#[repr(C)]pub struct FixedCapacityStringU16<const CAPACITY: usize> { /* private fields */ }
Expand description
Container for storing a UTF-8 string limited by the specified fixed bytes capacity as u16
.
This is a string only by convention, there is no runtime verification done, contents is treated as regular bytes.
See also FixedCapacityStringU8
if you need to store fewer bytes.
This is just a wrapper for FixedCapacityBytesU16
that the type dereferences to with a
different semantic meaning.
Implementations§
Source§impl<const CAPACITY: usize> FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> FixedCapacityStringU16<CAPACITY>
Sourcepub fn try_from_str(s: &str) -> Option<Self>
pub fn try_from_str(s: &str) -> Option<Self>
Try to create an instance from provided string.
Returns None
if provided string does not fit into the capacity.
Sourcepub fn try_from_bytes(bytes: &[u8]) -> Option<Self>
pub fn try_from_bytes(bytes: &[u8]) -> Option<Self>
Try to create an instance from provided bytes.
Returns None
if provided bytes do not fit into the capacity.
Methods from Deref<Target = FixedCapacityBytesU16<CAPACITY>>§
Sourcepub fn get_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn get_bytes_mut(&mut self) -> &mut [u8] ⓘ
Exclusive access to stored bytes
Sourcepub fn append(&mut self, bytes: &[u8]) -> bool
pub fn append(&mut self, bytes: &[u8]) -> bool
Append some bytes.
true
is returned on success, but if there isn’t enough capacity left, false
is.
Sourcepub fn truncate(&mut self, new_len: u16) -> bool
pub fn truncate(&mut self, new_len: u16) -> bool
Truncate stored bytes to this length.
Returns true
on success or false
if new_len
is larger than Self::len()
.
Trait Implementations§
Source§impl<const CAPACITY: usize> Clone for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Clone for FixedCapacityStringU16<CAPACITY>
Source§fn clone(&self) -> FixedCapacityStringU16<CAPACITY>
fn clone(&self) -> FixedCapacityStringU16<CAPACITY>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<const CAPACITY: usize> Debug for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Debug for FixedCapacityStringU16<CAPACITY>
Source§impl<const CAPACITY: usize> Default for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Default for FixedCapacityStringU16<CAPACITY>
Source§impl<const CAPACITY: usize> Deref for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Deref for FixedCapacityStringU16<CAPACITY>
Source§impl<const CAPACITY: usize> DerefMut for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> DerefMut for FixedCapacityStringU16<CAPACITY>
Source§impl<const CAPACITY: usize> TrivialType for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> TrivialType for FixedCapacityStringU16<CAPACITY>
Source§const METADATA: &[u8]
const METADATA: &[u8]
IoTypeMetadataKind
for encoding details.const SIZE: u32 = _
Source§unsafe fn from_bytes(bytes: &[u8]) -> Option<&Self>
unsafe fn from_bytes(bytes: &[u8]) -> Option<&Self>
impl<const CAPACITY: usize> Copy for FixedCapacityStringU16<CAPACITY>
Auto Trait Implementations§
impl<const CAPACITY: usize> Freeze for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> RefUnwindSafe for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Send for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Sync for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> Unpin for FixedCapacityStringU16<CAPACITY>
impl<const CAPACITY: usize> UnwindSafe for FixedCapacityStringU16<CAPACITY>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IoType for Twhere
T: TrivialType,
impl<T> IoType for Twhere
T: TrivialType,
Source§const METADATA: &'static [u8] = const METADATA: &'_ [u8] = T::METADATA;
const METADATA: &'static [u8] = const METADATA: &'_ [u8] = T::METADATA;
IoTypeMetadataKind
for encoding detailsSource§type PointerType = T
type PointerType = T
IoType
represents