pub enum SingleNoteTuningChangeError {
    TuningChangeListTooLong,
    DeviceIdOutOfRange,
    TuningProgramOutOfRange,
    TuningBankNumberOutOfRange,
}
Expand description

Creating a SingleNoteTuningChangeMessage failed.

Variants

TuningChangeListTooLong

The tuning change list has more than 128 elements.

Example

let create_tuning_message_with_num_changes = |num_changes| {
    let tuning_changes = (0..num_changes).map(|midi_number| {
        SingleNoteTuningChange {
            key: PianoKey::from_midi_number(midi_number),
            target_pitch: Note::from_midi_number(midi_number).pitch(),
        }
    });

    SingleNoteTuningChangeMessage::from_tuning_changes(
        &Default::default(),
        tuning_changes,
    )
};

assert!(matches!(
    create_tuning_message_with_num_changes(128),
    Ok(_)
));
assert!(matches!(
    create_tuning_message_with_num_changes(129),
    Err(SingleNoteTuningChangeError::TuningChangeListTooLong)
));

DeviceIdOutOfRange

The device ID is greater than 127.

Example

let create_tuning_message_for_device_id = |device_id| {
    let options = SingleNoteTuningChangeOptions {
        device_id,
        ..Default::default()
    };

    SingleNoteTuningChangeMessage::from_tuning_changes(&options, iter::empty())
};

assert!(matches!(
    create_tuning_message_for_device_id(127),
    Ok(_)
));
assert!(matches!(
    create_tuning_message_for_device_id(128),
    Err(SingleNoteTuningChangeError::DeviceIdOutOfRange)
));

TuningProgramOutOfRange

The tuning program number is greater than 127.

Example

let create_tuning_message_for_program = |tuning_program| {
    let options = SingleNoteTuningChangeOptions {
        tuning_program,
        ..Default::default()
    };

    SingleNoteTuningChangeMessage::from_tuning_changes(&options, iter::empty())
};

assert!(matches!(
    create_tuning_message_for_program(127),
    Ok(_)
));
assert!(matches!(
    create_tuning_message_for_program(128),
    Err(SingleNoteTuningChangeError::TuningProgramOutOfRange)
));

TuningBankNumberOutOfRange

The tuning bank number is greater than 127.

Example

let create_tuning_message_with_bank_select = |tuning_bank| {
    let options = SingleNoteTuningChangeOptions {
        with_bank_select: Some(tuning_bank),
        ..Default::default()
    };

    SingleNoteTuningChangeMessage::from_tuning_changes(&options, iter::empty())
};

assert!(matches!(
    create_tuning_message_with_bank_select(127),
    Ok(_)
));
assert!(matches!(
    create_tuning_message_with_bank_select(128),
    Err(SingleNoteTuningChangeError::TuningBankNumberOutOfRange)
));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.