pub trait SinkTrySend<T>: Sink<T> {
type Error: SinkTrySendError;
// Required method
fn try_send_or_return(
self: Pin<&mut Self>,
item: T,
) -> Result<(), (<Self as SinkTrySend<T>>::Error, T)>;
// Provided method
fn try_send(
self: Pin<&mut Self>,
item: T,
) -> Result<(), <Self as SinkTrySend<T>>::Error> { ... }
}
Expand description
A [Sink
] with a try_send
method like [futures::channel::mpsc::Sender
’s]
Required Associated Types§
Sourcetype Error: SinkTrySendError
type Error: SinkTrySendError
Errors that is not disconnected, or full
Required Methods§
Sourcefn try_send_or_return(
self: Pin<&mut Self>,
item: T,
) -> Result<(), (<Self as SinkTrySend<T>>::Error, T)>
fn try_send_or_return( self: Pin<&mut Self>, item: T, ) -> Result<(), (<Self as SinkTrySend<T>>::Error, T)>
Try to send a message msg
Like try_send
,
but if the send fails, the item is returned.
(When implementing the trait, implement this method.)
Provided Methods§
Sourcefn try_send(
self: Pin<&mut Self>,
item: T,
) -> Result<(), <Self as SinkTrySend<T>>::Error>
fn try_send( self: Pin<&mut Self>, item: T, ) -> Result<(), <Self as SinkTrySend<T>>::Error>
Try to send a message msg
If this returns with an error indicating that the stream is full, No arrangements will have been made for a wakeup when space becomes available.
If the send fails, item
is dropped.
If you need it back, use try_send_or_return
,
(When implementing the trait, implement try_send_or_return
, not this method.)