refactor: simplify supported version handling
This commit is contained in:
@@ -31,7 +31,7 @@ use ::uuid::Uuid;
|
|||||||
const CURRENT_VERSION: Uuid = Uuid::from_u128(0xe834d789_101b_4634_9823_9de990a9051f);
|
const CURRENT_VERSION: Uuid = Uuid::from_u128(0xe834d789_101b_4634_9823_9de990a9051f);
|
||||||
|
|
||||||
// needs to be sorted!
|
// needs to be sorted!
|
||||||
const SUPPORTED_VERSIONS: [Uuid; 1] = [
|
const SUPPORTED_VERSIONS: &[Uuid] = &[
|
||||||
Uuid::from_u128(0xe834d789_101b_4634_9823_9de990a9051f), // current
|
Uuid::from_u128(0xe834d789_101b_4634_9823_9de990a9051f), // current
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ where
|
|||||||
.context("failed getting local meta")?;
|
.context("failed getting local meta")?;
|
||||||
let local_meta: LocalMeta = match local_meta {
|
let local_meta: LocalMeta = match local_meta {
|
||||||
Some(local_meta) => {
|
Some(local_meta) => {
|
||||||
local_meta.ensure_versions(&SUPPORTED_VERSIONS)?;
|
local_meta.ensure_versions(SUPPORTED_VERSIONS)?;
|
||||||
rmp_serde::from_read_ref(&local_meta)?
|
rmp_serde::from_read_ref(&local_meta)?
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
@@ -433,7 +433,7 @@ where
|
|||||||
.map(|(name, state)| {
|
.map(|(name, state)| {
|
||||||
let key = key.clone();
|
let key = key.clone();
|
||||||
async move {
|
async move {
|
||||||
state.ensure_versions(&SUPPORTED_VERSIONS)?;
|
state.ensure_versions(SUPPORTED_VERSIONS)?;
|
||||||
|
|
||||||
let clear_text = self
|
let clear_text = self
|
||||||
.cryptor
|
.cryptor
|
||||||
@@ -493,7 +493,7 @@ where
|
|||||||
.map(|(actor, version, data)| {
|
.map(|(actor, version, data)| {
|
||||||
let key = key.clone();
|
let key = key.clone();
|
||||||
async move {
|
async move {
|
||||||
data.ensure_versions(&SUPPORTED_VERSIONS)?;
|
data.ensure_versions(SUPPORTED_VERSIONS)?;
|
||||||
let clear_text = self
|
let clear_text = self
|
||||||
.cryptor
|
.cryptor
|
||||||
.decrypt(key.key(), data.as_ref())
|
.decrypt(key.key(), data.as_ref())
|
||||||
@@ -571,7 +571,7 @@ where
|
|||||||
.context("failed loading remote meta while reading remote metas")?
|
.context("failed loading remote meta while reading remote metas")?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, vbox)| {
|
.map(|(name, vbox)| {
|
||||||
vbox.ensure_versions(&SUPPORTED_VERSIONS)?;
|
vbox.ensure_versions(SUPPORTED_VERSIONS)?;
|
||||||
|
|
||||||
let remote_meta: RemoteMeta = rmp_serde::from_read_ref(&vbox)?;
|
let remote_meta: RemoteMeta = rmp_serde::from_read_ref(&vbox)?;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use ::uuid::Uuid;
|
|||||||
|
|
||||||
const CURRENT_DATA_VERSION: Uuid = Uuid::from_u128(0xaadfd5a6_6e19_4b24_a802_4fa27c72f20c);
|
const CURRENT_DATA_VERSION: Uuid = Uuid::from_u128(0xaadfd5a6_6e19_4b24_a802_4fa27c72f20c);
|
||||||
|
|
||||||
const SUPPORTED_DATA_VERSIONS: [Uuid; 1] = [CURRENT_DATA_VERSION];
|
const SUPPORTED_DATA_VERSIONS: &[Uuid] = &[CURRENT_DATA_VERSION];
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user