pub trait StreamExtFinalizationCallbacks: Stream + Sized {
// Provided methods
fn on_complete<FComplete>(
self,
complete_cb: FComplete,
) -> StreamWithFinalizationCallbacks<Self, FComplete, impl FnOnce()>
where FComplete: FnOnce() { ... }
fn on_cancellation<FCancel>(
self,
cancel_cb: FCancel,
) -> StreamWithFinalizationCallbacks<Self, impl FnOnce(), FCancel>
where FCancel: FnOnce() { ... }
}Expand description
The extension trait that adds .on_complete(...) and .on_cancellation(...) to all Streams.
To use it, do:
use ogre_stream_ext::StreamExtFinalizationCallbacks;
use futures::StreamExt; // if you also want .map(), .filter(), etc.
Then: mystream .map(|x| …) .on_complete(|| println!(“done!”)) .on_cancellation(|| println!(“cancelled early!”))
Provided Methods§
fn on_complete<FComplete>(
self,
complete_cb: FComplete,
) -> StreamWithFinalizationCallbacks<Self, FComplete, impl FnOnce()>where
FComplete: FnOnce(),
fn on_cancellation<FCancel>(
self,
cancel_cb: FCancel,
) -> StreamWithFinalizationCallbacks<Self, impl FnOnce(), FCancel>where
FCancel: FnOnce(),
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.