Skip to main content

ReservationExt

Trait ReservationExt 

Source
pub trait ReservationExt<T> {
    // Required method
    fn send_or_reserve(
        &self,
        value: T,
    ) -> Result<Option<Reservation<T>>, SendError<T>>
       where T: 'static;
}
Expand description

Extension trait for bounded channel sends that can reserve capacity.

Required Methods§

Source

fn send_or_reserve( &self, value: T, ) -> Result<Option<Reservation<T>>, SendError<T>>
where T: 'static,

Attempts to send immediately, reserving the message when the channel is full.

Returns:

  • Ok(None) when the value was sent immediately.
  • Ok(Some(_)) when the channel was full. Await the reservation and call Reserved::send to deliver the value.
  • Err(_) when the receiver has been dropped.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§