Struct stop_token::StopSource[][src]

pub struct StopSource { /* fields omitted */ }

StopSource produces StopToken and cancels all of its tokens on drop.

Example:

let stop_source = StopSource::new();
let stop_token = stop_source.stop_token();
schedule_some_work(stop_token);
drop(stop_source); // At this point, scheduled work notices that it is canceled.

Implementations

impl StopSource[src]

pub fn new() -> StopSource[src]

Creates a new StopSource.

pub fn stop_token(&self) -> StopToken

Notable traits for StopToken

impl Future for StopToken type Output = ();
[src]

Produces a new StopToken, associated with this source.

Once the source is destroyed, StopToken future completes.

Trait Implementations

impl Debug for StopSource[src]

impl Default for StopSource[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.