~starkingdoms/starkingdoms

ref: eac9f535be64110c92c281b2eb829c8be8998c36 starkingdoms/crates/common/src/save/mod.rs -rw-r--r-- 464 bytes
eac9f535 — core feat: add basic save file authentication infrastructure a day ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use serde::{Deserialize, Serialize};

pub mod authentication;
pub mod v1;
pub mod error;

#[derive(Serialize, Deserialize)]
pub enum Savefile {
    V1(v1::Savefile),
}

pub trait SaveContainer {
    type LatestFormat;

    fn as_latest(&self) -> &Self::LatestFormat;
}

impl SaveContainer for Savefile {
    type LatestFormat = v1::Savefile;

    fn as_latest(&self) -> &Self::LatestFormat {
        match self {
            Savefile::V1(s) => s,
        }
    }
}