Trait rsynth::meta::Port[][src]

pub trait Port<T> {
    type PortData;
    fn in_ports(&self) -> &[Self::PortData];
fn out_ports(&self) -> &[Self::PortData]; }

Define meta-data for input ports and output ports.

The type parameter T is a dummy type parameter so that meta-data for different types of ports can be defined. Typical values for T are MidiPort and AudioPort.

Example

use rsynth::meta::{Port, MidiPort, AudioPort};
struct MyMetaData {
    audio_input_port_names: Vec<String>,
    audio_output_port_names: Vec<String>,
    midi_input_port_names: Vec<String>,
    midi_output_port_names: Vec<String>,
}

impl Port<AudioPort> for MyMetaData {
    type PortData = String;
    fn in_ports(&self) -> &[Self::PortData] {
        self.audio_input_port_names.as_slice()
    }
    fn out_ports(&self) -> &[Self::PortData] {
        self.audio_output_port_names.as_slice()
    }
}

impl Port<MidiPort> for MyMetaData {
    type PortData = String;
    fn in_ports(&self) -> &[Self::PortData] {
        self.audio_input_port_names.as_slice()
    }
    fn out_ports(&self) -> &[Self::PortData] {
        self.audio_output_port_names.as_slice()
    }
}

Note

For most use cases, you can use the pre-defined MetaData struct, which already implements Port<MidiPort> and Port<AudioPort>.

Associated Types

type PortData[src]

Loading content...

Required methods

fn in_ports(&self) -> &[Self::PortData][src]

fn out_ports(&self) -> &[Self::PortData][src]

Loading content...

Implementors

impl<G, AP, MP> Port<AudioPort> for MetaData<G, AP, MP>[src]

type PortData = AP

impl<G, AP, MP> Port<MidiPort> for MetaData<G, AP, MP>[src]

type PortData = MP

Loading content...