pub struct CancellationSource { /* private fields */ }Expand description
The control handle that triggers cancellation.
Dropping the source does not cancel the token — call cancel
explicitly. This prevents accidental cancellation on scope exit.
Implementations§
Source§impl CancellationSource
impl CancellationSource
Sourcepub fn token(&self) -> CancellationToken
pub fn token(&self) -> CancellationToken
Obtain a cloneable token that observes this source’s state.
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Signal cancellation. All tokens derived from this source will observe
is_cancelled() == true and any pending wait_timeout calls will wake.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check whether cancellation has already been requested.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CancellationSource
impl RefUnwindSafe for CancellationSource
impl Send for CancellationSource
impl Sync for CancellationSource
impl Unpin for CancellationSource
impl UnsafeUnpin for CancellationSource
impl UnwindSafe for CancellationSource
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