Trait ManageObject

Source
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§

Source

type Object: Send

The type of objects that this instance creates and recycles.

Source

type Error: Send

The type of errors that this instance can return.

Required Methods§

Source

fn create( &self, ) -> impl Future<Output = Result<Self::Object, Self::Error>> + Send

Creates a new object.

Source

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§

Source

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.

Implementors§