Skip to main content

SaveStack

Struct SaveStack 

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

The save/restore stack.

Implementations§

Source§

impl SaveStack

Source

pub fn new() -> Self

Create an empty save stack.

Source

pub fn save(&mut self, snapshot: SaveSnapshot) -> (u16, u32)

Push a new save level. Returns (level, save_id).

Source

pub fn add_record(&mut self, record: SaveRecord)

Add a COW record to the current save level.

Source

pub fn restore(&mut self) -> Option<SaveLevel>

Pop the topmost save level, returning its records for restore processing. Returns None if the stack is empty.

Source

pub fn restore_to(&mut self, save_id: u32) -> Option<Vec<SaveLevel>>

Pop all save levels from save_id upward (inclusive), returning them in stack order (target level first, newest level last). Per PLRM, restore can target any valid save — not just the topmost. All newer saves are invalidated and their COW records are also returned so they can be undone.

Source

pub fn current_level(&self) -> u16

Current save level (0 if no save active).

Source

pub fn last_save_id(&self) -> u32

Save ID of the most recent save (0 if no save active). Used for entity creation tracking (invalidrestore).

Source

pub fn is_valid(&self, save_id: u32) -> bool

Check if a save_id is valid (exists and not invalidated).

Source

pub fn depth(&self) -> usize

Number of active save levels.

Source

pub fn levels_ref(&self) -> &[SaveLevel]

Read-only access to the levels (for validation checks).

Source

pub fn invalidate_newer(&mut self, save_id: u32)

Invalidate all save levels newer than the given save_id.

Trait Implementations§

Source§

impl Default for SaveStack

Source§

fn default() -> Self

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> 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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.