pub struct SaveHeader {
pub magic: [u8; 4],
pub version: u32,
pub game_version: String,
pub timestamp: u64,
pub player_name: String,
pub play_time_seconds: f64,
pub metadata: HashMap<String, String>,
}Expand description
Metadata stored at the top of a save file.
The header is always present and can be read without loading the full snapshot, which is useful for displaying slot previews in a save/load menu.
Fields§
§magic: [u8; 4]Magic bytes — always SAVE_MAGIC.
version: u32Format version (not the game version).
game_version: StringHuman-readable game version string, e.g. "1.2.3".
timestamp: u64Unix timestamp (seconds) when this save was written.
player_name: StringPlayer name at save time.
play_time_seconds: f64Cumulative play time in seconds.
metadata: HashMap<String, String>Arbitrary key-value metadata (level name, difficulty, etc.).
Implementations§
Source§impl SaveHeader
impl SaveHeader
pub fn new() -> Self
pub fn with_player(self, name: impl Into<String>) -> Self
pub fn with_play_time(self, secs: f64) -> Self
pub fn with_game_version(self, ver: impl Into<String>) -> Self
pub fn set_meta(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn get_meta(&self, key: &str) -> Option<&str>
Trait Implementations§
Source§impl Clone for SaveHeader
impl Clone for SaveHeader
Source§fn clone(&self) -> SaveHeader
fn clone(&self) -> SaveHeader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SaveHeader
impl Debug for SaveHeader
Auto Trait Implementations§
impl Freeze for SaveHeader
impl RefUnwindSafe for SaveHeader
impl Send for SaveHeader
impl Sync for SaveHeader
impl Unpin for SaveHeader
impl UnsafeUnpin for SaveHeader
impl UnwindSafe for SaveHeader
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.