pub trait Manager: Sync + Send {
type Type: Send;
type Error: Send;
// Required methods
fn create(
&self,
) -> impl Future<Output = Result<Self::Type, Self::Error>> + Send;
fn recycle(
&self,
obj: &mut Self::Type,
metrics: &Metrics,
) -> impl Future<Output = RecycleResult<Self::Error>> + Send;
// Provided method
fn detach(&self, _obj: &mut Self::Type) { ... }
}Expand description
Manager responsible for creating new super::Objects or recycling existing ones.
Required Associated Types§
Sourcetype Type: Send
type Type: Send
Type of super::Objects that this Manager creates and recycles.
Sourcetype Error: Send
type Error: Send
Error that this Manager can return when creating and/or recycling
super::Objects.
Required Methods§
Sourcefn create(&self) -> impl Future<Output = Result<Self::Type, Self::Error>> + Send
fn create(&self) -> impl Future<Output = Result<Self::Type, Self::Error>> + Send
Creates a new instance of Manager::Type.
Sourcefn recycle(
&self,
obj: &mut Self::Type,
metrics: &Metrics,
) -> impl Future<Output = RecycleResult<Self::Error>> + Send
fn recycle( &self, obj: &mut Self::Type, metrics: &Metrics, ) -> impl Future<Output = RecycleResult<Self::Error>> + Send
Tries to recycle an instance of Manager::Type.
§Errors
Returns Manager::Error if the instance couldn’t be recycled.
Provided Methods§
Sourcefn detach(&self, _obj: &mut Self::Type)
fn detach(&self, _obj: &mut Self::Type)
Detaches an instance of Manager::Type from this Manager.
This method is called when using the super::Object::take() method for
removing an super::Object from a super::Pool. If the Manager doesn’t hold
any references to the handed out super::Objects then the default
implementation can be used which does nothing.
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.