embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

Midi2Host

Struct Midi2Host 

Source
pub struct Midi2Host<'d, A: UsbHostAllocator<'d>> { /* private fields */ }
Expand description

Friendly host driver for one USB MIDI 2.0 streaming function.

Implementations§

Source§

impl<'d, A: UsbHostAllocator<'d>> Midi2Host<'d, A>

Source

pub fn new( alloc: &A, info: MidiInfo, enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>

Allocate UMP pipes for a MIDI 2.0 function; call MidiInfo::activate first.

Source

pub fn with_topology(self, topology: Midi2Topology) -> Self

Attach the topology from MidiInfo::activate; its masks become the halves’ groups.

Source

pub async fn connect<P>( alloc: &A, control_pipe: &mut P, config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
where P: UsbPipe<Control, InOut>,

Discover, activate and open the first MIDI 2.0 function, with its topology.

control_pipe stays allocated, so a bidirectional function needs three pipes at once; a constrained host can call MidiInfo::activate, drop its control pipe, then Midi2Host::new.

Source

pub fn info(&self) -> &MidiInfo

The function this host was opened from.

Source

pub fn topology(&self) -> &Midi2Topology

The function’s topology; empty unless attached with with_topology.

Source

pub fn interface_number(&self) -> u8

Returns the interface number of this MIDI 2.0 streaming interface.

Source

pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, MidiError>

Receive one transfer of raw UMP bytes into buf.

Source

pub async fn read_ump<'a>( &mut self, buf: &'a mut [u8], ) -> Result<UmpReader<'a>, MidiError>

Source

pub async fn write(&mut self, data: &[u8]) -> Result<(), MidiError>

Source

pub async fn write_packet( &mut self, packet: &UmpPacket, ) -> Result<(), MidiError>

Send a single Universal MIDI Packet.

Source

pub fn split( self, ) -> (Option<Midi2Sender<'d, A>>, Option<Midi2Receiver<'d, A>>, MidiInfo)

Split into independently owned sender and receiver halves, plus the discovery info.

Trait Implementations§

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for Midi2Host<'d, A>

Source§

const NAME: &'static str = "MIDI 2.0"

Human-readable class name, used for logging.
Source§

type Info = MidiInfo

Cheap, owned description of the interface(s) and endpoints to use. Read more
Source§

fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<MidiInfo>

Find the class in an enumerated device. Returns None when the class is not present. This must not allocate pipes or issue control requests. Read more
Source§

async fn open( alloc: &A, _cfg: &[u8], info: MidiInfo, enum_info: &EnumerationInfo, ) -> Result<Self, ClassError>

Allocate pipes and perform any class-specific setup.
Source§

fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool

Convenience wrapper around probe.

Auto Trait Implementations§

§

impl<'d, A> Forget for Midi2Host<'d, A>

§

impl<'d, A> Freeze for Midi2Host<'d, A>

§

impl<'d, A> Move for Midi2Host<'d, A>

§

impl<'d, A> RefUnwindSafe for Midi2Host<'d, A>

§

impl<'d, A> Send for Midi2Host<'d, A>
where Option<Midi2Sender<'d, A>>: Send, Option<Midi2Receiver<'d, A>>: Send,

§

impl<'d, A> Sync for Midi2Host<'d, A>
where Option<Midi2Sender<'d, A>>: Sync, Option<Midi2Receiver<'d, A>>: Sync,

§

impl<'d, A> Unpin for Midi2Host<'d, A>
where Option<Midi2Sender<'d, A>>: Unpin, Option<Midi2Receiver<'d, A>>: Unpin,

§

impl<'d, A> UnsafeUnpin for Midi2Host<'d, A>

§

impl<'d, A> UnwindSafe for Midi2Host<'d, A>

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> 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.