rootasrole_core/database/
versionning.rs

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
27
28
29
30
31
32
33
34
35
36
37
38
use semver::Version;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

use super::migration::Migration;
use crate::version;
use crate::SettingsFile;

use super::structs::*;

#[derive(Deserialize, Serialize, Debug)]
pub struct Versioning<T: Default + Debug> {
    pub version: Version,
    #[serde(default, flatten)]
    pub data: T,
}

impl<T: Default + Debug> Versioning<T> {
    pub fn new(data: T) -> Self {
        Self {
            version: version::PACKAGE_VERSION.to_owned().parse().unwrap(),
            data,
        }
    }
}

impl<T: Default + Debug> Default for Versioning<T> {
    fn default() -> Self {
        Self {
            version: version::PACKAGE_VERSION.to_owned().parse().unwrap(),
            data: T::default(),
        }
    }
}

pub(crate) const JSON_MIGRATIONS: &[Migration<SConfig>] = &[];

pub(crate) const SETTINGS_MIGRATIONS: &[Migration<SettingsFile>] = &[];