From b5ef93a1d8da6f683a58ba3ed8f3cd648706d303 Mon Sep 17 00:00:00 2001 From: Grissess Date: Wed, 15 Sep 2021 20:27:25 -0400 Subject: Remove JACK, begin IV parsing --- src/seq/mod.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/seq/mod.rs') diff --git a/src/seq/mod.rs b/src/seq/mod.rs index 1a4cc95..49802d1 100644 --- a/src/seq/mod.rs +++ b/src/seq/mod.rs @@ -4,6 +4,7 @@ pub mod file; use std::collections::HashMap; use std::{cmp, ops}; +use std::convert::TryFrom; use super::Pitch; @@ -250,11 +251,42 @@ pub struct IVMeta { pub app: Option, } +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum Version { + Ver1_0, + Ver1_1, +} + +impl Default for Version { + fn default() -> Self { + Version::Ver1_1 + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct VersionDecodeError; + +const VER1_0: &[u8] = b"1.0"; +const VER1_1: &[u8] = b"1.1"; +impl<'a> TryFrom<&'a [u8]> for Version { + type Error = VersionDecodeError; + fn try_from(value: &'a [u8]) -> Result { + use Version::*; + match value { + v if v == VER1_0 => Ok(Ver1_0), + v if v == VER1_1 => Ok(Ver1_1), + _ => Err(VersionDecodeError), + } + } +} + #[derive(Default)] pub struct IV { pub default_group: Group, pub groups: HashMap, pub meta: IVMeta, + pub source: Option, + pub version: Version, } impl IV { -- cgit v1.2.3-70-g09d2