Skip to main content

EventList

Struct EventList 

Source
pub struct EventList { /* private fields */ }
Expand description

Ordered list of events within a process block.

events is the per-block event ring; sysex_pool is the variable-byte arena that EventBody::SysEx entries index into. Both are pre-allocated by EventList::with_capacity and reset (length only - backing memory preserved) by Self::clear, so steady-state operation is allocation-free.

Implementations§

Source§

impl EventList

Source

pub fn with_capacity(capacity: usize) -> Self

Construct an EventList with backing capacity already reserved.

Format wrappers build their per-instance event lists at construction time and reuse them across blocks via clear(). Without this, the first push after EventList::default() hits the global allocator on the audio thread; pre-allocating with the max event count an audio block is likely to carry keeps the first block alloc-free.

The SysEx byte pool is sized to SYSEX_POOL_PREALLOC regardless of capacity - capacity controls the event ring only.

Source

pub fn push(&mut self, event: Event)

Append an event. Note: sample_offset is not bounds-checked against any block size - callers that build event lists per block must validate sample_offset < num_samples themselves (the audio thread can’t recover from an out-of-range offset, so we treat that as a contract violation rather than panicking).

Source

pub fn push_sysex( &mut self, sample_offset: u32, data: &[u8], ) -> Result<(), PushError>

Append a SysEx event whose payload is copied into the pool. data is the inner SysEx bytes without the leading 0xF0 / trailing 0xF7 - wrappers strip those at the boundary.

Returns PushError::PoolFull when the pool can’t hold data.len() more bytes; the event is not appended and the pool is left unchanged. SysEx messages are atomic by spec, so the caller’s choices are drop-and-flag (via a meter) or fail the host call. Splitting / truncating produces a corrupt message and is never the right answer.

§Errors

PushError::PoolFull when the pool is at capacity.

Source

pub fn sysex_bytes(&self, body: &EventBody) -> &[u8]

Resolve a EventBody::SysEx entry to its payload bytes. Returns an empty slice for any other variant - the slice is indexed against the internal byte pool, so a non-SysEx body has nothing to point at.

Source

pub fn clear(&mut self)

Source

pub fn sort(&mut self)

Stable sort by sample_offset. Stability matters: events with identical sample offsets stay in the order they were pushed, which is what plugins assume when they iterate (e.g. “MIDI on this sample then a CC on the same sample” stays in that order). Don’t replace with sort_unstable_by_key - the stability guarantee is load-bearing.

Sorting reorders Event entries only; SysEx pool offsets stay valid because the pool’s bytes aren’t moved.

Source

pub fn iter(&self) -> impl Iterator<Item = &Event>

Source

pub fn get(&self, index: usize) -> Option<&Event>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn sysex_pool_used(&self) -> usize

Current SysEx pool usage in bytes. Mainly useful in tests and for plug-in code that wants to surface “headroom remaining” in an editor.

Source

pub fn sysex_pool_capacity(&self) -> usize

Total SysEx pool capacity in bytes. Stable for the life of the EventList (no audio-thread reallocation).

Trait Implementations§

Source§

impl Clone for EventList

Source§

fn clone(&self) -> EventList

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EventList

Source§

fn default() -> EventList

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.