Struct uefi::proto::device_path::text::PoolString
source · pub struct PoolString<'a> { /* private fields */ }
Expand description
Wrapper for a string internally allocated from UEFI boot services memory.
Methods from Deref<Target = CStr16>§
sourcepub fn as_slice(&self) -> &[Char16]
pub fn as_slice(&self) -> &[Char16]
Get the underlying Char16
s as slice without the trailing null.
sourcepub fn as_slice_with_nul(&self) -> &[Char16]
pub fn as_slice_with_nul(&self) -> &[Char16]
Get the underlying Char16
s as 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 without the trailing null.
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 null.
sourcepub fn num_chars(&self) -> usize
pub fn num_chars(&self) -> usize
Returns the number of characters without the trailing null. character
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns if the string is empty. This ignores the null character.
sourcepub fn num_bytes(&self) -> usize
pub fn num_bytes(&self) -> usize
Get the number of bytes in the string (including the trailing null).
sourcepub fn is_ascii(&self) -> bool
pub fn is_ascii(&self) -> bool
Checks if all characters in this string are within the ASCII range.
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 to 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());