~starkingdoms/starkingdoms

ref: eabc84c8e290163d25ea21f153ae811bf09fc23a starkingdoms/crates/common/src/save/mod.rs -rw-r--r-- 464 bytes
eabc84c8 — core feat: add basic save file authentication infrastructure 12 hours 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,
        }
    }
}