pub struct ApiFixedString<const N: usize> { /* private fields */ }Expand description
A string type used in VPP API messages.
This represents a fixed-length, nul-terminated string, commonly used in VPP API message structures.
Implementations§
Source§impl<const N: usize> ApiFixedString<N>
impl<const N: usize> ApiFixedString<N>
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns a byte slice of the string’s contents not including the nul-terminator.
Sourcepub fn to_str(&self) -> Result<&str, Utf8Error>
pub fn to_str(&self) -> Result<&str, Utf8Error>
Converts the string to a &str slice.
If the contents of the ApiFixedString are valid UTF-8 data, this
function will return the corresponding &[str] slice. Otherwise,
it will return an error with details of where UTF-8 validation failed.
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Converts the string to a Cow<str>, replacing invalid UTF-8 sequences with �.
Sourcepub fn copy_from_str(&mut self, s: &str)
pub fn copy_from_str(&mut self, s: &str)
Copies the contents of the given string into this ApiFixedString.
§Panics
Panics if the string exceeds the capacity of the fixed buffer.
Trait Implementations§
Source§impl<const N: usize> Clone for ApiFixedString<N>
impl<const N: usize> Clone for ApiFixedString<N>
Source§fn clone(&self) -> ApiFixedString<N>
fn clone(&self) -> ApiFixedString<N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const N: usize> Debug for ApiFixedString<N>
impl<const N: usize> Debug for ApiFixedString<N>
Source§impl<const N: usize> Default for ApiFixedString<N>
impl<const N: usize> Default for ApiFixedString<N>
Source§impl<const N: usize> EndianSwap for ApiFixedString<N>
impl<const N: usize> EndianSwap for ApiFixedString<N>
Source§unsafe fn endian_swap(&mut self, _to_net: bool)
unsafe fn endian_swap(&mut self, _to_net: bool)
Swap the endianness of the message in-place. Read more
Source§impl<const N: usize> PartialEq for ApiFixedString<N>
impl<const N: usize> PartialEq for ApiFixedString<N>
impl<const N: usize> Copy for ApiFixedString<N>
impl<const N: usize> Eq for ApiFixedString<N>
impl<const N: usize> StructuralPartialEq for ApiFixedString<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for ApiFixedString<N>
impl<const N: usize> RefUnwindSafe for ApiFixedString<N>
impl<const N: usize> Send for ApiFixedString<N>
impl<const N: usize> Sync for ApiFixedString<N>
impl<const N: usize> Unpin for ApiFixedString<N>
impl<const N: usize> UnsafeUnpin for ApiFixedString<N>
impl<const N: usize> UnwindSafe for ApiFixedString<N>
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