Struct stop_token::StopSource [−][src]
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ⓘ
[src]
Produces a new StopToken
, associated with this source.
Once the source is destroyed, StopToken
future completes.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for StopSource
[src]
impl Send for StopSource
[src]
impl Sync for StopSource
[src]
impl Unpin for StopSource
[src]
impl UnwindSafe for StopSource
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,