Struct Abortable
#[must_use = "futures/streams do nothing unless you poll them"]
pub struct Abortable<T> { /* private fields */ }
A future/stream which can be remotely short-circuited using an AbortHandle.
Implementations
impl<T> Abortable<T>
fn new(task: T, reg: AbortRegistration) -> SelfCreates a new
Abortablefuture/stream using an existingAbortRegistration.AbortRegistrations can be acquired throughAbortHandle::new.When
abortis called on the handle tied toregor ifaborthas already been called, the future/stream will complete immediately without making any further progress.Examples:
Usage with futures:
# block_on;Usage with streams:
# block_on;fn is_aborted(&self) -> boolChecks whether the task has been aborted. Note that all this method indicates is whether
AbortHandle::abortwas called. This means that it will returntrueeven if:abortwas called after the task had completed.abortwas called while the task was being polled - the task may still be running and will not be stopped untilpollreturns.
Trait Implementations
impl<'__pin, T> Unpin for Abortable<T>
where
PinnedFieldsOf<__Origin<'__pin, T>>: Unpin,
impl<Fut> Future for Abortable<Fut>
where
Fut: Future,
type Output = Result<<Fut as Future>::Output, Aborted>;fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
impl<St> Stream for Abortable<St>
where
St: Stream,
type Item = <St as Stream>::Item;fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>
impl<T: Clone> Clone for Abortable<T>
fn clone(&self) -> Abortable<T>
impl<T: Debug> Debug for Abortable<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T> !RefUnwindSafe for Abortable<T>
impl<T> !UnwindSafe for Abortable<T>
impl<T> Freeze for Abortable<T>
where
T: Freeze,
impl<T> Send for Abortable<T>
where
T: Send,
impl<T> Sync for Abortable<T>
where
T: Sync,
impl<T> UnsafeUnpin for Abortable<T>
where
T: UnsafeUnpin,
Blanket Implementations
impl<F> IntoFuture for Abortable<T>
where
F: Future,
type Output = <F as Future>::Output;type IntoFuture = F;fn into_future(self) -> <F as IntoFuture>::IntoFuture
impl<F, T, E> TryFuture for Abortable<T>
where
F: Future<Output = Result<T, E>> + ?Sized,
type Ok = T;type Error = E;fn try_poll(self: Pin<&mut F>, cx: &mut Context<'_>) -> Poll<<F as Future>::Output>
impl<Fut> TryFutureExt for Abortable<T>
where
Fut: TryFuture + ?Sized,
impl<S> TryStreamExt for Abortable<T>
where
S: TryStream + ?Sized,
impl<S, T, E> TryStream for Abortable<T>
where
S: Stream<Item = Result<T, E>> + ?Sized,
type Ok = T;type Error = E;fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>
impl<T> Any for Abortable<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Abortable<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Abortable<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Abortable<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Abortable<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> FutureExt for Abortable<T>
where
T: Future + ?Sized,
impl<T> StreamExt for Abortable<T>
where
T: Stream + ?Sized,
impl<T> ToOwned for Abortable<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Abortable<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Abortable<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Abortable<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>