pub struct Stream { /* private fields */ }Expand description
A manually managed stream identity.
A Stream is a pure identity: it owns no backend resources (backend
streams are pool-managed by the runtimes) and is freely copyable. Use it to
pin work to a stable stream regardless of which thread or task executes it:
Stream::enterruns synchronous work on the stream.Stream::attachbinds a future to the stream, surviving executor work-stealing on any async runtime.Stream::spawnruns a closure on a fresh OS thread bound to a fresh stream (native std only).
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R
Runs f on this stream, restoring the previous stream afterward,
including on unwind.
Sourcepub fn attach<F: Future>(&self, fut: F) -> StreamFuture<F> ⓘ
pub fn attach<F: Future>(&self, fut: F) -> StreamFuture<F> ⓘ
Binds a future to this stream.
The returned future re-establishes the stream around every poll, so the binding survives executor work-stealing on any async runtime, without requiring any particular executor.
Trait Implementations§
impl Copy for Stream
impl Eq for Stream
impl StructuralPartialEq for Stream
Auto Trait Implementations§
impl Freeze for Stream
impl RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl UnsafeUnpin for Stream
impl UnwindSafe for Stream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.