pub struct DltId { /* private fields */ }Expand description
A DLT identifier (Application ID or Context ID)
DLT IDs are 1-4 ASCII bytes. Create with DltId::new(b"APP")?.
Shorter IDs are internally padded with nulls
Implementations§
Source§impl DltId
impl DltId
Sourcepub fn new(bytes: &[u8]) -> Result<DltId, DltError>
pub fn new(bytes: &[u8]) -> Result<DltId, DltError>
Create a new DLT ID from a byte slice of 1 to 4 bytes
The ID will be validated as ASCII. IDs shorter than 4 bytes are right-padded with null bytes internally.
§Errors
Returns DltError::InvalidInput if the byte slice is empty, longer than 4 bytes,
or contains non-ASCII characters.
§Examples
let id = DltId::new(b"APP")?;
assert_eq!(id.as_str()?, "APP");
// Too long
assert!(DltId::new(b"TOOLONG").is_err());
// Empty
assert!(DltId::new(b"").is_err());Trait Implementations§
Source§impl TryFrom<&str> for DltId
Convert a string slice to a DLT ID, will yield an error if the string is too long or empty
impl TryFrom<&str> for DltId
Convert a string slice to a DLT ID, will yield an error if the string is too long or empty
impl Copy for DltId
impl Eq for DltId
impl StructuralPartialEq for DltId
Auto Trait Implementations§
impl Freeze for DltId
impl RefUnwindSafe for DltId
impl Send for DltId
impl Sync for DltId
impl Unpin for DltId
impl UnwindSafe for DltId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.