embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

MidiInfo

Struct MidiInfo 

Source
pub struct MidiInfo {
    pub version: MidiVersion,
    /* private fields */
}
Expand description

The USB MIDI function of a device, as plain Copy data: version, alternate setting and endpoints.

Use discover, activate, then MidiHost::from_info or Midi2Host::new. If activate fails with MidiError::is_midi2_failure, the device is back on alternate setting 0: open midi1_from_config as MIDI 1.0.

Fields§

§version: MidiVersion

Version of the function.

Implementations§

Source§

impl MidiInfo

Source

pub fn discover( config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>

Discover the function to use, preferring MIDI 2.0; parses descriptors only.

Source

pub fn midi1_from_config( config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>

Discover the MIDI 1.0 function: one interface on alternate setting 0, one bulk endpoint per direction.

Source

pub fn midi2_from_config( config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>

Discover the first MIDI 2.0 function: an alternate setting reporting bcdMSC >= 0x0200, at most one endpoint per direction.

Endpoints may be bulk or interrupt (USB MIDI 2.0 §3.3.2, §5.3). Appendix B.8 is an interrupt IN endpoint beside a bulk OUT endpoint.

Source

pub async fn fetch_group_terminal_blocks<P>( &self, control_pipe: &mut P, buffer: &mut [u8], ) -> Result<Midi2Topology, MidiError>
where P: UsbPipe<Control, InOut>,

Fetch this MIDI 2.0 function’s Group Terminal Blocks and the groups each endpoint carries.

buffer needs GR_TRM_BLOCK_HEADER_LEN + MAX_GTBS * GR_TRM_BLOCK_LEN bytes to always fit. Fails with MidiError::UnsupportedTopology for a MIDI 1.0 function.

Source

pub async fn activate<P>( &self, control_pipe: &mut P, ) -> Result<Midi2Topology, MidiError>
where P: UsbPipe<Control, InOut>,

Select a MIDI 2.0 function’s alternate setting and read its topology, before opening pipes.

On failure the device is put back on alternate setting 0. A MIDI 1.0 function needs nothing: this sends no request and returns an empty topology.

Source

pub async fn deactivate<P>(&self, control_pipe: &mut P) -> Result<(), MidiError>
where P: UsbPipe<Control, InOut>,

Put a MIDI 2.0 function back on alternate setting 0 before reopening it as MIDI 1.0; no request for MIDI 1.0.

Source

pub fn interface_number(&self) -> u8

Standard interface number of this function.

Source

pub fn alternate_setting(&self) -> u8

Alternate setting that carries this function’s protocol.

Source

pub fn input_endpoint(&self) -> Option<&MidiEndpoint>

Device-to-host (IN) bulk endpoint, if the function has one.

Source

pub fn output_endpoint(&self) -> Option<&MidiEndpoint>

Host-to-device (OUT) bulk endpoint, if the function has one.

Trait Implementations§

Source§

impl Clone for MidiInfo

Source§

fn clone(&self) -> Self

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 Copy for MidiInfo

Source§

impl Debug for MidiInfo

Source§

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

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

impl Eq for MidiInfo

Source§

impl Format for MidiInfo

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl PartialEq for MidiInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MidiInfo

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.