pub struct ShutdownToken { /* private fields */ }Expand description
A cancellation token with a typed ShutdownReason.
Clone-to-share; every clone observes the same cancellation.
Implementations§
Source§impl ShutdownToken
impl ShutdownToken
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Non-blocking check.
Sourcepub fn cancel(&self, reason: ShutdownReason)
pub fn cancel(&self, reason: ShutdownReason)
Trigger shutdown. Idempotent — only the first call records its reason; later calls are no-ops.
Sourcepub fn reason(&self) -> Option<ShutdownReason>
pub fn reason(&self) -> Option<ShutdownReason>
Read the first-recorded reason, if any.
Sourcepub fn child_token(&self) -> ShutdownToken
pub fn child_token(&self) -> ShutdownToken
Construct a child token that inherits cancellation from self.
Cancelling the child does NOT cancel the parent. Useful when a subsystem wants to shut its own subtasks down without affecting the outer service.
Trait Implementations§
Source§impl Clone for ShutdownToken
impl Clone for ShutdownToken
Source§fn clone(&self) -> ShutdownToken
fn clone(&self) -> ShutdownToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShutdownToken
impl Debug for ShutdownToken
Auto Trait Implementations§
impl Freeze for ShutdownToken
impl !RefUnwindSafe for ShutdownToken
impl Send for ShutdownToken
impl Sync for ShutdownToken
impl Unpin for ShutdownToken
impl UnsafeUnpin for ShutdownToken
impl !UnwindSafe for ShutdownToken
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