pub trait AsyncDrop {
type Error: Debug;
// Required method
fn async_drop_impl<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Implement this trait to define an async drop behavior for your type. See [AsyncDropGuard] for more details.
Required Associated Types§
Required Methods§
Sourcefn async_drop_impl<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_drop_impl<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Implement this to define drop behavior for your type. This will be called whenever [AsyncDropGuard::async_drop] is executed while wrapping a value of the type implementing AsyncDrop.
If the implementing type also implements Drop, then Drop::drop will be executed synchronously and after AsyncDrop::async_drop_impl.
AsyncDrop::async_drop_impl can return an error and that error will be propagated to the caller of [AsyncDropGuard::async_drop_impl]. If such an error happens, Drop::drop still gets executed.