pub struct LegacyTable<'b> { /* private fields */ }
Expand description
The BDAT table representation in legacy formats, used for all games before Xenoblade 3.
§Characteristics
§Cell types
Unlike modern tables, legacy tables can have multiple-value cells, or mask a value’s bits to create flags.
See also: LegacyRow
§Examples
§Operating on cells
use bdat::{Label, legacy::LegacyTable, label_hash};
fn get_character_id(table: &LegacyTable, row_id: u16) -> u32 {
let cell = table.row(row_id).get("CharacterID");
// Unlike modern tables, we can't simply operate on the value.
// We can `match` on cell types, or simply cast them and handle errors:
cell.as_single().unwrap().get_as::<u32>()
}
Implementations§
Source§impl<'b> LegacyTable<'b>
impl<'b> LegacyTable<'b>
pub fn name(&self) -> &str
pub fn set_name(&mut self, name: Utf<'b>)
Sourcepub fn row(&self, id: u16) -> LegacyRowRef<'_, 'b>
pub fn row(&self, id: u16) -> LegacyRowRef<'_, 'b>
Gets a row by its ID.
Note: the ID is the row’s numerical ID, which could be different from the index of the row in the table’s row list. That is because BDAT tables can have arbitrary start IDs.
§Panics
If there is no row for the given ID.
Sourcepub fn row_mut(&mut self, id: u16) -> LegacyRowMut<'_, 'b>
pub fn row_mut(&mut self, id: u16) -> LegacyRowMut<'_, 'b>
Gets a mutable view of a row by its ID
Note: the ID is the row’s numerical ID, which could be different from the index of the row in the table’s row list. That is because BDAT tables can have arbitrary start IDs.
§Panics
If there is no row for the given ID
Sourcepub fn get_row(&self, id: u16) -> Option<LegacyRowRef<'_, 'b>>
pub fn get_row(&self, id: u16) -> Option<LegacyRowRef<'_, 'b>>
Attempts to get a row by its ID.
If there is no row for the given ID, this returns None
.
Note: the ID is the row’s numerical ID, which could be different from the index of the row in the table’s row list. That is because BDAT tables can have arbitrary start IDs.
Sourcepub fn get_row_mut(&mut self, id: u16) -> Option<LegacyRowMut<'_, 'b>>
pub fn get_row_mut(&mut self, id: u16) -> Option<LegacyRowMut<'_, 'b>>
Attempts to get a mutable view of a row by its ID.
If there is no row for the given ID, this returns None
.
Note: the ID is the row’s numerical ID, which could be different from the index of the row in the table’s row list. That is because BDAT tables can have arbitrary start IDs.
Sourcepub fn rows(&self) -> impl Iterator<Item = LegacyRowRef<'_, 'b>>
pub fn rows(&self) -> impl Iterator<Item = LegacyRowRef<'_, 'b>>
Gets an iterator that visits this table’s rows
Sourcepub fn rows_mut(&mut self) -> impl Iterator<Item = LegacyRowMut<'_, 'b>>
pub fn rows_mut(&mut self) -> impl Iterator<Item = LegacyRowMut<'_, 'b>>
Gets an iterator over mutable references to this table’s rows.
The iterator does not allow structural modifications to the table. To add, remove, or
reorder rows, convert the table to a new builder first. (TableBuilder::from(table)
)
Sourcepub fn into_rows(self) -> impl Iterator<Item = LegacyRow<'b>>
pub fn into_rows(self) -> impl Iterator<Item = LegacyRow<'b>>
Gets an owning iterator over this table’s rows
Sourcepub fn into_rows_id(self) -> impl Iterator<Item = (u16, LegacyRow<'b>)>
pub fn into_rows_id(self) -> impl Iterator<Item = (u16, LegacyRow<'b>)>
Gets an owning iterator over this table’s rows, in pairs of
(row ID, row)
.
Sourcepub fn columns(&self) -> impl Iterator<Item = &LegacyColumn<'b>>
pub fn columns(&self) -> impl Iterator<Item = &LegacyColumn<'b>>
Gets an iterator that visits this table’s column definitions
Sourcepub fn columns_mut(&mut self) -> impl Iterator<Item = &mut LegacyColumn<'b>>
pub fn columns_mut(&mut self) -> impl Iterator<Item = &mut LegacyColumn<'b>>
Gets an iterator over mutable references to this table’s column definitions.
Sourcepub fn into_columns(self) -> impl Iterator<Item = LegacyColumn<'b>>
pub fn into_columns(self) -> impl Iterator<Item = LegacyColumn<'b>>
Gets an owning iterator over this table’s column definitions
pub fn row_count(&self) -> usize
pub fn column_count(&self) -> usize
Trait Implementations§
Source§impl<'b> Clone for LegacyTable<'b>
impl<'b> Clone for LegacyTable<'b>
Source§fn clone(&self) -> LegacyTable<'b>
fn clone(&self) -> LegacyTable<'b>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more