feat: add state version to State

This commit is contained in:
2025-01-22 23:18:27 +01:00
parent 993ba8d408
commit 2678d2d3dd
3 changed files with 21 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ tracing-subscriber-wasm = "0.1.0"
ron = { version = "0.8" }
rand = { version = "0.8", optional = true }
web-sys = { version = "0.3.76", features = ["File", "FileList"] }
smart-default = "0.7.1"
[dev-dependencies.serde_json]
version = "1"

View File

@@ -43,11 +43,14 @@ pub mod cli {
pub mod state {
//! Server state
const STATE_VERSION: u64 = 1;
use super::persistence::Persistent;
use crate::models;
use crate::models::Wall;
use serde::Deserialize;
use serde::Serialize;
use smart_default::SmartDefault;
use std::collections::BTreeSet;
#[derive(Clone, Debug)]
@@ -55,8 +58,12 @@ pub mod state {
pub persistent: Persistent<PersistentState>,
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[derive(Serialize, Deserialize, Clone, Debug, SmartDefault)]
pub struct PersistentState {
/// State schema version
#[default(STATE_VERSION)]
pub version: u64,
pub wall: Wall,
pub problems: Problems,
}