Skip to main content

SendAsyncScope

Struct SendAsyncScope 

Source
pub struct SendAsyncScope<'a> { /* private fields */ }
Available on crate feature alloc only.
Expand description

A LIFO stack of Send asynchronous cleanup actions.

Deferred closures and the futures they return must implement Send. Execution and cancellation behavior match LocalAsyncScope.

Implementations§

Source§

impl<'a> SendAsyncScope<'a>

Source

pub const fn new() -> Self

Creates an empty scope.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty scope with space for at least capacity actions.

Source

pub fn defer<F, Fut>(&mut self, action: F)
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = ()> + Send + 'a,

Queues a Send cleanup closure without invoking it.

Source

pub fn len(&self) -> usize

Returns the number of cleanup actions that have not completed.

Source

pub fn capacity(&self) -> usize

Returns the number of actions the scope can hold without reallocating.

Source

pub fn is_empty(&self) -> bool

Returns true when no cleanup actions remain.

Source

pub fn clear(&mut self)

Drops all queued actions without polling them further.

Source

pub fn run(&mut self) -> SendRun<'_, 'a>

Borrows the scope and drains its actions in LIFO order.

Source

pub async fn finish(self)

Consumes the scope and runs its actions in LIFO order.

Dropping the returned future also drops every remaining action.

Trait Implementations§

Source§

impl Debug for SendAsyncScope<'_>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SendAsyncScope<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SendAsyncScope<'a>

§

impl<'a> !Sync for SendAsyncScope<'a>

§

impl<'a> !UnwindSafe for SendAsyncScope<'a>

§

impl<'a> Freeze for SendAsyncScope<'a>

§

impl<'a> Send for SendAsyncScope<'a>

§

impl<'a> Unpin for SendAsyncScope<'a>

§

impl<'a> UnsafeUnpin for SendAsyncScope<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.