pub struct UsbMidiClass<'a, B: UsbBus> { /* private fields */ }Expand description
Packet-level implementation of a USB MIDI device.
Implementations§
Source§impl<B: UsbBus> UsbMidiClass<'_, B>
impl<B: UsbBus> UsbMidiClass<'_, B>
Sourcepub fn new(
alloc: &UsbBusAllocator<B>,
n_in_jacks: u8,
n_out_jacks: u8,
) -> Result<UsbMidiClass<'_, B>, InvalidArguments>
pub fn new( alloc: &UsbBusAllocator<B>, n_in_jacks: u8, n_out_jacks: u8, ) -> Result<UsbMidiClass<'_, B>, InvalidArguments>
Creates a new UsbMidiClass with the provided UsbBus and n_in/out_jacks embedded input/output jacks
(or “cables”, depending on the terminology).
Note that a maximum of 16 in and 16 out jacks is supported.
Sourcepub fn send_bytes(&mut self, buffer: [u8; 4]) -> Result<usize>
pub fn send_bytes(&mut self, buffer: [u8; 4]) -> Result<usize>
Sends bytes from a 4-byte buffer and returns either the transferred size or an error.
Sourcepub fn send_packet(&mut self, usb_midi: UsbMidiEventPacket) -> Result<usize>
pub fn send_packet(&mut self, usb_midi: UsbMidiEventPacket) -> Result<usize>
Sends a UsbMidiEventPacket and returns either the transferred size or an error.
Trait Implementations§
Source§impl<B: UsbBus> UsbClass<B> for UsbMidiClass<'_, B>
impl<B: UsbBus> UsbClass<B> for UsbMidiClass<'_, B>
Source§fn get_configuration_descriptors(
&self,
writer: &mut DescriptorWriter<'_>,
) -> Result<()>
fn get_configuration_descriptors( &self, writer: &mut DescriptorWriter<'_>, ) -> Result<()>
Called when a GET_DESCRIPTOR request is received for a configuration descriptor. When
called, the implementation should write its interface, endpoint and any extra class
descriptors into
writer. The configuration descriptor itself will be written by
UsbDevice and shouldn’t be written by classes. Read moreSource§fn get_bos_descriptors(
&self,
writer: &mut BosWriter<'_, '_>,
) -> Result<(), UsbError>
fn get_bos_descriptors( &self, writer: &mut BosWriter<'_, '_>, ) -> Result<(), UsbError>
Called when a GET_DESCRIPTOR request is received for a BOS descriptor.
When called, the implementation should write its blobs such as capability
descriptors into
writer. The BOS descriptor itself will be written by
UsbDevice and shouldn’t be written by classes.Source§fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str>
fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str>
Gets a class-specific string descriptor. Read more
Source§fn control_out(&mut self, xfer: ControlOut<'_, '_, '_, B>)
fn control_out(&mut self, xfer: ControlOut<'_, '_, '_, B>)
Called when a control request is received with direction HostToDevice. Read more
Source§fn control_in(&mut self, xfer: ControlIn<'_, '_, '_, B>)
fn control_in(&mut self, xfer: ControlIn<'_, '_, '_, B>)
Called when a control request is received with direction DeviceToHost. Read more
Source§fn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
Called when endpoint with address
addr has received a SETUP packet. Implementing this
shouldn’t be necessary in most cases, but is provided for completeness’ sake. Read moreSource§fn endpoint_out(&mut self, addr: EndpointAddress)
fn endpoint_out(&mut self, addr: EndpointAddress)
Called when endpoint with address
addr has received data (OUT packet). Read moreSource§fn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
Called when endpoint with address
addr has completed transmitting data (IN packet). Read moreSource§fn get_alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
fn get_alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8>
Called when the interfaces alternate setting state is requested. Read more
Source§fn set_alt_setting(
&mut self,
interface: InterfaceNumber,
alternative: u8,
) -> bool
fn set_alt_setting( &mut self, interface: InterfaceNumber, alternative: u8, ) -> bool
Called when the interfaces alternate setting state is altered. Read more
Auto Trait Implementations§
impl<'a, B> Freeze for UsbMidiClass<'a, B>
impl<'a, B> RefUnwindSafe for UsbMidiClass<'a, B>
impl<'a, B> Send for UsbMidiClass<'a, B>
impl<'a, B> Sync for UsbMidiClass<'a, B>
impl<'a, B> Unpin for UsbMidiClass<'a, B>
impl<'a, B> UnwindSafe for UsbMidiClass<'a, B>
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
Mutably borrows from an owned value. Read more