pub struct TSL31Packet<T: AsRef<[u8]>> { /* private fields */ }Expand description
A wrapper around a byte slice reference representing a TSL v3.1 Packet
Implementations§
Source§impl<T> TSL31Packet<T>
impl<T> TSL31Packet<T>
Sourcepub fn new_unchecked(buf: T) -> Self
pub fn new_unchecked(buf: T) -> Self
Summon a packet from the given bytes without checking it.
Sourcepub fn new_checked(buf: T) -> Result<Self, Error>
pub fn new_checked(buf: T) -> Result<Self, Error>
Validate the the given bytes are a packet and return it, or an error
Sourcepub fn display_data(&self) -> &str
pub fn display_data(&self) -> &str
Return the display data as a string, with trailing space/null bytes removed
Sourcepub fn brightness(&self) -> Brightness
pub fn brightness(&self) -> Brightness
Tally brightness
Source§impl<T> TSL31Packet<T>
impl<T> TSL31Packet<T>
Sourcepub fn set_address(&mut self, addr: u8) -> Result<(), ()>
pub fn set_address(&mut self, addr: u8) -> Result<(), ()>
Set the address. Return Err(()) if the addr is out of range
pub fn set_brightness(&mut self, brightness: Brightness)
Sourcepub fn set_display_data<'a, S>(&mut self, s: S)
pub fn set_display_data<'a, S>(&mut self, s: S)
Set the display data. Panics if length > 16 or string does not contain printable ascii
Trait Implementations§
Source§impl<T> Display for TSL31Packet<T>
impl<T> Display for TSL31Packet<T>
impl<T: Eq + AsRef<[u8]>> Eq for TSL31Packet<T>
impl<T: AsRef<[u8]>> StructuralPartialEq for TSL31Packet<T>
Auto Trait Implementations§
impl<T> Freeze for TSL31Packet<T>where
T: Freeze,
impl<T> RefUnwindSafe for TSL31Packet<T>where
T: RefUnwindSafe,
impl<T> Send for TSL31Packet<T>where
T: Send,
impl<T> Sync for TSL31Packet<T>where
T: Sync,
impl<T> Unpin for TSL31Packet<T>where
T: Unpin,
impl<T> UnwindSafe for TSL31Packet<T>where
T: UnwindSafe,
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