Skip to main content

PutIf

Trait PutIf 

Source
pub trait PutIf<T: 'static>: 'static {
    // Required methods
    fn put(&self, item: T) -> Pin<Box<dyn Future<Output = ()> + '_>>;
    fn try_put(&self, item: T) -> Result<(), T>;
    fn can_put(&self) -> bool;
}
Expand description

What a put export offers. Implemented by the FIFO’s put side; a PutPort holds one of these once connected.

put returns a boxed future rather than being an async fn because it is called through dyn: a trait object cannot have an async fn whose future type varies by implementor.

Required Methods§

Source

fn put(&self, item: T) -> Pin<Box<dyn Future<Output = ()> + '_>>

Block until the FIFO has room, then hand the item over.

Source

fn try_put(&self, item: T) -> Result<(), T>

Take the item only if it fits right now; hand it back if it does not.

Source

fn can_put(&self) -> bool

Is there room this instant? (Zero time; the answer can go stale.)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§