@@ -72,8 +72,14 @@ impl<T: Send + 'static> IntoHandler<T> for FifoChannel {
7272impl < T > FifoChannelHandler < T > {
7373 /// Attempt to fetch an incoming value from the channel associated with this receiver, returning
7474 /// an error if the channel is empty or if all senders have been dropped.
75- pub fn try_recv ( & self ) -> ZResult < T > {
76- self . 0 . try_recv ( ) . map_err ( Into :: into)
75+ ///
76+ /// If the channel is empty, this will return [`None`].
77+ pub fn try_recv ( & self ) -> ZResult < Option < T > > {
78+ match self . 0 . try_recv ( ) {
79+ Ok ( value) => Ok ( Some ( value) ) ,
80+ Err ( flume:: TryRecvError :: Empty ) => Ok ( None ) ,
81+ Err ( err) => Err ( err. into ( ) ) ,
82+ }
7783 }
7884
7985 /// Wait for an incoming value from the channel associated with this receiver, returning an
@@ -84,14 +90,26 @@ impl<T> FifoChannelHandler<T> {
8490
8591 /// Wait for an incoming value from the channel associated with this receiver, returning an
8692 /// error if all senders have been dropped or the deadline has passed.
87- pub fn recv_deadline ( & self , deadline : Instant ) -> ZResult < T > {
88- self . 0 . recv_deadline ( deadline) . map_err ( Into :: into)
93+ ///
94+ /// If the deadline has expired, this will return [`None`].
95+ pub fn recv_deadline ( & self , deadline : Instant ) -> ZResult < Option < T > > {
96+ match self . 0 . recv_deadline ( deadline) {
97+ Ok ( value) => Ok ( Some ( value) ) ,
98+ Err ( flume:: RecvTimeoutError :: Timeout ) => Ok ( None ) ,
99+ Err ( err) => Err ( err. into ( ) ) ,
100+ }
89101 }
90102
91103 /// Wait for an incoming value from the channel associated with this receiver, returning an
92104 /// error if all senders have been dropped or the timeout has expired.
93- pub fn recv_timeout ( & self , duration : Duration ) -> ZResult < T > {
94- self . 0 . recv_timeout ( duration) . map_err ( Into :: into)
105+ ///
106+ /// If the timeout has expired, this will return [`None`].
107+ pub fn recv_timeout ( & self , duration : Duration ) -> ZResult < Option < T > > {
108+ match self . 0 . recv_timeout ( duration) {
109+ Ok ( value) => Ok ( Some ( value) ) ,
110+ Err ( flume:: RecvTimeoutError :: Timeout ) => Ok ( None ) ,
111+ Err ( err) => Err ( err. into ( ) ) ,
112+ }
95113 }
96114
97115 /// Create a blocking iterator over the values received on the channel that finishes iteration
0 commit comments