pub struct CancellationToken { /* private fields */ }Expand description
A cooperative cancellation token.
Supports both synchronous polling (is_cancelled()) and async waiting
(cancelled()). The async path uses tokio::select! in streaming loops
to interrupt mid-stream without waiting for the next token.
Implementations§
Source§impl CancellationToken
impl CancellationToken
pub fn new() -> CancellationToken
Sourcepub fn new_pair() -> (CancellationHandle, CancellationToken)
pub fn new_pair() -> (CancellationHandle, CancellationToken)
Create a split pair: a write-only handle and a read-only token.
Useful when the cancellation signal sender and the receiver should be passed to different components independently.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if cancellation has been requested (synchronous poll).
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Source§fn clone(&self) -> CancellationToken
fn clone(&self) -> CancellationToken
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 Default for CancellationToken
impl Default for CancellationToken
Source§fn default() -> CancellationToken
fn default() -> CancellationToken
Returns the “default value” for a type. Read more
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