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
impl StrVarMapPool
Sourcepub fn new() -> StrVarMapPool
pub fn new() -> StrVarMapPool
Creates an empty pool.
Sourcepub fn allocate(&mut self) -> PoolHandle
pub fn allocate(&mut self) -> PoolHandle
Sourcepub fn release(&mut self, handle: PoolHandle)
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.
Sourcepub fn get(&self, handle: PoolHandle) -> Option<&StrVarMap>
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.
Sourcepub fn get_mut(&mut self, handle: PoolHandle) -> Option<&mut StrVarMap>
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.
Sourcepub fn clear(&mut self, strategy: ClearStrategy)
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.