ChangeSet

Struct ChangeSet 

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

Represents a set of changes to apply to a save file

This is useful for batching multiple changes together and for tracking modifications in a GUI before applying them.

Implementations§

Source§

impl ChangeSet

Source

pub fn new() -> Self

Create a new empty ChangeSet

Source

pub fn add(&mut self, path: String, value: Value)

Add a change to the set

Source

pub fn add_parsed(&mut self, path: String, value_str: &str)

Add a change with a string value (auto-parsed)

Source

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

Add a raw YAML change from a string (for complex/unknown structures)

Source

pub fn has_change(&self, path: &str) -> bool

Check if a specific path has been modified

Source

pub fn get_change(&self, path: &str) -> Option<&Value>

Get the pending change for a path, if any

Source

pub fn remove(&mut self, path: &str) -> Option<Value>

Remove a change from the set

Source

pub fn clear(&mut self)

Clear all changes

Source

pub fn len(&self) -> usize

Get number of changes

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &Value)>

Get an iterator over all changes

Source

pub fn apply(&self, save: &mut SaveFile) -> Result<(), SaveError>

Apply all changes to a SaveFile

Source

pub fn set_character_name(&mut self, name: &str)

Convenience methods for common operations

Set character name

Source

pub fn set_cash(&mut self, amount: u64)

Set cash amount

Source

pub fn set_eridium(&mut self, amount: u64)

Set eridium amount

Source

pub fn set_character_xp(&mut self, xp: u64)

Set character XP

Source

pub fn set_specialization_xp(&mut self, xp: u64)

Set specialization XP

Source

pub fn add_backpack_item(&mut self, slot: u8, serial: &str, flags: StateFlags)

Add an item to a backpack slot.

§Arguments
  • slot - Backpack slot number (0-22 typically)
  • serial - Item serial string (e.g., “@Ugr$ZCm/…”)
  • flags - State flags for the item
§Example
use bl4::{ChangeSet, StateFlags};

let mut changes = ChangeSet::new();
changes.add_backpack_item(0, "@Ugr$ZCm/...", StateFlags::backpack());
Source

pub fn set_backpack_flags(&mut self, slot: u8, flags: StateFlags)

Set state_flags on an existing backpack item.

Source

pub fn set_favorite(&mut self, slot: u8, value: bool)

Set or clear the favorite flag on a backpack item.

Source

pub fn set_junk(&mut self, slot: u8, value: bool)

Set or clear the junk flag on a backpack item.

Source

pub fn set_label1(&mut self, slot: u8, value: bool)

Set or clear label 1 on a backpack item.

Source

pub fn set_label2(&mut self, slot: u8, value: bool)

Set or clear label 2 on a backpack item.

Source

pub fn set_label3(&mut self, slot: u8, value: bool)

Set or clear label 3 on a backpack item.

Source

pub fn set_label4(&mut self, slot: u8, value: bool)

Set or clear label 4 on a backpack item.

Source

pub fn add_bank_item(&mut self, slot: u16, serial: &str, flags: StateFlags)

Add an item to a bank slot.

Note: Bank items are stored in profile.sav, not character saves.

§Arguments
  • slot - Bank slot number
  • serial - Item serial string
  • flags - State flags for the item
Source

pub fn set_bank_flags(&mut self, slot: u16, flags: StateFlags)

Set state_flags on an existing bank item.

Source

pub fn equip_item(&mut self, slot: u8, serial: &str)

Equip an item to a slot.

This adds the item to equipped_inventory. The item should also exist in the backpack with matching flags.

§Arguments
  • slot - Equipped slot (0-3 weapons, 4 shield, 5 grenade, 6+ gear)
  • serial - Item serial string
Source

pub fn unequip_slot(&mut self, slot: u8)

Clear an equipped slot (unequip item).

Trait Implementations§

Source§

impl Clone for ChangeSet

Source§

fn clone(&self) -> ChangeSet

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 ChangeSet

Source§

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

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

impl Default for ChangeSet

Source§

fn default() -> ChangeSet

Returns the “default value” for a type. 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> 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> Same for T

Source§

type Output = T

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