Trait deadpool::managed::Manager

source ·
pub trait Manager: Sync + Send {
    type Type;
    type Error;

    // Required methods
    fn create(&self) -> impl Future<Output = Result<Self::Type, Self::Error>>;
    fn recycle(
        &self,
        obj: &mut Self::Type,
        metrics: &Metrics
    ) -> impl Future<Output = RecycleResult<Self::Error>>;

    // Provided method
    fn detach(&self, _obj: &mut Self::Type) { ... }
}
Available on crate feature managed only.
Expand description

Manager responsible for creating new Objects or recycling existing ones.

Required Associated Types§

source

type Type

Type of Objects that this Manager creates and recycles.

source

type Error

Error that this Manager can return when creating and/or recycling Objects.

Required Methods§

source

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

Creates a new instance of Manager::Type.

source

fn recycle( &self, obj: &mut Self::Type, metrics: &Metrics ) -> impl Future<Output = RecycleResult<Self::Error>>

Tries to recycle an instance of Manager::Type.

§Errors

Returns Manager::Error if the instance couldn’t be recycled.

Provided Methods§

source

fn detach(&self, _obj: &mut Self::Type)

Detaches an instance of Manager::Type from this Manager.

This method is called when using the Object::take() method for removing an Object from a Pool. If the Manager doesn’t hold any references to the handed out Objects then the default implementation can be used which does nothing.

Object Safety§

This trait is not object safe.

Implementors§