pub trait OneshotReceiverExt<T> {
// Required method
fn with_guard<F>(self, guard: F) -> GuardedReceiver<F, T> ⓘ
where F: FnMut(T);
}
Available on crate feature
async
only.Expand description
Extensions for oneshot channel types.
Required Methods§
Sourcefn with_guard<F>(self, guard: F) -> GuardedReceiver<F, T> ⓘwhere
F: FnMut(T),
fn with_guard<F>(self, guard: F) -> GuardedReceiver<F, T> ⓘwhere
F: FnMut(T),
If the receiver is dropped without the value being observed, the provided closure will be called with the value that was left in the channel.
This is useful in cases where you want to cleanup resources if the receiver of this value has gone away. If the sender and receiver are running on separate threads, it’s possible for the sender to succeed, and for the receiver to be concurrently dropped, never realizing that it received a value.
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.