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>
impl<'d, A: UsbHostAllocator<'d>> Midi2Host<'d, A>
Sourcepub fn new(
alloc: &A,
info: MidiInfo,
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
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.
Sourcepub fn with_topology(self, topology: Midi2Topology) -> Self
pub fn with_topology(self, topology: Midi2Topology) -> Self
Attach the topology from MidiInfo::activate; its masks become the halves’ groups.
Sourcepub async fn connect<P>(
alloc: &A,
control_pipe: &mut P,
config_desc: &[u8],
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
pub async fn connect<P>( alloc: &A, control_pipe: &mut P, config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
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.
Sourcepub fn topology(&self) -> &Midi2Topology
pub fn topology(&self) -> &Midi2Topology
The function’s topology; empty unless attached with with_topology.
Sourcepub fn interface_number(&self) -> u8
pub fn interface_number(&self) -> u8
Returns the interface number of this MIDI 2.0 streaming interface.
Sourcepub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, MidiError>
pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, MidiError>
Receive one transfer of raw UMP bytes into buf.
Sourcepub async fn read_ump<'a>(
&mut self,
buf: &'a mut [u8],
) -> Result<UmpReader<'a>, MidiError>
pub async fn read_ump<'a>( &mut self, buf: &'a mut [u8], ) -> Result<UmpReader<'a>, MidiError>
Sourcepub async fn write_packet(
&mut self,
packet: &UmpPacket,
) -> Result<(), MidiError>
pub async fn write_packet( &mut self, packet: &UmpPacket, ) -> Result<(), MidiError>
Send a single Universal MIDI Packet.
Sourcepub fn split(
self,
) -> (Option<Midi2Sender<'d, A>>, Option<Midi2Receiver<'d, A>>, MidiInfo)
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>
impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for Midi2Host<'d, A>
Source§type Info = MidiInfo
type Info = MidiInfo
Source§fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<MidiInfo>
fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<MidiInfo>
None when the class is
not present. This must not allocate pipes or issue control requests. Read moreSource§async fn open(
alloc: &A,
_cfg: &[u8],
info: MidiInfo,
enum_info: &EnumerationInfo,
) -> Result<Self, ClassError>
async fn open( alloc: &A, _cfg: &[u8], info: MidiInfo, enum_info: &EnumerationInfo, ) -> Result<Self, ClassError>
Source§fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool
fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool
probe.