elemental_shared/
version.rs1use anyhow::Result;
2
3pub trait VersionControlled: Default {
4 fn version(&self) -> usize;
5 fn is_up_to_date(&self, latest_version: usize) -> bool {
6 self.version() >= latest_version
7 }
8}
9pub trait Migrator<V: VersionControlled> {
10 fn migrate(&self, value: V, target_version: usize) -> Result<V>;
11}
12
13pub trait Persistor<V: VersionControlled> {
14 fn save(&self, value: &V) -> impl Future<Output = Result<()>>;
15 fn load(&self) -> impl Future<Output = Result<Option<V>>>
16 where
17 Self: Sized;
18}