Trait Poolable

Source
pub trait Poolable {
    // Required methods
    fn new_for_pool() -> Self;
    fn reset_for_pool(&mut self);
}
Expand description

Trait for objects that can be safely used in object pools

This trait provides a safe alternative to Default for object pool usage. Unlike Default, this creates obviously invalid objects that are safe for pool pre-allocation but cannot be accidentally used in production.

Required Methods§

Source

fn new_for_pool() -> Self

Create a poolable object with invalid/empty state

§Safety

This method creates objects that are intended for pool pre-allocation and must be properly initialized before use. The returned object should have obviously invalid values.

Source

fn reset_for_pool(&mut self)

Reset the object to poolable state

This method resets an object to a state suitable for pool reuse. It should clear any sensitive data and reset to invalid state.

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§