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
impl Copy for U7
impl Eq for U7
impl StructuralPartialEq for U7
Auto Trait Implementations§
impl Freeze for U7
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