@@ -5,7 +5,7 @@ use futures::Stream;
5
5
/// inner module, used to group feature-specific imports
6
6
#[ cfg( async_channel_impl = "tokio" ) ]
7
7
mod inner {
8
- pub use tokio:: sync:: mpsc:: error:: { SendError , TryRecvError } ;
8
+ pub use tokio:: sync:: mpsc:: error:: { SendError , TryRecvError , TrySendError } ;
9
9
10
10
use tokio:: sync:: mpsc:: { Receiver as InnerReceiver , Sender as InnerSender } ;
11
11
@@ -47,7 +47,7 @@ mod inner {
47
47
/// inner module, used to group feature-specific imports
48
48
#[ cfg( async_channel_impl = "flume" ) ]
49
49
mod inner {
50
- pub use flume:: { RecvError , SendError , TryRecvError } ;
50
+ pub use flume:: { RecvError , SendError , TryRecvError , TrySendError } ;
51
51
52
52
use flume:: { r#async:: RecvStream , Receiver as InnerReceiver , Sender as InnerSender } ;
53
53
@@ -77,7 +77,7 @@ mod inner {
77
77
/// inner module, used to group feature-specific imports
78
78
#[ cfg( not( any( async_channel_impl = "flume" , async_channel_impl = "tokio" ) ) ) ]
79
79
mod inner {
80
- pub use async_std:: channel:: { RecvError , SendError , TryRecvError } ;
80
+ pub use async_std:: channel:: { RecvError , SendError , TryRecvError , TrySendError } ;
81
81
82
82
use async_std:: channel:: { Receiver as InnerReceiver , Sender as InnerSender } ;
83
83
@@ -121,6 +121,15 @@ impl<T> Sender<T> {
121
121
122
122
result
123
123
}
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
+ }
124
133
}
125
134
126
135
impl < T > Receiver < T > {
0 commit comments