pub struct RawTable {
pub definition: Option<RawDefinition>,
pub rows: Vec<RawTableRow>,
}Expand description
Complete table data parsed from Assembly Kit XML files.
This represents an entire table including its structure definition and all row data.
Corresponds to a .xml data file in the Assembly Kit (e.g., units_tables.xml).
§Structure
The table contains:
- An optional definition (field structure) - typically populated during parsing
- All rows of data from the XML file
§Usage
After parsing with RawTable::read() or RawTable::read_all(), the table
can be converted to RPFM’s internal formats:
RawTable::to_db()- Convert to DB format for saving as a PackFile tableRawTable::to_table()- Convert to in-memory table for manipulation
Fields§
§definition: Option<RawDefinition>Table structure definition (fields, types, relationships).
This is populated by combining the parsed data structure with the
corresponding TWaD_ definition file.
rows: Vec<RawTableRow>All rows of data in the table.
Implementations§
Source§impl RawTable
Implementation of RawTable.
impl RawTable
Implementation of RawTable.
Sourcepub fn read_all(
raw_tables_folder: &Path,
version: i16,
tables_to_skip: &[&str],
) -> Result<Vec<Self>>
pub fn read_all( raw_tables_folder: &Path, version: i16, tables_to_skip: &[&str], ) -> Result<Vec<Self>>
Reads all table data files from an Assembly Kit directory.
This function scans the directory for table data XML files and parses them
into RawTable instances. It first reads all table definitions, then
reads the corresponding data files.
§Arguments
raw_tables_folder- Directory containing both definition and data filesversion- Assembly Kit version (0-2)tables_to_skip- Table names to exclude from parsing
§Returns
Returns a vector of successfully parsed tables. Tables that fail to parse or are in the skip list are excluded.
§Errors
Returns an error if:
- The version is unsupported (not 0, 1, or 2)
- The directory cannot be read
- Definition files cannot be parsed
§Note
Individual table data files that fail to parse are silently skipped rather than causing the entire operation to fail.
Sourcepub fn read(
raw_definition: &RawDefinition,
raw_table_data_folder: &Path,
version: i16,
) -> Result<Self>
pub fn read( raw_definition: &RawDefinition, raw_table_data_folder: &Path, version: i16, ) -> Result<Self>
Parses a single Assembly Kit table data file.
Reads the XML data file corresponding to the provided definition and parses
it into a RawTable. The data file must have the same name as the definition
(without the TWaD_ prefix).
§Arguments
raw_definition- Table structure definitionraw_table_data_folder- Directory containing the data XML filesversion- Assembly Kit version (0-2)
§Returns
Returns a RawTable with the definition and all parsed row data.
§Errors
Returns an error if:
- The version is unsupported (not 0, 1, or 2)
- The data file cannot be opened
- The XML is malformed
- The table is
translated_texts.xml(returnsRLibError::AssemblyKitTableTableIgnored)
§Special Cases
§translated_texts.xml
This file (present in Rome 2, Attila, Thrones) is ~400MB and not needed for schema processing, so it’s explicitly ignored.
§XML Preprocessing
Before parsing, the XML undergoes several transformations to work around
serde_xml_rs limitations:
- Table-specific row tags are renamed to generic
<rows> - Field tags are renamed to
<datafield>with the name as an attribute - Empty fields are filled with placeholder text (removed after parsing)
Sourcepub fn to_db(&self, definition: Option<&Definition>) -> Result<DB>
pub fn to_db(&self, definition: Option<&Definition>) -> Result<DB>
Converts the raw table to RPFM’s DB format.
This is a convenience wrapper around RawTable::to_table() that converts
the result to a DB struct suitable for saving as a PackFile table.
§Arguments
definition- Optional RPFM schema definition for type validation and patching
§Returns
Returns a DB instance containing the converted table data.
§Errors
Returns an error if:
- The table has no definition
- Field types cannot be determined
- Data conversion fails (e.g., invalid number format)
Sourcepub fn to_table(&self, definition: Option<&Definition>) -> Result<TableInMemory>
pub fn to_table(&self, definition: Option<&Definition>) -> Result<TableInMemory>
Converts the raw table to RPFM’s in-memory table format.
This function performs the main conversion from Assembly Kit’s XML representation to RPFM’s internal table structure, including type conversion and handling of missing fields.
§Arguments
definition- Optional RPFM schema definition used for:- Type validation and patching (e.g., fixing string types on empty fields)
- Providing default values for missing fields
§Returns
Returns a TableInMemory with all data converted to proper types.
§Errors
Returns an error if:
- The raw table has no definition (returns
RLibError::RawTableMissingDefinition) - Field data cannot be parsed to the expected type
- The table structure is invalid
§Type Conversion
String values from XML are converted to typed data:
"true","1"→Boolean(true)"123"→I32(123),F32(123.0), etc.""→ Appropriate default value for the type
§Missing Field Handling
Some games (Thrones, Attila, Rome 2, Shogun 2) omit empty fields from rows. This function inserts default values for any missing fields based on their type.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RawTable
impl<'de> Deserialize<'de> for RawTable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RawTable
impl RefUnwindSafe for RawTable
impl Send for RawTable
impl Sync for RawTable
impl Unpin for RawTable
impl UnsafeUnpin for RawTable
impl UnwindSafe for RawTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.