pub struct Field { /* private fields */ }Expand description
Defines a single field within a table definition.
A Field describes one column in a database table, including its data type, constraints,
and metadata. Fields can be modified at runtime via schema patches.
§Field Types
See FieldType for the supported data types (integers, strings, sequences, etc.).
§Field Attributes and Constraints
- Key Fields: When
is_keyis true, the field is part of the table’s primary key - References: Fields can reference columns in other tables for foreign key relationships
- Lookups: Additional columns from referenced tables to display in the UI
- Filenames: Fields that contain file paths within the game’s VFS
- Bitwise: Numeric fields that should be split into multiple boolean columns
- Enums: Numeric fields with named values
- Colours: Fields that are part of an RGB triplet
§Patching
Most field properties can be overridden via schema patches. Use the accessor methods
(e.g., is_key(), default_value()) rather than direct field access to ensure
patches are applied.
Implementations§
Source§impl Field
impl Field
Sourcepub fn set_name(&mut self, val: String) -> &mut Self
pub fn set_name(&mut self, val: String) -> &mut Self
Name of the field.
Must match the field name from the Assembly Kit table definition (usually snake_case, but not always).
Sourcepub fn set_field_type(&mut self, val: FieldType) -> &mut Self
pub fn set_field_type(&mut self, val: FieldType) -> &mut Self
Data type of the field.
Determines how the field’s binary data is interpreted.
Sourcepub fn set_is_key(&mut self, val: bool) -> &mut Self
pub fn set_is_key(&mut self, val: bool) -> &mut Self
Whether this field is part of the table’s primary key.
Can be overridden via patches. Use is_key() to get the patched value.
Sourcepub fn set_default_value(&mut self, val: Option<String>) -> &mut Self
pub fn set_default_value(&mut self, val: Option<String>) -> &mut Self
Default value for this field when creating new rows.
Can be overridden via patches. Use default_value() to get the patched value.
Sourcepub fn set_is_filename(&mut self, val: bool) -> &mut Self
pub fn set_is_filename(&mut self, val: bool) -> &mut Self
Whether this field contains a filename/path.
Can be overridden via patches. Use is_filename() to get the patched value.
Sourcepub fn set_filename_relative_path(&mut self, val: Option<String>) -> &mut Self
pub fn set_filename_relative_path(&mut self, val: Option<String>) -> &mut Self
Semicolon-separated list of relative paths where files for this field can be found.
Only applicable when is_filename is true. Can be overridden via patches.
Use filename_relative_path() to get the parsed, patched value.
Sourcepub fn set_is_reference(&mut self, val: Option<(String, String)>) -> &mut Self
pub fn set_is_reference(&mut self, val: Option<(String, String)>) -> &mut Self
Foreign key reference to another table.
Format: Some((table_name, column_name)) where table_name doesn’t include
the _tables suffix. Can be overridden via patches.
Use is_reference() to get the patched value.
Sourcepub fn set_lookup(&mut self, val: Option<Vec<String>>) -> &mut Self
pub fn set_lookup(&mut self, val: Option<Vec<String>>) -> &mut Self
Additional columns from the referenced table to show in lookups.
Only applicable when is_reference is Some. Can be overridden via patches.
Use lookup() to get the patched value.
Sourcepub fn set_description(&mut self, val: String) -> &mut Self
pub fn set_description(&mut self, val: String) -> &mut Self
Human-readable description of the field’s purpose.
Can be overridden via patches. Use description() to get the patched value.
Sourcepub fn set_ca_order(&mut self, val: i16) -> &mut Self
pub fn set_ca_order(&mut self, val: i16) -> &mut Self
Visual position in CA’s Assembly Kit table editor.
-1 means the position is unknown. This is used to maintain column order
consistency with the Assembly Kit.
Sourcepub fn set_is_bitwise(&mut self, val: i32) -> &mut Self
pub fn set_is_bitwise(&mut self, val: i32) -> &mut Self
Number of boolean columns this field should be split into.
Only applicable to numeric fields. A value > 1 means the field should be expanded into that many boolean columns when processed.
Sourcepub fn set_enum_values(&mut self, val: BTreeMap<i32, String>) -> &mut Self
pub fn set_enum_values(&mut self, val: BTreeMap<i32, String>) -> &mut Self
Named values for this field when treated as an enum.
Maps integer values to their string names. When non-empty, the field is treated as a string enum in processed fields.
NOTE: When possible, prefer using lookups instead of enum_values.
Sourcepub fn set_is_part_of_colour(&mut self, val: Option<u8>) -> &mut Self
pub fn set_is_part_of_colour(&mut self, val: Option<u8>) -> &mut Self
Index of the RGB colour group this field belongs to.
When set, this field is part of a 3-field RGB triplet that should be merged into a single ColourRGB field when processed.
Sourcepub fn set_unused(&mut self, val: bool) -> &mut Self
pub fn set_unused(&mut self, val: bool) -> &mut Self
Whether this field is unused by the game.
Not serialized - determined via patches at runtime.
Use unused() to get the patched value.
Source§impl Field
Implementation of Field.
impl Field
Implementation of Field.
Sourcepub fn new(
name: String,
field_type: FieldType,
is_key: bool,
default_value: Option<String>,
is_filename: bool,
filename_relative_path: Option<String>,
is_reference: Option<(String, String)>,
lookup: Option<Vec<String>>,
description: String,
ca_order: i16,
is_bitwise: i32,
enum_values: BTreeMap<i32, String>,
is_part_of_colour: Option<u8>,
) -> Self
pub fn new( name: String, field_type: FieldType, is_key: bool, default_value: Option<String>, is_filename: bool, filename_relative_path: Option<String>, is_reference: Option<(String, String)>, lookup: Option<Vec<String>>, description: String, ca_order: i16, is_bitwise: i32, enum_values: BTreeMap<i32, String>, is_part_of_colour: Option<u8>, ) -> Self
Creates a new field with the specified properties.
§Arguments
name- Field namefield_type- Data type of the fieldis_key- Whether this field is part of the primary keydefault_value- Optional default valueis_filename- Whether this field contains a filenamefilename_relative_path- Optional path hints for filename fieldsis_reference- Optional foreign key reference(table, column)lookup- Optional lookup columnsdescription- Field descriptionca_order- Visual position in Assembly Kitis_bitwise- Number of boolean columns to expand into (0 or 1 = no expansion)enum_values- Map of integer values to string names for enum fieldsis_part_of_colour- Optional RGB colour group index
§Returns
Returns a new Field instance with the specified properties.
Sourcepub fn field_type(&self) -> &FieldType
pub fn field_type(&self) -> &FieldType
Returns the field’s data type.
Sourcepub fn is_key(&self, schema_patches: Option<&DefinitionPatch>) -> bool
pub fn is_key(&self, schema_patches: Option<&DefinitionPatch>) -> bool
Sourcepub fn default_value(
&self,
schema_patches: Option<&DefinitionPatch>,
) -> Option<String>
pub fn default_value( &self, schema_patches: Option<&DefinitionPatch>, ) -> Option<String>
Sourcepub fn is_filename(&self, schema_patches: Option<&DefinitionPatch>) -> bool
pub fn is_filename(&self, schema_patches: Option<&DefinitionPatch>) -> bool
Sourcepub fn filename_relative_path(
&self,
schema_patches: Option<&DefinitionPatch>,
) -> Option<Vec<String>>
pub fn filename_relative_path( &self, schema_patches: Option<&DefinitionPatch>, ) -> Option<Vec<String>>
Returns the filename relative paths, applying patches if provided.
The paths are split by semicolons and backslashes are converted to forward slashes.
§Arguments
schema_patches- Optional patches to check for overrides
§Returns
Returns a vector of relative path strings, or None if no paths are defined.
Sourcepub fn is_reference(
&self,
schema_patches: Option<&DefinitionPatch>,
) -> Option<(String, String)>
pub fn is_reference( &self, schema_patches: Option<&DefinitionPatch>, ) -> Option<(String, String)>
Returns the foreign key reference information, applying patches if provided.
§Arguments
schema_patches- Optional patches to check for overrides
§Returns
Returns Some((table_name, column_name)) if this field references another table,
or None if it doesn’t. The table name does not include the _tables suffix.
Sourcepub fn lookup(
&self,
schema_patches: Option<&DefinitionPatch>,
) -> Option<Vec<String>>
pub fn lookup( &self, schema_patches: Option<&DefinitionPatch>, ) -> Option<Vec<String>>
Returns the lookup column list, applying patches if provided.
Lookup columns are additional columns from the referenced table that should be displayed in the UI alongside the referenced field.
§Arguments
schema_patches- Optional patches to check for overrides
§Returns
Returns a vector of column names to look up, or None if no lookups are defined.
Sourcepub fn lookup_no_patch(&self) -> Option<Vec<String>>
pub fn lookup_no_patch(&self) -> Option<Vec<String>>
Returns the lookup column list without applying patches.
§Returns
Returns a vector of column names from the base definition, ignoring any patches.
Sourcepub fn lookup_hardcoded(
&self,
schema_patches: Option<&DefinitionPatch>,
) -> HashMap<String, String>
pub fn lookup_hardcoded( &self, schema_patches: Option<&DefinitionPatch>, ) -> HashMap<String, String>
Returns hardcoded lookup values from patches.
Hardcoded lookups provide predefined value mappings that don’t require querying the referenced table. This is useful for performance or when the referenced table is not available.
§Arguments
schema_patches- Optional patches to check for hardcoded values
§Returns
Returns a map of key values to their display strings. Returns an empty map if no hardcoded lookups are defined.
Sourcepub fn description(&self, schema_patches: Option<&DefinitionPatch>) -> String
pub fn description(&self, schema_patches: Option<&DefinitionPatch>) -> String
Sourcepub fn ca_order(&self) -> i16
pub fn ca_order(&self) -> i16
Returns the CA order value.
This represents the visual position of the field in CA’s Assembly Kit.
A value of -1 indicates the position is unknown.
Sourcepub fn is_bitwise(&self) -> i32
pub fn is_bitwise(&self) -> i32
Returns the bitwise expansion count.
§Returns
0or1: No bitwise expansion> 1: Number of boolean columns this field should be expanded into
Sourcepub fn enum_values(&self) -> &BTreeMap<i32, String>
pub fn enum_values(&self) -> &BTreeMap<i32, String>
Returns the enum value mappings.
§Returns
Returns a reference to the map of integer values to their string names. Empty if this field is not an enum.
Sourcepub fn enum_values_to_option(&self) -> Option<BTreeMap<i32, String>>
pub fn enum_values_to_option(&self) -> Option<BTreeMap<i32, String>>
Returns the enum values as an Option.
Sourcepub fn enum_values_to_string(&self) -> String
pub fn enum_values_to_string(&self) -> String
Returns the enum values as a semicolon-separated string.
§Returns
Returns a string in the format "value1,name1;value2,name2;...".
Sourcepub fn is_part_of_colour(&self) -> Option<u8>
pub fn is_part_of_colour(&self) -> Option<u8>
Sourcepub fn is_numeric(&self, _schema_patches: Option<&DefinitionPatch>) -> bool
pub fn is_numeric(&self, _schema_patches: Option<&DefinitionPatch>) -> bool
Returns whether this field should be treated as numeric (currently always false).
This is a placeholder for future functionality and currently always returns false.
§Arguments
_schema_patches- Unused (reserved for future use)
Sourcepub fn cannot_be_empty(&self, schema_patches: Option<&DefinitionPatch>) -> bool
pub fn cannot_be_empty(&self, schema_patches: Option<&DefinitionPatch>) -> bool
Sourcepub fn unused(&self, schema_patches: Option<&DefinitionPatch>) -> bool
pub fn unused(&self, schema_patches: Option<&DefinitionPatch>) -> bool
Returns whether this field is unused by the game.
Fields marked as unused are still present in the binary format but are not actually used by the game logic. This information is primarily determined via patches.
§Arguments
schema_patches- Optional patches to check for theunusedflag
§Returns
Returns true if the field is marked as unused (either in the base definition or via patch).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Field
impl<'de> Deserialize<'de> for Field
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>,
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
impl UnwindSafe for Field
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.