Trait SinkTrySend

Source
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§

Source

type Error: SinkTrySendError

Errors that is not disconnected, or full

Required Methods§

Source

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§

Source

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.)

Implementations on Foreign Types§

Source§

impl<T> SinkTrySend<T> for Sender<T>

Implementors§

impl<T, C> SinkTrySend<T> for Sender<T, C>
where T: HasMemoryCost + Debug + Send + 'static, C: ChannelSpec, C::Sender<Entry<T>>: SinkTrySend<Entry<T>>, <C::Sender<Entry<T>> as SinkTrySend<Entry<T>>>::Error: Send + Sync,