pub struct U7(/* private fields */);
Expand description
A data byte that holds 7 bits of information.
Implementations§
source§impl U7
impl U7
sourcepub fn new(data: u8) -> Result<U7, Error>
pub fn new(data: u8) -> Result<U7, Error>
Create a new U7
or return an error if it is out of range.
sourcepub unsafe fn from_unchecked(data: u8) -> U7
pub unsafe fn from_unchecked(data: u8) -> U7
sourcepub const fn from_u8_lossy(data: u8) -> U7
pub const fn from_u8_lossy(data: u8) -> U7
Create a U7
from a u8
. Only the 7 least significant bits of note
are kept.
sourcepub fn try_from_bytes(bytes: &[u8]) -> Result<&[U7], Error>
pub fn try_from_bytes(bytes: &[u8]) -> Result<&[U7], Error>
Convert a slice of u8
into a slice of U7
. If any of the data is out of range, then an
error is returned.
sourcepub fn data_to_bytes(data: &[U7]) -> &[u8] ⓘ
pub fn data_to_bytes(data: &[U7]) -> &[u8] ⓘ
Convert a slice of U7
into a slice u8
. Since U7
is a subset of u8
, this is a simple
cast.
sourcepub unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &[U7]
pub unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &[U7]
Convert a slice of u8
to a slice of U7
without bounds checking.
Safety
Behavior is undefined if any byte is > 127.
Trait Implementations§
source§impl From<ControlFunction> for U7
impl From<ControlFunction> for U7
source§fn from(control_function: ControlFunction) -> U7
fn from(control_function: ControlFunction) -> U7
Converts to this type from the input type.
source§impl From<U7> for ControlFunction
impl From<U7> for ControlFunction
source§fn from(data: U7) -> ControlFunction
fn from(data: U7) -> ControlFunction
Converts to this type from the input type.
source§impl Ord for U7
impl Ord for U7
source§impl PartialOrd for U7
impl PartialOrd for U7
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for U7
impl Eq for U7
impl StructuralEq for U7
impl StructuralPartialEq for U7
Auto Trait Implementations§
impl RefUnwindSafe for U7
impl Send for U7
impl Sync for U7
impl Unpin for U7
impl UnwindSafe for U7
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