@@ -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,20 @@ 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 async fn try_send ( & self , msg : T ) -> Result < ( ) , TrySendError < T > > {
131
+ #[ cfg( async_channel_impl = "flume" ) ]
132
+ let result = self . 0 . try_send ( msg) ;
133
+ #[ cfg( not( all( async_channel_impl = "flume" ) ) ) ]
134
+ let result = self . 0 . try_send ( msg) . await ;
135
+
136
+ result
137
+ }
124
138
}
125
139
126
140
impl < T > Receiver < T > {
0 commit comments