pub struct CancellationToken { /* private fields */ }Expand description
A shareable token for requesting cooperative transfer cancellation.
Clones refer to the same cancellation state. Calling Self::cancel on
any clone makes Self::is_cancelled return true on every clone.
Cancellation cannot be reset. An in-progress blocking read is not
interrupted immediately; cancellation is checked at defined points in
the transfer implementation.
Implementations§
Source§impl CancellationToken
impl CancellationToken
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Requests cancellation for every operation sharing this token.
This method returns immediately and does not wait for a read or transfer to stop.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns whether cancellation has been requested.
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Auto Trait Implementations§
impl Freeze for CancellationToken
impl RefUnwindSafe for CancellationToken
impl Send for CancellationToken
impl Sync for CancellationToken
impl Unpin for CancellationToken
impl UnsafeUnpin for CancellationToken
impl UnwindSafe for CancellationToken
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