pub struct Loc { /* private fields */ }Expand description
In-memory representation of a decoded Loc (localisation) file.
Wraps a TableInMemory with a fixed three-column schema: key, text, and tooltip.
Unlike DB tables, Loc files don’t require external schema definitions.
§Structure
Each row contains:
key(StringU16): Unique identifier for the localised texttext(StringU16): The localised string contenttooltip(Boolean): Flag of unknown purpose
§Example
use rpfm_lib::files::{Decodeable, loc::Loc};
use std::io::Cursor;
let mut reader = Cursor::new(loc_data);
let loc = Loc::decode(&mut reader, &None).unwrap();
// Access entries
for row in loc.data().iter() {
// row[0] = key, row[1] = text, row[2] = tooltip
}Implementations§
Source§impl Loc
impl Loc
Sourcepub fn table(&self) -> &TableInMemory
pub fn table(&self) -> &TableInMemory
The underlying table data with key, text, and tooltip columns.
Source§impl Loc
impl Loc
Sourcepub fn set_table(&mut self, val: TableInMemory) -> &mut Self
pub fn set_table(&mut self, val: TableInMemory) -> &mut Self
The underlying table data with key, text, and tooltip columns.
Source§impl Loc
Implementation of Loc.
impl Loc
Implementation of Loc.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty Loc table.
Initializes with the standard three-column schema (key, text, tooltip) but no data rows.
Sourcepub fn definition(&self) -> &Definition
pub fn definition(&self) -> &Definition
Returns the schema definition used by this Loc table.
Sourcepub fn data(&self) -> Cow<'_, [Vec<DecodedData>]>
pub fn data(&self) -> Cow<'_, [Vec<DecodedData>]>
Returns the table rows as a slice of decoded data.
Sourcepub fn data_mut(&mut self) -> &mut Vec<Vec<DecodedData>>
pub fn data_mut(&mut self) -> &mut Vec<Vec<DecodedData>>
Returns a mutable reference to the table rows.
Ensure modifications maintain valid structure (3 columns per row).
Sourcepub fn new_row(&self) -> Vec<DecodedData>
pub fn new_row(&self) -> Vec<DecodedData>
Creates a new row with default placeholder values.
Sourcepub fn set_data(&mut self, data: &[Vec<DecodedData>]) -> Result<()>
pub fn set_data(&mut self, data: &[Vec<DecodedData>]) -> Result<()>
Replaces all table data with the provided rows.
§Errors
Returns an error if rows don’t match the expected 3-column structure.
Sourcepub fn column_position_by_name(&self, column_name: &str) -> Option<usize>
pub fn column_position_by_name(&self, column_name: &str) -> Option<usize>
Returns the column index for a given column name, or None if not found.
Valid column names: "key" (0), "text" (1), "tooltip" (2).
Sourcepub fn set_definition(&mut self, new_definition: &Definition)
pub fn set_definition(&mut self, new_definition: &Definition)
Replaces the table definition and migrates existing data to match.
Typically not needed for Loc files since the definition is fixed.
Sourcepub fn read_header<R: ReadBytes>(data: &mut R) -> Result<(i32, u32)>
pub fn read_header<R: ReadBytes>(data: &mut R) -> Result<(i32, u32)>
Reads and validates the Loc file header.
§Returns
A tuple of (version, entry_count). Version is always 1 in known files.
§Errors
Returns RLibError::DecodingLocNotALocTable if the header is invalid
(wrong byte order mark, wrong file type, or insufficient data).
Sourcepub fn merge(sources: &[&Self]) -> Result<Self>
pub fn merge(sources: &[&Self]) -> Result<Self>
Merges multiple Loc tables into a single new table.
Combines all rows from the source tables. Duplicate keys are preserved (not deduplicated).
Trait Implementations§
Source§impl Decodeable for Loc
impl Decodeable for Loc
Source§impl<'de> Deserialize<'de> for Loc
impl<'de> Deserialize<'de> for Loc
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>,
Source§impl Encodeable for Loc
impl Encodeable for Loc
Source§fn encode<W: WriteBytes>(
&mut self,
buffer: &mut W,
_extra_data: &Option<EncodeableExtraData<'_>>,
) -> Result<()>
fn encode<W: WriteBytes>( &mut self, buffer: &mut W, _extra_data: &Option<EncodeableExtraData<'_>>, ) -> Result<()>
Source§impl From<TableInMemory> for Loc
Implementation to create a Loc from a Table directly.
impl From<TableInMemory> for Loc
Implementation to create a Loc from a Table directly.
Source§fn from(table: TableInMemory) -> Self
fn from(table: TableInMemory) -> Self
impl StructuralPartialEq for Loc
Auto Trait Implementations§
impl Freeze for Loc
impl RefUnwindSafe for Loc
impl Send for Loc
impl Sync for Loc
impl Unpin for Loc
impl UnsafeUnpin for Loc
impl UnwindSafe for Loc
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.