pub struct CancelFlag { /* private fields */ }Expand description
Shared cancel flag checked by HTTP retries between attempts.
Stores the first observed CancelKind so cooperative checks can surface
exit 130 vs 143 correctly (first cancel wins).
§Interior mutability
Cross-task flag (Arc<AtomicU8>): signal waiter, wall-clock path, and HTTP
pollers share one flag. An atomic is the right primitive (not Mutex<u8> /
Cell — multi-task, single primitive, no compound invariant).
Ordering is Ordering::SeqCst on every load/store/CAS so first-writer-wins
is totally ordered against cooperative check without a separate fence story.
Implementations§
Source§impl CancelFlag
impl CancelFlag
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Marks the flag as cancelled with CancelKind::Terminate (generic cancel).
Sourcepub fn cancel_with(&self, kind: CancelKind)
pub fn cancel_with(&self, kind: CancelKind)
Marks the flag as cancelled with an explicit signal kind.
First writer wins; subsequent calls are no-ops (idempotent).
CAS uses SeqCst success/failure orderings (see type docs).
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns whether cancellation was requested.
Sourcepub fn kind(&self) -> Option<CancelKind>
pub fn kind(&self) -> Option<CancelKind>
Returns the stored kind when cancelled.
Sourcepub fn check(&self) -> AppResult<()>
pub fn check(&self) -> AppResult<()>
Returns AppError::interrupted or AppError::terminated when cancelled.
§Errors
Returns crate::error::ErrorKind::Interrupted or crate::error::ErrorKind::Terminated when the flag is set.