diff --git a/Cargo.toml b/Cargo.toml index 13afec7..fd586c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ sysex7 = [] sysex8 = [] system-common = [] ump-stream = [] +utility = [] [dependencies] derive_more = { version = "0.99.17", features = ["from"], default-features = false } diff --git a/src/message.rs b/src/message.rs index d76e979..b54f3c2 100644 --- a/src/message.rs +++ b/src/message.rs @@ -24,6 +24,8 @@ pub enum UmpMessage { SystemCommon(crate::system_common::SystemCommon), #[cfg(feature = "ump-stream")] UmpStream(crate::ump_stream::UmpStream), + #[cfg(feature = "utility")] + Utility(crate::utility::Utility), } impl<'a> core::convert::TryFrom<&'a [u32]> for UmpMessage<&'a [u32]> { @@ -67,6 +69,10 @@ impl<'a> core::convert::TryFrom<&'a [u32]> for UmpMessage<&'a [u32]> { crate::ump_stream::UMP_MESSAGE_TYPE => { UmpStream(crate::ump_stream::UmpStream::try_from(buffer)?.into()) } + #[cfg(feature = "utility")] + crate::utility::UMP_MESSAGE_TYPE => { + Utility(crate::utility::Utility::try_from(buffer)?.into()) + } _ => Err(crate::error::Error::InvalidData( "Couldn't interpret ump message type", ))?, @@ -249,4 +255,16 @@ mod tests { panic!(); }; } + + #[cfg(feature = "utility")] + #[test] + fn utility() { + use crate::utility::Utility; + + let buffer = [0x0020_1234, 0x0, 0x0, 0x0]; + let message = UmpMessage::try_from(&buffer[..]); + let Ok(UmpMessage::Utility(Utility::Timestamp(_))) = message else { + panic!(); + }; + } } diff --git a/src/utility/mod.rs b/src/utility/mod.rs index bc35098..fcbd3ee 100644 --- a/src/utility/mod.rs +++ b/src/utility/mod.rs @@ -123,8 +123,7 @@ pub mod delta_clockstamp_tpq { } } -#[allow(dead_code)] -const UMP_MESSAGE_TYPE: u8 = 0x0; +pub(crate) const UMP_MESSAGE_TYPE: u8 = 0x0; struct DataProperty;