Schema

Struct Schema 

Source
pub struct Schema { /* private fields */ }
Expand description

This struct represents a Schema File in memory, ready to be used to decode versioned PackedFiles.

Implementations§

Source§

impl Schema

Source

pub fn version(&self) -> &u16

It stores the structural version of the Schema.

Source

pub fn definitions(&self) -> &HashMap<String, Vec<Definition>>

It stores the versioned files inside the Schema.

Source

pub fn patches(&self) -> &HashMap<String, DefinitionPatch>

It stores a list of per-table, per-column patches.

Source§

impl Schema

Source

pub fn version_mut(&mut self) -> &mut u16

It stores the structural version of the Schema.

Source

pub fn definitions_mut(&mut self) -> &mut HashMap<String, Vec<Definition>>

It stores the versioned files inside the Schema.

Source

pub fn patches_mut(&mut self) -> &mut HashMap<String, DefinitionPatch>

It stores a list of per-table, per-column patches.

Source§

impl Schema

Source

pub fn set_version(&mut self, val: u16) -> &mut Self

It stores the structural version of the Schema.

Source

pub fn set_definitions( &mut self, val: HashMap<String, Vec<Definition>>, ) -> &mut Self

It stores the versioned files inside the Schema.

Source

pub fn set_patches( &mut self, val: HashMap<String, DefinitionPatch>, ) -> &mut Self

It stores a list of per-table, per-column patches.

Source§

impl Schema

Implementation of Schema.

Source

pub fn new_patch( patches: &HashMap<String, DefinitionPatch>, path: &Path, ) -> Result<()>

This function will save a new patch to the local patches list.

Source

pub fn remove_patch_for_table(table_name: &str, path: &Path) -> Result<()>

This function will remove the local patches for the specified table.

Source

pub fn remove_patch_for_field( table_name: &str, field_name: &str, path: &Path, ) -> Result<()>

This function will remove the local patches for the specified table and field.

Source

pub fn patch_value( &self, table_name: &str, column_name: &str, key: &str, ) -> Option<&String>

This function retrieves a value from a patch for a specific table, column and key.

Source

pub fn patches_for_table(&self, table_name: &str) -> Option<&DefinitionPatch>

This function retrieves all patches that affect a specific table.

Source

pub fn add_patch_to_patch_set( patch_set: &mut HashMap<String, DefinitionPatch>, patches: &HashMap<String, DefinitionPatch>, )

This function adds a list of patches into the currently loaded schema.

Note: if you add a patch, you’ll need to re-retrieve any definition you retrieved before in order for them to get patched.

Source

pub fn add_definition(&mut self, table_name: &str, definition: &Definition)

This function adds a definition for a table into the currently loaded schema.

Source

pub fn remove_definition(&mut self, table_name: &str, version: i32)

This function removes a definition for a table from the currently loaded schema.

Source

pub fn definitions_by_table_name_cloned( &self, table_name: &str, ) -> Option<Vec<Definition>>

This function returns a copy of a specific VersionedFile of DB Type from the provided Schema.

Source

pub fn definitions_by_table_name( &self, table_name: &str, ) -> Option<&Vec<Definition>>

This function returns a reference to a specific VersionedFile of DB Type from the provided Schema.

Source

pub fn definitions_by_table_name_mut( &mut self, table_name: &str, ) -> Option<&mut Vec<Definition>>

This function returns a mutable reference to a specific VersionedFile of DB Type from the provided Schema.

Source

pub fn definition_newer( &self, table_name: &str, candidates: &[Definition], ) -> Option<&Definition>

This function returns the last compatible definition of a DB Table.

As we may have versions from other games, we first need to check for the last definition in the dependency database. If that fails, we try to get it from the schema.

Source

pub fn definition_by_name_and_version( &self, table_name: &str, table_version: i32, ) -> Option<&Definition>

Source

pub fn definition_by_name_and_version_mut( &mut self, table_name: &str, table_version: i32, ) -> Option<&mut Definition>

Source

pub fn load(path: &Path, local_patches: Option<&Path>) -> Result<Self>

This function loads a Schema to memory from a provided .ron file.

Source

pub fn load_json(path: &Path) -> Result<Self>

This function loads a Schema to memory from a provided .json file.

Source

pub fn save(&mut self, path: &Path) -> Result<()>

This function saves a Schema from memory to a .ron file with the provided path.

Source

pub fn save_json(&mut self, path: &Path) -> Result<()>

This function saves a Schema from memory to a .json file with the provided path.

Source

pub fn export_to_json(schema_folder_path: &Path) -> Result<()>

This function exports all the schema files from the provided folder to .json.

For compatibility purposes.

Source

pub fn update( schema_path: &Path, schema_patches_path: &Path, game_name: &str, ) -> Result<()>

This function allow us to update the provided Schema from a legacy format into the current one.

Source

pub fn referencing_columns_for_table( &self, table_name: &str, definition: &Definition, ) -> HashMap<String, HashMap<String, Vec<String>>>

This function returns all columns that reference the columns on our specific table within the DB Tables of our Schema.

Returns a list of (local_column_name, vec<(remote_table_name, remote_column_name)>).

Source

pub fn tables_and_columns_referencing_our_own( &self, table_name: &str, column_name: &str, fields: &[Field], localised_fields: &[Field], ) -> (BTreeMap<String, Vec<String>>, bool)

This function returns the list of table/columns that reference the provided columns, and if there may be a loc entry that changing our column may need a change.

This supports more than one reference level, except for locs.

Source

pub fn load_patches_from_str( patch: &str, ) -> Result<HashMap<String, DefinitionPatch>>

This function tries to load multiple patches from a str.

Source

pub fn load_definitions_from_str( definition: &str, ) -> Result<HashMap<String, Definition>>

This function tries to load multiple definitions from a str.

Source

pub fn export_patches_to_str( patches: &HashMap<String, DefinitionPatch>, ) -> Result<String>

This function tries to export a list of patches to a ron string.

Source

pub fn export_definitions_to_str( definitions: &HashMap<String, Definition>, ) -> Result<String>

This function tries to export a list of definitions to a ron string.

Trait Implementations§

Source§

impl Clone for Schema

Source§

fn clone(&self) -> Schema

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 Schema

Source§

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

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

impl Default for Schema

Default implementation of Schema.

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Schema

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 PartialEq for Schema

Source§

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

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 Schema

Source§

impl StructuralPartialEq for Schema

Auto Trait Implementations§

§

impl Freeze for Schema

§

impl RefUnwindSafe for Schema

§

impl Send for Schema

§

impl Sync for Schema

§

impl Unpin for Schema

§

impl UnwindSafe for Schema

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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

Source§

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