launchkey_sdk/midi/
to_hex.rs1use wmidi::U7;
2
3pub trait ToHexString {
5 fn to_hex_string(&self) -> String;
7}
8
9impl ToHexString for &[U7] {
10 fn to_hex_string(&self) -> String {
11 self.iter()
12 .map(|byte| format!("{:02X}", u8::from(*byte))) .collect::<Vec<String>>()
14 .join(" ")
15 }
16}
17
18impl ToHexString for &[u8] {
19 fn to_hex_string(&self) -> String {
20 self.iter()
21 .map(|byte| format!("{:02X}", byte))
22 .collect::<Vec<_>>()
23 .join(" ")
24 }
25}
26
27impl ToHexString for Vec<u8> {
28 fn to_hex_string(&self) -> String {
29 self.as_slice().to_hex_string()
30 }
31}