[][src]Enum helgoboss_midi::StructuredShortMessage

pub enum StructuredShortMessage {
    NoteOff {
        channel: Channel,
        key_number: KeyNumber,
        velocity: U7,
    },
    NoteOn {
        channel: Channel,
        key_number: KeyNumber,
        velocity: U7,
    },
    PolyphonicKeyPressure {
        channel: Channel,
        key_number: KeyNumber,
        pressure_amount: U7,
    },
    ControlChange {
        channel: Channel,
        controller_number: ControllerNumber,
        control_value: U7,
    },
    ProgramChange {
        channel: Channel,
        program_number: U7,
    },
    ChannelPressure {
        channel: Channel,
        pressure_amount: U7,
    },
    PitchBendChange {
        channel: Channel,
        pitch_bend_value: U14,
    },
    SystemExclusiveStart,
    TimeCodeQuarterFrame(TimeCodeQuarterFrame),
    SongPositionPointer {
        position: U14,
    },
    SongSelect {
        song_number: U7,
    },
    TuneRequest,
    SystemExclusiveEnd,
    TimingClock,
    Start,
    Continue,
    Stop,
    ActiveSensing,
    SystemReset,
    SystemCommonUndefined1,
    SystemCommonUndefined2,
    SystemRealTimeUndefined1,
    SystemRealTimeUndefined2,
}

A short message implemented as an enum where each variant contains exactly the data which is relevant for the particular message type.

This enum is primarily intended for read-only usage via pattern matching. For that reason each variant is a struct-like enum, which is ideal for pattern matching while it is less ideal for reuse (the data contained in the variant can't be passed around in one piece).

The enum's size in memory is currently 4 bytes.

Example

use helgoboss_midi::{
    controller_numbers, Channel, RawShortMessage, ShortMessage, ShortMessageFactory,
    StructuredShortMessage, U7,
};

let msg = RawShortMessage::control_change(
    Channel::new(5),
    controller_numbers::DAMPER_PEDAL_ON_OFF,
    U7::new(100),
);
let structured_msg = msg.to_structured();
match structured_msg {
    StructuredShortMessage::ControlChange {
        channel,
        controller_number,
        control_value,
    } => {
        assert_eq!(channel.get(), 5);
        assert_eq!(controller_number.get(), 64);
        assert_eq!(control_value.get(), 100);
    }
    _ => panic!("wrong type"),
};
assert_eq!(structured_msg.channel(), Some(Channel::new(5)));
assert_eq!(core::mem::size_of_val(&structured_msg), 4);

Variants

NoteOff

Fields of NoteOff

channel: Channelkey_number: KeyNumbervelocity: U7
NoteOn

Fields of NoteOn

channel: Channelkey_number: KeyNumbervelocity: U7
PolyphonicKeyPressure

Fields of PolyphonicKeyPressure

channel: Channelkey_number: KeyNumberpressure_amount: U7
ControlChange

Fields of ControlChange

channel: Channelcontroller_number: ControllerNumbercontrol_value: U7
ProgramChange

Fields of ProgramChange

channel: Channelprogram_number: U7
ChannelPressure

Fields of ChannelPressure

channel: Channelpressure_amount: U7
PitchBendChange

Fields of PitchBendChange

channel: Channelpitch_bend_value: U14
SystemExclusiveStart
TimeCodeQuarterFrame(TimeCodeQuarterFrame)
SongPositionPointer

Fields of SongPositionPointer

position: U14
SongSelect

Fields of SongSelect

song_number: U7
TuneRequest
SystemExclusiveEnd
TimingClock
Start
Continue
Stop
ActiveSensing
SystemReset
SystemCommonUndefined1
SystemCommonUndefined2
SystemRealTimeUndefined1
SystemRealTimeUndefined2

Trait Implementations

impl Clone for StructuredShortMessage[src]

impl Copy for StructuredShortMessage[src]

impl Debug for StructuredShortMessage[src]

impl Eq for StructuredShortMessage[src]

impl Hash for StructuredShortMessage[src]

impl Ord for StructuredShortMessage[src]

impl PartialEq<StructuredShortMessage> for StructuredShortMessage[src]

impl PartialOrd<StructuredShortMessage> for StructuredShortMessage[src]

impl ShortMessage for StructuredShortMessage[src]

impl ShortMessageFactory for StructuredShortMessage[src]

impl StructuralEq for StructuredShortMessage[src]

impl StructuralPartialEq for StructuredShortMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.