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
impl Schema
Sourcepub fn definitions(&self) -> &HashMap<String, Vec<Definition>>
pub fn definitions(&self) -> &HashMap<String, Vec<Definition>>
It stores the versioned files inside the Schema.
Sourcepub fn patches(&self) -> &HashMap<String, DefinitionPatch>
pub fn patches(&self) -> &HashMap<String, DefinitionPatch>
It stores a list of per-table, per-column patches.
Source§impl Schema
impl Schema
Sourcepub fn version_mut(&mut self) -> &mut u16
pub fn version_mut(&mut self) -> &mut u16
It stores the structural version of the Schema.
Sourcepub fn definitions_mut(&mut self) -> &mut HashMap<String, Vec<Definition>>
pub fn definitions_mut(&mut self) -> &mut HashMap<String, Vec<Definition>>
It stores the versioned files inside the Schema.
Sourcepub fn patches_mut(&mut self) -> &mut HashMap<String, DefinitionPatch>
pub fn patches_mut(&mut self) -> &mut HashMap<String, DefinitionPatch>
It stores a list of per-table, per-column patches.
Source§impl Schema
impl Schema
Sourcepub fn set_version(&mut self, val: u16) -> &mut Self
pub fn set_version(&mut self, val: u16) -> &mut Self
It stores the structural version of the Schema.
Sourcepub fn set_definitions(
&mut self,
val: HashMap<String, Vec<Definition>>,
) -> &mut Self
pub fn set_definitions( &mut self, val: HashMap<String, Vec<Definition>>, ) -> &mut Self
It stores the versioned files inside the Schema.
Sourcepub fn set_patches(
&mut self,
val: HashMap<String, DefinitionPatch>,
) -> &mut Self
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.
impl Schema
Implementation of Schema.
Sourcepub fn new_patch(
patches: &HashMap<String, DefinitionPatch>,
path: &Path,
) -> Result<()>
pub fn new_patch( patches: &HashMap<String, DefinitionPatch>, path: &Path, ) -> Result<()>
This function will save a new patch to the local patches list.
Sourcepub fn remove_patch_for_table(table_name: &str, path: &Path) -> Result<()>
pub fn remove_patch_for_table(table_name: &str, path: &Path) -> Result<()>
This function will remove the local patches for the specified table.
Sourcepub fn remove_patch_for_field(
table_name: &str,
field_name: &str,
path: &Path,
) -> Result<()>
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.
Sourcepub fn patch_value(
&self,
table_name: &str,
column_name: &str,
key: &str,
) -> Option<&String>
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.
Sourcepub fn patches_for_table(&self, table_name: &str) -> Option<&DefinitionPatch>
pub fn patches_for_table(&self, table_name: &str) -> Option<&DefinitionPatch>
This function retrieves all patches that affect a specific table.
Sourcepub fn add_patch_to_patch_set(
patch_set: &mut HashMap<String, DefinitionPatch>,
patches: &HashMap<String, DefinitionPatch>,
)
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.
Sourcepub fn add_definition(&mut self, table_name: &str, definition: &Definition)
pub fn add_definition(&mut self, table_name: &str, definition: &Definition)
This function adds a definition for a table into the currently loaded schema.
Sourcepub fn remove_definition(&mut self, table_name: &str, version: i32)
pub fn remove_definition(&mut self, table_name: &str, version: i32)
This function removes a definition for a table from the currently loaded schema.
Sourcepub fn definitions_by_table_name_cloned(
&self,
table_name: &str,
) -> Option<Vec<Definition>>
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.
Sourcepub fn definitions_by_table_name(
&self,
table_name: &str,
) -> Option<&Vec<Definition>>
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.
Sourcepub fn definitions_by_table_name_mut(
&mut self,
table_name: &str,
) -> Option<&mut Vec<Definition>>
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.
Sourcepub fn definition_newer(
&self,
table_name: &str,
candidates: &[Definition],
) -> Option<&Definition>
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.
pub fn definition_by_name_and_version( &self, table_name: &str, table_version: i32, ) -> Option<&Definition>
pub fn definition_by_name_and_version_mut( &mut self, table_name: &str, table_version: i32, ) -> Option<&mut Definition>
Sourcepub fn load(path: &Path, local_patches: Option<&Path>) -> Result<Self>
pub fn load(path: &Path, local_patches: Option<&Path>) -> Result<Self>
This function loads a Schema to memory from a provided .ron file.
Sourcepub fn load_json(path: &Path) -> Result<Self>
pub fn load_json(path: &Path) -> Result<Self>
This function loads a Schema to memory from a provided .json file.
Sourcepub fn save(&mut self, path: &Path) -> Result<()>
pub fn save(&mut self, path: &Path) -> Result<()>
This function saves a Schema from memory to a .ron file with the provided path.
Sourcepub fn save_json(&mut self, path: &Path) -> Result<()>
pub fn save_json(&mut self, path: &Path) -> Result<()>
This function saves a Schema from memory to a .json file with the provided path.
Sourcepub fn export_to_json(schema_folder_path: &Path) -> Result<()>
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.
Sourcepub fn update(
schema_path: &Path,
schema_patches_path: &Path,
game_name: &str,
) -> Result<()>
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.
Sourcepub fn referencing_columns_for_table(
&self,
table_name: &str,
definition: &Definition,
) -> HashMap<String, HashMap<String, Vec<String>>>
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)>).
Sourcepub fn tables_and_columns_referencing_our_own(
&self,
table_name: &str,
column_name: &str,
fields: &[Field],
localised_fields: &[Field],
) -> (BTreeMap<String, Vec<String>>, bool)
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.
Sourcepub fn load_patches_from_str(
patch: &str,
) -> Result<HashMap<String, DefinitionPatch>>
pub fn load_patches_from_str( patch: &str, ) -> Result<HashMap<String, DefinitionPatch>>
This function tries to load multiple patches from a str.
Sourcepub fn load_definitions_from_str(
definition: &str,
) -> Result<HashMap<String, Definition>>
pub fn load_definitions_from_str( definition: &str, ) -> Result<HashMap<String, Definition>>
This function tries to load multiple definitions from a str.
Sourcepub fn export_patches_to_str(
patches: &HashMap<String, DefinitionPatch>,
) -> Result<String>
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.
Sourcepub fn export_definitions_to_str(
definitions: &HashMap<String, Definition>,
) -> Result<String>
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<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
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 Schema
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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§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().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.