Skip to main content

AsAsyncDisposable

Trait AsAsyncDisposable 

Source
pub trait AsAsyncDisposable {
    // Required method
    fn to_item_disposal(&self) -> Option<ItemDisposal>;
}
Expand description

An item that may be disposable, at once or by a task: AsyncDisposeMany disposes the items for which to_item_disposal gives a disposal, and leaves the others alone, as upstream disposes the items that implement IDisposable or IAsyncDisposable.

Deviation (DEVIATIONS.md, DynamicData): .NET tests the type of an item at run time, and prefers IDisposable when an item implements both. Rust has no such test for a generic item, so the type of the items says how they are disposed: an Rc of an IAsyncDisposable is disposed by its task, an Rc<dyn IDisposable> at once. Another type implements the trait, or async_dispose_many_with takes the function that tells how an item is disposed.

Required Methods§

Source

fn to_item_disposal(&self) -> Option<ItemDisposal>

How the item is disposed, or None when it is not disposable.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AsAsyncDisposable for Rc<dyn IAsyncDisposable>

Source§

impl AsAsyncDisposable for Rc<dyn IDisposable>

Source§

impl<X: AsAsyncDisposable> AsAsyncDisposable for Option<X>

Source§

impl<X: IAsyncDisposable + 'static> AsAsyncDisposable for Rc<X>

Implementors§