@@ -5,7 +5,7 @@ use futures::Stream;
55/// inner module, used to group feature-specific imports
66#[ cfg( async_channel_impl = "tokio" ) ]
77mod inner {
8- pub use tokio:: sync:: mpsc:: error:: { SendError , TryRecvError } ;
8+ pub use tokio:: sync:: mpsc:: error:: { SendError , TryRecvError , TrySendError } ;
99
1010 use tokio:: sync:: mpsc:: { Receiver as InnerReceiver , Sender as InnerSender } ;
1111
@@ -47,7 +47,7 @@ mod inner {
4747/// inner module, used to group feature-specific imports
4848#[ cfg( async_channel_impl = "flume" ) ]
4949mod inner {
50- pub use flume:: { RecvError , SendError , TryRecvError } ;
50+ pub use flume:: { RecvError , SendError , TryRecvError , TrySendError } ;
5151
5252 use flume:: { r#async:: RecvStream , Receiver as InnerReceiver , Sender as InnerSender } ;
5353
@@ -77,7 +77,7 @@ mod inner {
7777/// inner module, used to group feature-specific imports
7878#[ cfg( not( any( async_channel_impl = "flume" , async_channel_impl = "tokio" ) ) ) ]
7979mod inner {
80- pub use async_std:: channel:: { RecvError , SendError , TryRecvError } ;
80+ pub use async_std:: channel:: { RecvError , SendError , TryRecvError , TrySendError } ;
8181
8282 use async_std:: channel:: { Receiver as InnerReceiver , Sender as InnerSender } ;
8383
@@ -121,6 +121,15 @@ impl<T> Sender<T> {
121121
122122 result
123123 }
124+
125+ /// Try to send a value over the channel. Will return immediately if the channel is full.
126+ ///
127+ /// # Errors
128+ /// - If the channel is full
129+ /// - If the channel is dropped
130+ pub fn try_send ( & self , msg : T ) -> Result < ( ) , TrySendError < T > > {
131+ self . 0 . try_send ( msg)
132+ }
124133}
125134
126135impl < T > Receiver < T > {
0 commit comments