pub trait ManagedResource: Sized + Send {
type Error: Error + Send + Sync + 'static;
// Required method
fn create() -> Result<Self, Self::Error>;
// Provided methods
fn is_healthy(&self) -> bool { ... }
fn cleanup(self) -> Result<(), Self::Error> { ... }
fn managed(self) -> ResourceGuard<Self> { ... }
}Expand description
Trait for types that can be managed as resources
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
Check if this resource is healthy
Sourcefn cleanup(self) -> Result<(), Self::Error>
fn cleanup(self) -> Result<(), Self::Error>
Clean up this resource (called when resource is dropped)
Sourcefn managed(self) -> ResourceGuard<Self>
fn managed(self) -> ResourceGuard<Self>
Create a managed resource guard
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.