blob: 9959502122afda9a7bdbf4241dad503e19d021f4 (
plain)
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
39
40
41
42
|
use super::Result;
use mullvad_types::{relay_constraints::Constraint, settings::SettingsVersion};
// ======================================================
// Section for vendoring types and values that
// this settings version depend on. See `mod.rs`.
// ...
// ======================================================
/// TODO: Write in this documentation how the settings format changed, what the migration does.
pub fn migrate(settings: &mut serde_json::Value) -> Result<()> {
if !version_matches(settings) {
return Ok(());
}
// TODO
log::info!("Migrating settings format to V${CURRENT_VERSION+1}");
// TODO: Insert migration code here
// TODO
settings["settings_version"] = serde_json::json!(SettingsVersion::V${CURRENT_VERSION + 1});
Ok(())
}
fn version_matches(settings: &serde_json::Value) -> bool {
settings
.get("settings_version")
// TODO
.map(|version| version == SettingsVersion::V${CURRENT_VERSION} as u64)
.unwrap_or(false)
}
#[cfg(test)]
mod test {
use super::{migrate, version_matches};
// TODO: Implement tests. Look at other migration modules for inspiration.
}
|