Skip to main content

AssetVariationDb

Struct AssetVariationDb 

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

An asset variation database.

Implementations§

Source§

impl AssetVariationDb

Source

pub fn to_xml(&self) -> String

Returns the database in the XML form of the packs: UTF-8, CRLF line ends, tab indentation and single-quoted attributes.

Source

pub fn from_xml(xml: &str) -> Result<Self>

Reads a database from the XML form of the packs. Whitespace between elements doesn’t matter.

§Errors

Returns RLibError::DecodingAssetVariationDbXml if the XML is malformed, or doesn’t have the structure of the database.

Source

pub fn from_environment_map(xml: &str) -> Result<Self>

Builds a database from its source in the Assembly Kit, raw_data/warscape_asset_variation_db/environment_map.xml.

Each environment_file lists the values it allows per category, comma-separated, and an empty or missing list allows every value. The database gets the single entry environment. The categories go in a fixed order, with their values sorted: the bit order the game’s tools use isn’t known, but it doesn’t change what matches.

§Errors

Returns RLibError::DecodingAssetVariationDbXml if the XML is malformed, has no environment_file, or more values than bits.

Source§

impl AssetVariationDb

Source

pub fn serialise_version(&self) -> &u16

Version of the format.

Source

pub fn categories(&self) -> &Vec<VariationCategory>

Categories of the conditions of a battle, with their values.

Source

pub fn entries(&self) -> &Vec<VariationEntry>

Lists of variations, by key.

Source§

impl AssetVariationDb

Source

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

Version of the format.

Source

pub fn categories_mut(&mut self) -> &mut Vec<VariationCategory>

Categories of the conditions of a battle, with their values.

Source

pub fn entries_mut(&mut self) -> &mut Vec<VariationEntry>

Lists of variations, by key.

Source§

impl AssetVariationDb

Source

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

Version of the format.

Source

pub fn set_categories(&mut self, val: Vec<VariationCategory>) -> &mut Self

Categories of the conditions of a battle, with their values.

Source

pub fn set_entries(&mut self, val: Vec<VariationEntry>) -> &mut Self

Lists of variations, by key.

Source§

impl AssetVariationDb

Source

pub fn value_count(&self) -> usize

Amount of values of all the categories together.

Source

pub fn category(&self, name: &str) -> Option<&VariationCategory>

Returns the category with the provided name, if any.

Source

pub fn entry(&self, key: &str) -> Option<&VariationEntry>

Returns the entry with the provided key, if any.

Source

pub fn bit(&self, category: &str, value: &str) -> u32

Bit of a value of a category, or 0 if the category or the value don’t exist.

Source

pub fn query_mask(&self, query: &VariationQuery) -> u32

Bits of a query.

Source

pub fn matches(&self, key: &str, query: &VariationQuery) -> VariationMatches<'_>

Returns the variations of a key that match a query, as the game finds them.

§Arguments
  • key - Key of the entry, like environment.
  • query - Value chosen for each category.
§Returns

The matches. If nothing matches, they’re the ones of the same query with the map default_map.

Source

pub fn matches_listed_map( &self, key: &str, query: &VariationQuery, ) -> VariationMatches<'_>

Returns the variations of a key that match a query, treating a map the database doesn’t list as unmatched.

The game adds no bit for a map it doesn’t list, so its first query matches every map. Tools that pick from a list of maps want the default_map query instead, which this does.

§Arguments
  • key - Key of the entry, like environment.
  • query - Value chosen for each category.
§Returns

The matches.

Source

pub fn allowed_values(&self, flags: u32) -> Vec<(&str, Vec<&str>)>

Returns, per category, the values allowed by some flags. Flags 0 allow every value.

Source

pub fn flags_for(&self, allowed: &BTreeMap<String, Vec<String>>) -> u32

Returns the flags that allow exactly the provided values of each category. Categories left out allow all their values.

Source

pub fn validate(&self) -> Vec<String>

Checks the database for what makes it wrong for the game.

§Returns

A description of each problem: more values than bits, repeated names or values, no default_map, flags with bits of no value, and variations that can never match.

Source

pub fn add_value(&mut self, category: &str, value: &str) -> Result<()>

Adds a value to a category, moving the bits of the flags of every variation so they keep allowing the same values.

A variation that allowed every value of the category, without being unconstrained, also allows the new one.

§Errors

Returns RLibError::AssetVariationDbEditRefused if the category doesn’t exist, the value is empty or already exists, or every bit of the flags is in use.

Source

pub fn remove_value(&mut self, category: &str, value: &str) -> Result<()>

Removes a value from a category, moving the bits of the flags of every variation so they keep allowing the same values.

§Errors

Returns RLibError::AssetVariationDbEditRefused if the category or the value don’t exist, if the value is the default_map map, or if a variation would allow nothing else, as its flags would become 0, which allows everything.

Source

pub fn rename_value( &mut self, category: &str, from: &str, to: &str, ) -> Result<()>

Renames a value of a category. The flags don’t change.

§Errors

Returns RLibError::AssetVariationDbEditRefused if the category or the value don’t exist, or the new name is empty or already exists.

Trait Implementations§

Source§

impl Clone for AssetVariationDb

Source§

fn clone(&self) -> AssetVariationDb

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AssetVariationDb

Source§

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

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

impl Decodeable for AssetVariationDb

Source§

fn decode<R: ReadBytes>( data: &mut R, _extra_data: &Option<DecodeableExtraData<'_>>, ) -> Result<Self>

Decodes binary data into the implementing type. Read more
Source§

impl Default for AssetVariationDb

Source§

fn default() -> AssetVariationDb

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

impl<'de> Deserialize<'de> for AssetVariationDb

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 Encodeable for AssetVariationDb

Source§

fn encode<W: WriteBytes>( &mut self, buffer: &mut W, _extra_data: &Option<EncodeableExtraData<'_>>, ) -> Result<()>

Encodes the implementing type into binary data. Read more
Source§

impl PartialEq for AssetVariationDb

Source§

fn eq(&self, other: &AssetVariationDb) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AssetVariationDb

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 StructuralPartialEq for AssetVariationDb

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

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.