embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

MidiPacket

Struct MidiPacket 

Source
pub struct MidiPacket { /* private fields */ }
Expand description

Packet containing the encoded event.

Implementations§

Source§

impl MidiPacket

Source

pub const fn new(bytes: [u8; 4]) -> Self

Creates a new packet from bytes.

Source

pub const fn cable_number(&self) -> u8

Returns the cable number.

Source

pub const fn cin(&self) -> u8

Returns the Code Index Number from the packet header.

Source

pub fn event(&self) -> &[u8]

Returns the event bytes, or an empty slice when the packet uses a reserved CIN.

Source

pub const fn event_len(&self) -> usize

Returns the event length, 0 when the packet uses a reserved CIN.

Source

pub fn decode(&self) -> (u8, &[u8])

Returns a tuple of (cable_no, event).

Source

pub const fn as_bytes(&self) -> &[u8; 4]

Returns a reference to the packet bytes.

Source

pub const fn to_bytes(&self) -> [u8; 4]

Returns the packet bytes as owned array.

Source

pub fn try_encode( cable_number: u8, event: &[u8], ) -> Result<(Self, usize), MidiPacketError>

Tries to create a packet from an event with relaxed length checking. The event slice can be longer than expected, additional bytes are ignored. The expected (and used) event length is returned in the result tuple as second member.

Source

pub fn try_encode_exact( cable_number: u8, event: &[u8], ) -> Result<Self, MidiPacketError>

Tries to create a packet from an event with length checking. Returns an error if the event length does not match the expected length.

Source

pub fn is_sysex(&self) -> bool

Checks if the event is part of a SysEx message.

Source

pub fn is_sysex_start(&self) -> bool

Checks if the event is the start of a SysEx message.

Source

pub fn is_sysex_end(&self) -> bool

Checks if the event is the end of a SysEx message.

Trait Implementations§

Source§

impl Clone for MidiPacket

Source§

fn clone(&self) -> MidiPacket

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 Debug for MidiPacket

Source§

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

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

impl Eq for MidiPacket

Source§

impl Format for MidiPacket
where [u8; 4]: Format,

Source§

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

Writes the defmt representation of self to fmt.
Source§

impl From<[u8; 4]> for MidiPacket

Source§

fn from(bytes: [u8; 4]) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MidiPacket

Source§

fn eq(&self, other: &MidiPacket) -> 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 MidiPacket

Source§

impl TryFrom<&[u8]> for MidiPacket

Source§

type Error = MidiPacketError

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.

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, <T as TryFrom<U>>::Error>

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.