[][src]Struct sync_tokens::cancelation_token::Cancelable

pub struct Cancelable { /* fields omitted */ }

Assists in canceling an asynchronous operation. Typically, this struct is kept private and used with either allow_cancel() or Self::future(). A CancelationToken is given to whoever can cancel operations

See example at sync-tokens

Implementations

impl Cancelable[src]

pub async fn allow_cancel<TFuture, T, '_>(
    &'_ self,
    future: TFuture,
    canceled_result: T
) -> T where
    TFuture: Future<Output = T> + Unpin
[src]

Allows canceling the future. canceled_result is what's returned when the CancelationToken is canceled. It is reccomended that the future return a Result so that canceled_result can be an error

pub fn future(&self) -> CancelationTokenFuture

Notable traits for CancelationTokenFuture

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

Returns a future that returns once the CancelationToken is canceled. Intended for use with select

Trait Implementations

impl Clone for Cancelable[src]

impl Debug for Cancelable[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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.