pub trait ManageObject: Send + Sync {
type Object: Send;
type Error: Send;
// Required methods
fn create(
&self,
) -> impl Future<Output = Result<Self::Object, Self::Error>> + Send;
fn is_recyclable(
&self,
o: &mut Self::Object,
status: &ObjectStatus,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
// Provided method
fn on_detached(&self, _o: &mut Self::Object) { ... }
}Expand description
A trait whose instance creates new objects and recycles existing ones.
Required Associated Types§
Required Methods§
Sourcefn create(
&self,
) -> impl Future<Output = Result<Self::Object, Self::Error>> + Send
fn create( &self, ) -> impl Future<Output = Result<Self::Object, Self::Error>> + Send
Creates a new object.
Sourcefn is_recyclable(
&self,
o: &mut Self::Object,
status: &ObjectStatus,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn is_recyclable( &self, o: &mut Self::Object, status: &ObjectStatus, ) -> impl Future<Output = Result<(), Self::Error>> + Send
Whether the object o is recyclable.
Returns Ok(()) if the object is recyclable; otherwise, returns an error.
Provided Methods§
Sourcefn on_detached(&self, _o: &mut Self::Object)
fn on_detached(&self, _o: &mut Self::Object)
A callback invoked when an object is detached from the pool.
If this instance does not hold any references to the object, 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.