pub struct AsyncDropGuard<T: Debug>(_);
Expand description

AsyncDropGuard allows async dropping of the contained value with a safety check.

Values wrapped in AsyncDropGuard offer an async AsyncDropGuard::async_drop function that can be called to asynchronously drop the value. You must always manually call AsyncDropGuard::async_drop. If the AsyncDropGuard leaves scope without a call to AsyncDropGuard::async_drop, a safety check will trigger and cause a panic.

Types wrapped in AsyncDropGuard must implement AsyncDrop to define what exactly should happen when AsyncDropGuard::async_drop gets called.

Warning: If a type T is supposed to be used with AsyncDropGuard, you must ensure that there is no way to create instances of T that aren’t wrapped in AsyncDropGuard. Ideally, T’s constructor directly creates an AsyncDropGuard[T]. If a T object exists without being wrapped in AsyncDropGuard, the safety check will not run and call sites might forget to correctly drop T.

Implementations

Wrap a value into an AsyncDropGuard. This enables the safety checks and will enforce that AsyncDropGuard::async_drop gets called before the AsyncDropGuard instance leaves scope.

Asynchronously drop the value. This will call AsyncDrop::async_drop_impl on the contained value. Calling code must ensure that the self value is dropped after this is called.

If this function does not get executed and the AsyncDropGuard instance leaves scope, that will cause a panic.

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.