Skip to main content

Field

Struct Field 

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

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 name
  • field_type - Data type of the field
  • is_key - Whether this field is part of the primary key
  • default_value - Optional default value
  • is_filename - Whether this field contains a filename
  • filename_relative_path - Optional path hints for filename fields
  • is_reference - Optional foreign key reference (table, column)
  • lookup - Optional lookup columns
  • description - Field description
  • ca_order - Visual position in Assembly Kit
  • is_bitwise - Number of boolean columns to expand into (0 or 1 = no expansion)
  • enum_values - Map of integer values to string names for enum fields
  • is_part_of_colour - Optional RGB colour group index
§Returns

Returns a new Field instance with the specified properties.

Source

pub fn name(&self) -> &str

Returns the field name.

Source

pub fn field_type(&self) -> &FieldType

Returns the field’s data type.

Source

pub fn is_key(&self, schema_patches: Option<&DefinitionPatch>) -> bool

Returns whether this field is a key field, applying patches if provided.

§Arguments
  • schema_patches - Optional patches to check for overrides
§Returns

Returns true if the field is a key field (either by base definition or patch).

Source

pub fn default_value( &self, schema_patches: Option<&DefinitionPatch>, ) -> Option<String>

Returns the field’s default value, applying patches if provided.

§Arguments
  • schema_patches - Optional patches to check for overrides
§Returns

Returns the default value if set (either by base definition or patch).

Source

pub fn is_filename(&self, schema_patches: Option<&DefinitionPatch>) -> bool

Returns whether this field contains a filename, applying patches if provided.

§Arguments
  • schema_patches - Optional patches to check for overrides
§Returns

Returns true if the field contains a filename path.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn description(&self, schema_patches: Option<&DefinitionPatch>) -> String

Returns the field description, applying patches if provided.

§Arguments
  • schema_patches - Optional patches to check for overrides
§Returns

Returns the field’s description text. May be empty if no description is set.

Source

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.

Source

pub fn is_bitwise(&self) -> i32

Returns the bitwise expansion count.

§Returns
  • 0 or 1: No bitwise expansion
  • > 1: Number of boolean columns this field should be expanded into
Source

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.

Source

pub fn enum_values_to_option(&self) -> Option<BTreeMap<i32, String>>

Returns the enum values as an Option.

Source

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;...".

Source

pub fn is_part_of_colour(&self) -> Option<u8>

Returns the RGB colour group index.

§Returns

Returns the colour group index if this field is part of an RGB triplet, or None if it’s not a colour field.

Source

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

pub fn cannot_be_empty(&self, schema_patches: Option<&DefinitionPatch>) -> bool

Returns whether this field cannot be empty, checking patches.

§Arguments
  • schema_patches - Optional patches to check for the not_empty flag
§Returns

Returns true if the field is marked as “cannot be empty” via a patch.

Source

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 the unused flag
§Returns

Returns true if the field is marked as unused (either in the base definition or via patch).

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

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 Debug for Field

Source§

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

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

impl Default for Field

Default implementation of FieldType.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Field

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&RawField> for Field

Source§

fn from(raw_field: &RawField) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Field

Source§

fn eq(&self, other: &Field) -> 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 Serialize for Field

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Field

Source§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,