pub trait AsyncFallibleExt<T> {
// Required methods
fn send_lossy(&mut self, msg: T) -> impl Future<Output = bool> + Send;
fn try_send_lossy(&mut self, msg: T) -> bool;
fn request<R, F>(
&mut self,
make_msg: F,
) -> impl Future<Output = Option<R>> + Send
where R: Send,
F: FnOnce(Sender<R>) -> T + Send;
fn request_or<R, F>(
&mut self,
make_msg: F,
default: R,
) -> impl Future<Output = R> + Send
where R: Send,
F: FnOnce(Sender<R>) -> T + Send;
fn request_or_default<R, F>(
&mut self,
make_msg: F,
) -> impl Future<Output = R> + Send
where R: Default + Send,
F: FnOnce(Sender<R>) -> T + Send;
}Expand description
Extension trait for bounded channel operations that may fail due to disconnection.
Similar to FallibleExt but for bounded channels where send operations are async.
Required Methods§
Sourcefn send_lossy(&mut self, msg: T) -> impl Future<Output = bool> + Send
fn send_lossy(&mut self, msg: T) -> impl Future<Output = bool> + Send
Send a message asynchronously, returning true if successful.
Use this for fire-and-forget messages where the receiver may have been dropped during shutdown. The return value can be ignored if the caller doesn’t need to know whether the send succeeded.
Sourcefn try_send_lossy(&mut self, msg: T) -> bool
fn try_send_lossy(&mut self, msg: T) -> bool
Try to send a message without blocking, returning true if successful.
Use this for fire-and-forget messages where you don’t want to wait
if the channel is full. Returns false if the channel is full or
disconnected.
Sourcefn request<R, F>(
&mut self,
make_msg: F,
) -> impl Future<Output = Option<R>> + Send
fn request<R, F>( &mut self, make_msg: F, ) -> impl Future<Output = Option<R>> + Send
Send a request message containing a oneshot responder and await the response.
Returns None if:
- The receiver has been dropped (send fails)
- The responder is dropped without sending (receive fails)
Sourcefn request_or<R, F>(
&mut self,
make_msg: F,
default: R,
) -> impl Future<Output = R> + Send
fn request_or<R, F>( &mut self, make_msg: F, default: R, ) -> impl Future<Output = R> + Send
Send a request and return the provided default on failure.
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.