Add some conveniences for migration

This commit is contained in:
Adam Gausmann 2022-10-28 22:04:30 -05:00
parent 070276a2f5
commit 6cc08354b5

View file

@ -10,6 +10,8 @@ use std::io::{Read, Write};
use crate::error::Error; use crate::error::Error;
use crate::io::read_magic; use crate::io::read_magic;
pub use v6 as latest;
#[derive(Debug)] #[derive(Debug)]
pub enum BlotterFile { pub enum BlotterFile {
V5(v5::BlotterFile), V5(v5::BlotterFile),
@ -33,4 +35,12 @@ impl BlotterFile {
Self::V6(file) => file.write(writer), Self::V6(file) => file.write(writer),
} }
} }
/// Convert the file into the latest version.
pub fn migrate(self) -> latest::BlotterFile {
match self {
Self::V5(file) => Self::V6(file.into()).migrate(),
Self::V6(file) => file,
}
}
} }