Struct bpx::table::NamedItemTable
source · [−]pub struct NamedItemTable<T> { /* private fields */ }
Available on crate feature
table
only.Expand description
Helper class to work with named items stored as arrays in a BPX container.
Implementations
sourceimpl<T> NamedItemTable<T>
impl<T> NamedItemTable<T>
sourcepub fn with_list(list: Vec<T>) -> Self
pub fn with_list(list: Vec<T>) -> Self
Constructs a new NamedItemTable from a list of items.
Arguments
list
: the list of items.
returns: ItemTable
sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Gets immutable access to an item by its index.
Returns None if the index is out of bounds.
Arguments
index
: the index to find.
returns: Option<&T>
sourceimpl<T: Item> NamedItemTable<T>
impl<T: Item> NamedItemTable<T>
sourcepub fn load_name<'a, T1>(
&self,
container: &Container<T1>,
strings: &'a StringSection,
item: &T
) -> Result<&'a str, Error>
pub fn load_name<'a, T1>(
&self,
container: &Container<T1>,
strings: &'a StringSection,
item: &T
) -> Result<&'a str, Error>
sourcepub fn push(&mut self, name: String, item: T) -> usize
pub fn push(&mut self, name: String, item: T) -> usize
Adds a new item to this table.
Arguments
name
: the name of the item to add.item
: the item to add.
returns: ()
sourcepub fn find_by_name<T1>(
&self,
container: &Container<T1>,
strings: &StringSection,
name: &str
) -> Result<Option<&T>, Error>
pub fn find_by_name<T1>(
&self,
container: &Container<T1>,
strings: &StringSection,
name: &str
) -> Result<Option<&T>, Error>
Lookup an item by its name. Returns None if the item does not exist.
Arguments
container
: the container to load strings from if needed.strings
: the string section to use for loading strings if needed.name
: the name to search for.
returns: Result<Option<&T>, Error>
Errors
A Error is returned if the strings could not be loaded.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for NamedItemTable<T> where
T: RefUnwindSafe,
impl<T> Send for NamedItemTable<T> where
T: Send,
impl<T> !Sync for NamedItemTable<T>
impl<T> Unpin for NamedItemTable<T> where
T: Unpin,
impl<T> UnwindSafe for NamedItemTable<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more