pub trait AsyncReceiver<T: Sized + Send + Sync>:
Sized
+ Send
+ Sync {
// Required methods
fn callback(&self, cb: impl Into<ControllerCallback<Self>>);
fn clear_callback(&self);
async fn poll(&self) -> ControllerResult<()>;
async fn try_recv(&self) -> ControllerResult<Option<T>>;
// Provided method
async fn recv(&self) -> ControllerResult<T> { ... }
}Expand description
Asynchronous and thread-safe handle to receive data from a stream.
See Controller’s documentation for details.
Details about the sender are left to the implementor.
Required Methods§
Sourcefn callback(&self, cb: impl Into<ControllerCallback<Self>>)
fn callback(&self, cb: impl Into<ControllerCallback<Self>>)
Register a callback to be called on receive.
There can only be one callback registered at any given time.
Sourcefn clear_callback(&self)
fn clear_callback(&self)
Clear the currently registered callback.
Sourceasync fn poll(&self) -> ControllerResult<()>
async fn poll(&self) -> ControllerResult<()>
Block until a value is available, without consuming it.
Sourceasync fn try_recv(&self) -> ControllerResult<Option<T>>
async fn try_recv(&self) -> ControllerResult<Option<T>>
Attempt to receive a value, return None if nothing is currently available.
Provided Methods§
Sourceasync fn recv(&self) -> ControllerResult<T>
async fn recv(&self) -> ControllerResult<T>
Block until a value is available and returns it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.