Struct LegacyTable

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

Source

pub fn name(&self) -> &str

Source

pub fn set_name(&mut self, name: Utf<'b>)

Source

pub fn base_id(&self) -> u16

Gets the minimum row ID in the table.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn rows(&self) -> impl Iterator<Item = LegacyRowRef<'_, 'b>>

Gets an iterator that visits this table’s rows

Source

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

Source

pub fn into_rows(self) -> impl Iterator<Item = LegacyRow<'b>>

Gets an owning iterator over this table’s rows

Source

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).

Source

pub fn columns(&self) -> impl Iterator<Item = &LegacyColumn<'b>>

Gets an iterator that visits this table’s column definitions

Source

pub fn columns_mut(&mut self) -> impl Iterator<Item = &mut LegacyColumn<'b>>

Gets an iterator over mutable references to this table’s column definitions.

Source

pub fn into_columns(self) -> impl Iterator<Item = LegacyColumn<'b>>

Gets an owning iterator over this table’s column definitions

Source

pub fn row_count(&self) -> usize

Source

pub fn column_count(&self) -> usize

Trait Implementations§

Source§

impl<'b> Clone for LegacyTable<'b>

Source§

fn clone(&self) -> LegacyTable<'b>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'b> Debug for LegacyTable<'b>

Source§

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

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

impl<'b> From<LegacyTable<'b>> for CompatTable<'b>

Source§

fn from(value: LegacyTable<'b>) -> Self

Converts to this type from the input type.
Source§

impl<'b> From<LegacyTable<'b>> for LegacyTableBuilder<'b>

Source§

fn from(value: LegacyTable<'b>) -> Self

Converts to this type from the input type.
Source§

impl<'b> PartialEq for LegacyTable<'b>

Source§

fn eq(&self, other: &LegacyTable<'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'b> TryFrom<LegacyTable<'b>> for ModernTable<'b>

Source§

type Error = FormatConvertError

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

fn try_from(legacy_table: LegacyTable<'b>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'b> TryFrom<ModernTable<'b>> for LegacyTable<'b>

Source§

type Error = FormatConvertError

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

fn try_from(modern_table: ModernTable<'b>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'b> StructuralPartialEq for LegacyTable<'b>

Auto Trait Implementations§

§

impl<'b> Freeze for LegacyTable<'b>

§

impl<'b> RefUnwindSafe for LegacyTable<'b>

§

impl<'b> Send for LegacyTable<'b>

§

impl<'b> Sync for LegacyTable<'b>

§

impl<'b> Unpin for LegacyTable<'b>

§

impl<'b> UnwindSafe for LegacyTable<'b>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.