pub struct Message<T> {
pub position: usize,
pub data: T,
}
Expand description
Message wrapper that holds buffer positional data and a generic type. This is useful if you want to send a message to another source that something occured at a specific moment, for example: a midi message was triggered at buffer position 42
Fields§
§position: usize
Buffer position the event occured
data: T
Generic data specified by the application
Implementations§
source§impl<T> Message<T>
impl<T> Message<T>
sourcepub fn new(position: usize, data: T) -> Self
pub fn new(position: usize, data: T) -> Self
instantiate new Message<T>
use screech::Message;
#[derive(Debug, PartialEq)]
enum MessageType {
Midi(u8, u8, u8),
Foo,
}
let message = Message::new(42, MessageType::Midi(146, 69, 128));
assert_eq!(message.position, 42);
assert_eq!(message.data, MessageType::Midi(146, 69, 128));