Struct libradicl::rad_types::TagMap

source ·
pub struct TagMap<'a> { /* private fields */ }
Expand description

This type represents a mapping from TagDescs to a corresponding set of values conforming to these descriptions (i.e. in terms of types). The TagMap allows you to fetch the value for a specific tag by name or index, or to add values to a corresponding set of descriptions.

Implementations§

source§

impl<'a> TagMap<'a>

source

pub fn with_keyset(keyset: &'a [TagDesc]) -> Self

Create a new TagMap whose set of keys is determined by the provided keyset. This will have one value slot for each provided key.

source

pub fn add_checked(&mut self, val: TagValue) -> bool

Try to add the next tag value. If there is space and the type matches, add it and return true, otherwise return false.

source

pub fn add(&mut self, val: TagValue)

add the next TagValue to the data for this TagMap. This function doesn’t check if the type is correct or if too many tag values have been added. It should only be used when one is certain that the next tag value appropriately matches the next available key.

source

pub fn get(&self, key: &str) -> Option<&TagValue>

get the value for the tag associated with the name key, returns Some(&TagValue) for the appropriate tag if it exists, and None otherwise.

source

pub fn get_at_index(&self, idx: usize) -> Option<&TagValue>

get the value for the tag at index idx returns Some(&TagValue) if idx is in bounds and None otherwise.

Trait Implementations§

source§

impl<'a> Debug for TagMap<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Index<usize> for TagMap<'a>

source§

fn index(&self, index: usize) -> &Self::Output

Returns a reference to the TagValue in the TagMap at the provided index, panics if index is out of bounds.

§

type Output = TagValue

The returned type after indexing.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for TagMap<'a>

§

impl<'a> Send for TagMap<'a>

§

impl<'a> Sync for TagMap<'a>

§

impl<'a> Unpin for TagMap<'a>

§

impl<'a> UnwindSafe for TagMap<'a>

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>,

§

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>,

§

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.