pub trait IntoBytes<T> {
// Required method
fn into_bytes(self) -> T;
}
Expand description
Convert a Ump backed message into a Bytes backed message.
Note that in most cases this is a “lossy” conversion. Some
fields in a Ump message are not represented in a Bytes
message like group
, for example.
use midi2::{IntoBytes, Data, channel_voice1::NoteOn};
let ump_message = NoteOn::try_from(&[0x279E_753D_u32][..]).expect("Valid data");
let bytes_message: NoteOn<[u8; 3]> = ump_message.into_bytes();
assert_eq!(bytes_message.data(), &[0x9E, 0x75, 0x3D]);
This is the reciprocal trait to FromUmp. Any implementor of FromUmp automatically implements IntoBytes, similar to the core::convert::Into trait.