pub struct PaddedString<const SIZE: usize> { /* private fields */ }Expand description
Fixed-size, optionally NULL-terminated UTF-8 string read from the observer memory map.
The backing buffer is always SIZE bytes wide. Logical string content runs
from byte 0 up to (but excluding) the first 0x00 byte, or to the end of
the buffer if no NUL byte is present.
PaddedString has alignment 1, so it can safely be borrowed by reference
even when nested inside a #[repr(C, packed)] struct.
Implementations§
Source§impl<const SIZE: usize> PaddedString<SIZE>
impl<const SIZE: usize> PaddedString<SIZE>
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the bytes up to (but excluding) the first NUL byte.
If the buffer contains no NUL byte, all SIZE bytes are returned.
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Lossy UTF-8 view of Self::as_bytes.
Invalid UTF-8 sequences are replaced with U+FFFD.
Trait Implementations§
Source§impl<const SIZE: usize> Clone for PaddedString<SIZE>
impl<const SIZE: usize> Clone for PaddedString<SIZE>
Source§fn clone(&self) -> PaddedString<SIZE>
fn clone(&self) -> PaddedString<SIZE>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const SIZE: usize> Debug for PaddedString<SIZE>
impl<const SIZE: usize> Debug for PaddedString<SIZE>
Source§impl<const SIZE: usize> Display for PaddedString<SIZE>
impl<const SIZE: usize> Display for PaddedString<SIZE>
Source§impl<const SIZE: usize> Hash for PaddedString<SIZE>
impl<const SIZE: usize> Hash for PaddedString<SIZE>
Source§impl<const SIZE: usize> PartialEq for PaddedString<SIZE>
impl<const SIZE: usize> PartialEq for PaddedString<SIZE>
Source§fn eq(&self, other: &PaddedString<SIZE>) -> bool
fn eq(&self, other: &PaddedString<SIZE>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<const SIZE: usize> Copy for PaddedString<SIZE>
impl<const SIZE: usize> Eq for PaddedString<SIZE>
impl<const SIZE: usize> StructuralPartialEq for PaddedString<SIZE>
Auto Trait Implementations§
impl<const SIZE: usize> Freeze for PaddedString<SIZE>
impl<const SIZE: usize> RefUnwindSafe for PaddedString<SIZE>
impl<const SIZE: usize> Send for PaddedString<SIZE>
impl<const SIZE: usize> Sync for PaddedString<SIZE>
impl<const SIZE: usize> Unpin for PaddedString<SIZE>
impl<const SIZE: usize> UnsafeUnpin for PaddedString<SIZE>
impl<const SIZE: usize> UnwindSafe for PaddedString<SIZE>
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