pub struct CString16(_);
Expand description
Methods from Deref<Target = CStr16>
sourcepub fn as_slice_with_nul(&self) -> &[Char16]
pub fn as_slice_with_nul(&self) -> &[Char16]
Get the underlying Char16
slice, including the trailing null.
sourcepub fn to_u16_slice(&self) -> &[u16]
pub fn to_u16_slice(&self) -> &[u16]
Converts this C string to a u16 slice
sourcepub fn to_u16_slice_with_nul(&self) -> &[u16]
pub fn to_u16_slice_with_nul(&self) -> &[u16]
Converts this C string to a u16 slice containing the trailing 0 char
sourcepub fn num_bytes(&self) -> usize
pub fn num_bytes(&self) -> usize
Get the number of bytes in the string (including the trailing null character).
sourcepub fn as_str_in_buf(&self, buf: &mut dyn Write) -> Result
pub fn as_str_in_buf(&self, buf: &mut dyn Write) -> Result
Writes each Char16
as a [´char´] (4 bytes long in Rust language) into the buffer.
It is up the the implementer of core::fmt::Write
to convert the char to a string
with proper encoding/charset. For example, in the case of alloc::string::String
all Rust chars (UTF-32) get converted to UTF-8.
Example
let firmware_vendor_c16_str: CStr16 = ...;
// crate "arrayvec" uses stack-allocated arrays for Strings => no heap allocations
let mut buf = arrayvec::ArrayString::<128>::new();
firmware_vendor_c16_str.as_str_in_buf(&mut buf);
log::info!("as rust str: {}", buf.as_str());
Trait Implementations
sourceimpl Ord for CString16
impl Ord for CString16
sourceimpl PartialOrd<CString16> for CString16
impl PartialOrd<CString16> for CString16
sourcefn partial_cmp(&self, other: &CString16) -> Option<Ordering>
fn partial_cmp(&self, other: &CString16) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for CString16
impl StructuralEq for CString16
impl StructuralPartialEq for CString16
Auto Trait Implementations
impl RefUnwindSafe for CString16
impl Send for CString16
impl Sync for CString16
impl Unpin for CString16
impl UnwindSafe for CString16
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more