pub struct MIDIIO { /* private fields */ }Expand description
MIDI port.
Lock-free MIDI port shape (see LOCKLESS.md Phase 3):
sourcesis published RCU-style by control-side connect/disconnect and read on the RT path byprocess().connectionsis control-side only (routing queries, disconnect, plan compiler); no RT reader exists.buffer/finishedare accessed under the plan’s single-writer invariant: every port buffer has exactly one writer per cycle, all readers run in later plan nodes, the engine’s pre-cycle writes are serialized by cycle start, and its post-cycle reads by cycle completion. That invariant is what makes theunsafeaccessors sound; it is enforced by the render plan’s MIDI edges and checked byRenderPlan::verify().
Implementations§
Source§impl MIDIIO
impl MIDIIO
pub fn new() -> Self
Sourcepub fn connect(from: &Arc<MIDIIO>, to: &Arc<MIDIIO>)
pub fn connect(from: &Arc<MIDIIO>, to: &Arc<MIDIIO>)
Connect producer from to consumer to. Updates both sides so
to.sources contains from and from.connections contains to.
Control-side only; publishes the new sources list RCU-style.
Sourcepub fn disconnect(from: &Arc<MIDIIO>, to: &Arc<MIDIIO>) -> Result<(), String>
pub fn disconnect(from: &Arc<MIDIIO>, to: &Arc<MIDIIO>) -> Result<(), String>
Disconnect producer from from consumer to. Removes from both sides.
Control-side only.
Sourcepub fn add_connection(&self, to: &Arc<MIDIIO>)
pub fn add_connection(&self, to: &Arc<MIDIIO>)
Control-side only: record to in this port’s connections without
touching to.sources (duplicate-safe). Used by folder/child
reparenting, where events flow by direct buffer writes ordered by
plan edges rather than by source merging.
Sourcepub fn connections(&self) -> Vec<Arc<MIDIIO>>
pub fn connections(&self) -> Vec<Arc<MIDIIO>>
Control-side snapshot of the ports this port feeds. Used by routing queries and the plan compiler; never on the RT path.
Sourcepub fn sources(&self) -> Vec<Arc<MIDIIO>>
pub fn sources(&self) -> Vec<Arc<MIDIIO>>
Control-side snapshot of the ports feeding this port.
Sourcepub unsafe fn setup(&self)
pub unsafe fn setup(&self)
Prepare this port for a new processing cycle.
§Safety
The caller must be this port’s sole writer for the coming cycle and no reader may be active (single-writer invariant).
Sourcepub unsafe fn process(&self)
pub unsafe fn process(&self)
Merge events from all connected sources into this port’s buffer. Source buffers are left intact so multiple consumers can read them.
§Safety
The single-writer invariant must hold for this port (sole writer this cycle), and every source’s producer must have completed earlier in the plan (MIDI edge) or belong to a finished cycle.
Sourcepub unsafe fn buffer(&self) -> &[MidiEvent]
pub unsafe fn buffer(&self) -> &[MidiEvent]
Read the port’s event buffer.
§Safety
No writer may be active: the buffer’s producer must have completed (plan ordering or cycle boundary).
Sourcepub unsafe fn buffer_mut(&self) -> MidiBufferMut<'_>
pub unsafe fn buffer_mut(&self) -> MidiBufferMut<'_>
Write the port’s event buffer.
Returns a guard instead of a bare &mut so the signature is not
&self -> &mut T (clippy::mut_from_ref); the guard derefs to
Vec<MidiEvent>, so call sites use it like the old field access.
§Safety
The caller must be this port’s sole writer this cycle and no reader may be active (single-writer invariant).
Sourcepub fn ready(&self) -> bool
pub fn ready(&self) -> bool
Returns true if this port has finished processing this cycle. A port with no sources is considered ready once it has finished producing; a port with sources is ready only when all sources have.
Sourcepub fn mark_finished(&self)
pub fn mark_finished(&self)
Mark this port as finished without processing (used by producers such as track inputs that fill their buffer directly).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MIDIIO
impl !RefUnwindSafe for MIDIIO
impl !UnwindSafe for MIDIIO
impl Send for MIDIIO
impl Unpin for MIDIIO
impl UnsafeUnpin for MIDIIO
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeClone for T
impl<T> MaybeDebug for T
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSync for Twhere
T: Sync,
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().