Skip to main content

StrVarMapPool

Struct StrVarMapPool 

Source
pub struct StrVarMapPool { /* private fields */ }
Expand description

Pool of reusable StrVarMap values.

Same checkout, release, and handle rules as VarMapPool. Use this when pooled maps are keyed by runtime strings.

use varmap::StrVarMapPool;

let mut pool = StrVarMapPool::new();
let h = pool.allocate();
pool.get_mut(h).unwrap().set("host", "localhost");
assert_eq!(pool.get(h).unwrap().get_str("host"), Some("localhost"));
pool.release(h);

Implementations§

Source§

impl StrVarMapPool

Source

pub fn new() -> StrVarMapPool

Creates an empty pool.

Source

pub fn allocate(&mut self) -> PoolHandle

Checks out a StrVarMap, reusing a released slot when one is available.

The map is empty. Reused slots are cleared first; previously allocated capacity is kept. The returned handle is valid until release or clear.

Source

pub fn release(&mut self, handle: PoolHandle)

Returns handle’s map to the pool.

The map is cleared and the slot may be reused by a later allocate. handle and any copies become invalid. A stale handle is ignored.

Source

pub fn get(&self, handle: PoolHandle) -> Option<&StrVarMap>

Returns the StrVarMap for handle.

Returns None if the handle is stale, was released, or does not refer to a live slot in this pool.

Source

pub fn get_mut(&mut self, handle: PoolHandle) -> Option<&mut StrVarMap>

Returns a mutable StrVarMap for handle.

Returns None if the handle is stale, was released, or does not refer to a live slot in this pool.

Source

pub fn clear(&mut self, strategy: ClearStrategy)

Invalidates every outstanding handle and applies strategy.

See ClearStrategy for what is dropped versus retained. Keep variants leave kept maps empty while preserving capacity for later allocates.

Trait Implementations§

Source§

impl Default for StrVarMapPool

Source§

fn default() -> StrVarMapPool

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.