sectorsync_core/
snapshot.rs1use crate::entity::EntityRecord;
4use crate::ids::{InstanceId, OwnerEpoch, StationId, Tick};
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub struct SnapshotVersion {
9 pub runtime_version: u32,
11 pub schema_version: u32,
13 pub ruleset_version: u32,
15 pub module_version: u32,
17}
18
19impl Default for SnapshotVersion {
20 fn default() -> Self {
21 Self {
22 runtime_version: 1,
23 schema_version: 1,
24 ruleset_version: 1,
25 module_version: 1,
26 }
27 }
28}
29
30#[derive(Clone, Debug, Default, PartialEq, Eq)]
32pub struct SnapshotMeta {
33 pub instance_id: InstanceId,
35 pub station_id: StationId,
37 pub tick: Tick,
39 pub entity_count: usize,
41 pub owner_epoch: OwnerEpoch,
43 pub version: SnapshotVersion,
45}
46
47#[derive(Clone, Debug, Default, PartialEq)]
49pub struct StationSnapshot {
50 pub meta: SnapshotMeta,
52 pub entities: Vec<EntityRecord>,
54}
55
56pub trait RuntimeUpgradeHook {
58 fn pre_upgrade(&mut self, _meta: &SnapshotMeta) {}
60
61 fn migrate_state(&mut self, snapshot: StationSnapshot) -> StationSnapshot {
63 snapshot
64 }
65
66 fn post_upgrade(&mut self, _meta: &SnapshotMeta) {}
68}