pub trait Manager: Sync + Send {
type Type;
type Error;
// Required methods
fn create<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Type, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn recycle<'life0, 'life1, 'async_trait>(
&'life0 self,
obj: &'life1 mut Self::Type
) -> Pin<Box<dyn Future<Output = RecycleResult<Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn detach(&self, _obj: &mut Self::Type) { ... }
}
Expand description
Manager responsible for creating new Object
s or recycling existing ones.
Required Associated Types§
Required Methods§
sourcefn create<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Type, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Self::Type, Self::Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Creates a new instance of Manager::Type
.
sourcefn recycle<'life0, 'life1, 'async_trait>(
&'life0 self,
obj: &'life1 mut Self::Type
) -> Pin<Box<dyn Future<Output = RecycleResult<Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recycle<'life0, 'life1, 'async_trait>( &'life0 self, obj: &'life1 mut Self::Type ) -> Pin<Box<dyn Future<Output = RecycleResult<Self::Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
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 Object::take()
method for
removing an Object
from a Pool
. If the Manager
doesn’t hold
any references to the handed out Object
s then the default
implementation can be used which does nothing.