embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

UmpPacket

Struct UmpPacket 

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

Universal MIDI Packet (UMP).

Contains between 1 and 4 32-bit words.

Implementations§

Source§

impl UmpPacket

Source

pub const fn from_u32(w0: u32) -> Result<Self, UmpError>

Create a single-word (32-bit) UMP packet.

Source

pub const fn from_u32_pair(w0: u32, w1: u32) -> Result<Self, UmpError>

Create a two-word (64-bit) UMP packet.

Source

pub const fn from_u32_triple( w0: u32, w1: u32, w2: u32, ) -> Result<Self, UmpError>

Create a three-word (96-bit) UMP packet.

Source

pub const fn from_u32_quad( w0: u32, w1: u32, w2: u32, w3: u32, ) -> Result<Self, UmpError>

Create a four-word (128-bit) UMP packet.

Source

pub fn from_words(words: &[u32]) -> Result<Self, UmpError>

Create a UMP packet from a slice of words, verifying word length against the message type.

Source

pub fn message_type(&self) -> MessageType

Returns the message type of the packet.

Source

pub fn group(&self) -> Option<u8>

Returns the group index (0..15), or None for Utility and Stream messages, which have none.

Source

pub fn in_groups(&self, mask: u16) -> bool

Whether the packet is accepted by mask (bit n = group n); groupless packets always are.

Source

pub fn status(&self) -> u8

Returns the status byte of the first word (bits 16..23).

Source

pub fn channel(&self) -> Option<u8>

Returns the channel (0..15), or None unless this is a channel voice message.

Source

pub fn words(&self) -> &[u32]

Returns the slice of 32-bit words forming this packet.

Source

pub fn word_count(&self) -> usize

Returns the number of 32-bit words in this packet.

Source

pub fn byte_count(&self) -> usize

Returns the byte length of this packet when serialized.

Source

pub fn try_from_bytes(bytes: &[u8]) -> Result<(Self, usize), UmpError>

Try to decode a UMP packet from bytes (little-endian 32-bit words).

Returns the decoded packet and the number of bytes consumed.

Source

pub fn to_bytes(&self, out: &mut [u8]) -> Result<usize, UmpError>

Serialize the UMP packet to bytes in little-endian byte order.

Returns the number of bytes written.

Trait Implementations§

Source§

impl Clone for UmpPacket

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 UmpPacket

Source§

impl Debug for UmpPacket

Source§

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

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

impl Eq for UmpPacket

Source§

impl Format for UmpPacket
where [u32; 4]: Format,

Source§

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

Writes the defmt representation of self to fmt.
Source§

impl From<Ump32> for UmpPacket

Source§

fn from(packet: Ump32) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for UmpPacket

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 UmpPacket

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.