Skip to main content

StrVarMap

Struct StrVarMap 

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

Heterogeneous map keyed by &str.

Each set / get hashes the name with FNV-1a and delegates to an internal VarMap. For static names, prefer VarMap with var! for better performance.

Implementations§

Source§

impl StrVarMap

Source

pub const fn new() -> StrVarMap

Creates an empty map.

Source

pub fn clear(&mut self)

Removes all keys and resets the arena. See VarMap::clear.

Source

pub fn set<T>(&mut self, var_name: &str, value: T)
where T: VarMapValue,

Inserts or overwrites var_name with value. See VarMap::set.

Source

pub fn update<T>(&mut self, var_name: &str, f: impl FnOnce(&mut T)) -> bool
where T: VarMapValue,

Updates the value at var_name in place when supported for T.

Returns false if var_name is missing, the stored type is not T, or T does not support in-place updates (see VarMapValue::update).

Source

pub fn get<'a, V>( &'a self, var_name: &str, ) -> Option<<V as VarMapValue>::Decoded<'a>>
where V: VarMapValue,

Returns the value for var_name decoded as V.

Returns None if the name is missing or the stored type does not match V.

Source

pub fn get_bool(&self, var_name: &str) -> Option<bool>

Returns the value as bool. See Self::get.

Source

pub fn get_u8(&self, var_name: &str) -> Option<u8>

Returns the value as u8. See Self::get.

Source

pub fn get_u16(&self, var_name: &str) -> Option<u16>

Returns the value as u16. See Self::get.

Source

pub fn get_u32(&self, var_name: &str) -> Option<u32>

Returns the value as u32. See Self::get.

Source

pub fn get_u64(&self, var_name: &str) -> Option<u64>

Returns the value as u64. See Self::get.

Source

pub fn get_i8(&self, var_name: &str) -> Option<i8>

Returns the value as i8. See Self::get.

Source

pub fn get_i16(&self, var_name: &str) -> Option<i16>

Returns the value as i16. See Self::get.

Source

pub fn get_i32(&self, var_name: &str) -> Option<i32>

Returns the value as i32. See Self::get.

Source

pub fn get_i64(&self, var_name: &str) -> Option<i64>

Returns the value as i64. See Self::get.

Source

pub fn get_f32(&self, var_name: &str) -> Option<f32>

Returns the value as f32. See Self::get.

Source

pub fn get_f64(&self, var_name: &str) -> Option<f64>

Returns the value as f64. See Self::get.

Source

pub fn get_str(&self, var_name: &str) -> Option<&str>

Returns the value as &str. See Self::get.

Source

pub fn get_bytes(&self, var_name: &str) -> Option<&[u8]>

Returns the value as &[u8]. See Self::get.

Source

pub fn get_char(&self, var_name: &str) -> Option<char>

Returns the value as char. See Self::get.

Source

pub fn get_ip(&self, var_name: &str) -> Option<IpAddr>

Returns the value as IpAddr. See Self::get.

Source

pub fn get_ipv4(&self, var_name: &str) -> Option<Ipv4Addr>

Returns the value as Ipv4Addr. See Self::get.

Source

pub fn get_ipv6(&self, var_name: &str) -> Option<Ipv6Addr>

Returns the value as Ipv6Addr. See Self::get.

Source

pub fn contains(&self, var_name: &str) -> bool

Returns true if var_name has a value (any type).

Source

pub fn allocated_size(&self) -> usize

Returns the total allocated size of the map.

Trait Implementations§

Source§

impl Default for StrVarMap

Source§

fn default() -> StrVarMap

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.