Skip to content

Commit

Permalink
feat: utility messages are integrated into top level aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Leadbetter committed May 9, 2024
1 parent 6dd5413 commit 25f9a81
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sysex7 = []
sysex8 = []
system-common = []
ump-stream = []
utility = []

[dependencies]
derive_more = { version = "0.99.17", features = ["from"], default-features = false }
Expand Down
18 changes: 18 additions & 0 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub enum UmpMessage<B: crate::buffer::Ump> {
SystemCommon(crate::system_common::SystemCommon<B>),
#[cfg(feature = "ump-stream")]
UmpStream(crate::ump_stream::UmpStream<B>),
#[cfg(feature = "utility")]
Utility(crate::utility::Utility<B>),
}

impl<'a> core::convert::TryFrom<&'a [u32]> for UmpMessage<&'a [u32]> {
Expand Down Expand Up @@ -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",
))?,
Expand Down Expand Up @@ -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!();
};
}
}
3 changes: 1 addition & 2 deletions src/utility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 25f9a81

Please sign in to comment.