pub struct Context(/* private fields */);Expand description
A context value carrying a cancellation signal and optional deadline.
Cheap to clone — backed by Arc.
Implementations§
Source§impl Context
impl Context
Sourcepub fn done(&self) -> &Receiver<()>
pub fn done(&self) -> &Receiver<()>
A receiver that fires (returns None) when this context is cancelled or
its deadline elapses. Use it in select!:
go_lib::select! {
recv(ctx.done()) -> _v => { /* cancelled */ }
default => { /* still running */ }
}Sourcepub fn deadline(&self) -> Option<Instant>
pub fn deadline(&self) -> Option<Instant>
The deadline of this context, or None for contexts without one.
Sourcepub fn err(&self) -> Option<ContextError>
pub fn err(&self) -> Option<ContextError>
The cancellation error, or None if the context is still active.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl !UnwindSafe for Context
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