pub enum Finalizer {
Sync(Box<dyn FnOnce() + Send>),
Async(Pin<Box<dyn Future<Output = ()> + Send>>),
}Expand description
A finalizer that runs during region close.
Finalizers are stored in a stack and executed LIFO when a region transitions to the Finalizing state. This ensures resources are released in the reverse order they were acquired.
Variants§
Sync(Box<dyn FnOnce() + Send>)
Synchronous finalizer (runs directly on scheduler thread).
Use for lightweight cleanup that doesn’t need to await.
Async(Pin<Box<dyn Future<Output = ()> + Send>>)
Asynchronous finalizer (runs as masked task).
Use for cleanup that needs to perform async operations. Runs under a cancel mask to prevent interruption.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Finalizer
impl !RefUnwindSafe for Finalizer
impl Send for Finalizer
impl !Sync for Finalizer
impl Unpin for Finalizer
impl UnsafeUnpin for Finalizer
impl !UnwindSafe for Finalizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).