pub struct Halt(/* private fields */);Expand description
Clonable, infallible cooperative-cancellation token.
Clones share the same underlying flag. cancel() is one-way; there is
no reset() by design — construct a fresh Halt for a fresh
operation.
Construct with Halt::new (or Halt::default). The Default
impl forwards to new() — both produce a fresh, uncancelled token.
The pair exists because clippy’s new_without_default lint requires
Default whenever a public new() is present, even when the two
would do exactly the same thing.
Implementations§
Source§impl Halt
impl Halt
Sourcepub fn from_arc(flag: Arc<AtomicBool>) -> Self
pub fn from_arc(flag: Arc<AtomicBool>) -> Self
Wrap an existing Arc<AtomicBool> as a Halt. Useful as a
bridge during the 0.18 deprecation window: callers that already
hold an Arc<AtomicBool> (e.g. Drive::halt_flag(), the
deprecated DiscStream::set_halt) can adopt the new token API
without changing the underlying flag.
Cancelling either side flips the same bit — the wrapping Halt
and the original Arc are two views over one shared flag.
Sourcepub fn as_arc(&self) -> &Arc<AtomicBool>
pub fn as_arc(&self) -> &Arc<AtomicBool>
Borrow the underlying Arc<AtomicBool>. Used at boundaries with
pre-Halt APIs that still take an Arc<AtomicBool> directly
(CopyOptions::halt, the deprecated DiscStream::set_halt).
Round 3 deletes those boundaries and this accessor with them.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Read the shared flag.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Halt
impl RefUnwindSafe for Halt
impl Send for Halt
impl Sync for Halt
impl Unpin for Halt
impl UnsafeUnpin for Halt
impl UnwindSafe for Halt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more