Struct coremidi::EventBuffer[][src]

pub struct EventBuffer { /* fields omitted */ }

Implementations

Create an empty EventBuffer for a given Protocol without allocating.

Create an empty EventBuffer of a given capacity for a given Protocol.

Get underlying buffer capacity in bytes

Add a new packet containing the provided timestamp and data. It consumes the instance and returns it modified with the new packet.

See EventBuffer::push for further details.

Example:

use coremidi::{Protocol, Timestamp, EventBuffer};

let buffer = EventBuffer::new(Protocol::Midi20)
    .with_packet(0, &[0x40903c00, 0xffff0000]); // Note On for Middle C

assert_eq!(buffer.len(), 1);
assert_eq!(
    buffer.iter()
        .map(|packet| (packet.timestamp(), packet.data().to_vec()))
        .collect::<Vec<(Timestamp, Vec<u32>)>>(),
    vec![(0, vec![0x40903c00, 0xffff0000])],
)

Add a new event containing the provided timestamp and data.

According to the official documentation for CoreMIDI, the timestamp represents the time at which the events are to be played, where zero means “now”. The timestamp applies to the first MIDI word in the packet.

An event must not have a timestamp that is smaller than that of a previous event in the same EventBuffer

Example:

use coremidi::{EventBuffer, Protocol, Timestamp};

let mut buffer = EventBuffer::new(Protocol::Midi20);
buffer.push(0, &[0x40903c00, 0xffff0000]); // Note On for Middle C

assert_eq!(buffer.len(), 1);
assert_eq!(
    buffer.iter()
        .map(|packet| (packet.timestamp(), packet.data().to_vec()))
        .collect::<Vec<(Timestamp, Vec<u32>)>>(),
    vec![(0, vec![0x40903c00, 0xffff0000])],
)

Clears the buffer, removing all packets. Note that this method has no effect on the allocated capacity of the buffer.

Methods from Deref<Target = EventList>

Check if the packet list is empty.

Get the number of packets in the list.

Get an iterator for the packets in the list.

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

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

Performs the conversion.

Performs the conversion.

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.