SaveFile

Struct SaveFile 

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

Represents a loaded save file with query/modify capabilities

Implementations§

Source§

impl SaveFile

Source

pub fn from_yaml(yaml_data: &[u8]) -> Result<Self, SaveError>

Parse a save file from decrypted YAML data

Source

pub fn to_yaml(&self) -> Result<Vec<u8>, SaveError>

Serialize the save file back to YAML

Source

pub fn get(&self, path: &str) -> Result<&Value, SaveError>

Query a value at a YAML path (e.g. “state.currencies.cash” or “state.experience[0].level”)

Source

pub fn set(&mut self, path: &str, value: Value) -> Result<(), SaveError>

Set a value at a YAML path

Source

pub fn parse_value(value_str: &str) -> Value

Parse a string value into the appropriate YAML type (number, bool, or string)

Source

pub fn set_raw(&mut self, path: &str, yaml_str: &str) -> Result<(), SaveError>

Set a raw YAML value from a string (for complex/unknown structures)

This parses a YAML string and sets it at the given path. Useful for setting complex nested structures or values we haven’t decoded yet.

§Example
// Set a complex nested structure
save.set_raw("some.unknown.field", r#"
  nested:
    value: 123
    array: [1, 2, 3]
"#).unwrap();
Source

pub fn get_character_name(&self) -> Option<&str>

Get character name

Source

pub fn set_character_name(&mut self, name: &str) -> Result<(), SaveError>

Set character name

Source

pub fn get_character_class(&self) -> Option<&str>

Get character class

Source

pub fn get_difficulty(&self) -> Option<&str>

Get player difficulty

Source

pub fn get_cash(&self) -> Option<u64>

Get cash amount

Source

pub fn set_cash(&mut self, amount: u64) -> Result<(), SaveError>

Set cash amount

Source

pub fn get_eridium(&self) -> Option<u64>

Get eridium amount

Source

pub fn set_eridium(&mut self, amount: u64) -> Result<(), SaveError>

Set eridium amount

Source

pub fn get_character_level(&self) -> Option<(u64, u64)>

Get character level and XP

Source

pub fn set_character_xp(&mut self, xp: u64) -> Result<(), SaveError>

Set character XP (level is calculated from XP)

Source

pub fn get_specialization_level(&self) -> Option<(u64, u64)>

Get specialization level and XP

Source

pub fn set_specialization_xp(&mut self, xp: u64) -> Result<(), SaveError>

Set specialization XP (level is calculated from XP)

Trait Implementations§

Source§

impl Debug for SaveFile

Source§

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

Formats the value using the given formatter. Read more

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

Source§

type Output = T

Should always be Self
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.