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>§

source

pub fn as_ptr(&self) -> *const Char16

Returns the inner pointer to this C16 string.

source

pub fn as_slice(&self) -> &[Char16]

Get the underlying Char16s as slice without the trailing null.

source

pub fn as_slice_with_nul(&self) -> &[Char16]

Get the underlying Char16s as slice including the trailing null.

source

pub fn to_u16_slice(&self) -> &[u16]

Converts this C string to a u16 slice without the trailing null.

source

pub fn to_u16_slice_with_nul(&self) -> &[u16]

Converts this C string to a u16 slice containing the trailing null.

source

pub fn iter(&self) -> CStr16Iter<'_>

Returns an iterator over this C string

source

pub fn num_chars(&self) -> usize

Returns the number of characters without the trailing null. character

source

pub fn is_empty(&self) -> bool

Returns if the string is empty. This ignores the null character.

source

pub fn num_bytes(&self) -> usize

Get the number of bytes in the string (including the trailing null).

source

pub fn is_ascii(&self) -> bool

Checks if all characters in this string are within the ASCII range.

source

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());
source

pub fn as_bytes(&self) -> &[u8]

Returns the underlying bytes as slice including the terminating null character.

Trait Implementations§

source§

impl<'a> Debug for PoolString<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Deref for PoolString<'a>

§

type Target = CStr16

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Drop for PoolString<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PoolString<'a>

§

impl<'a> RefUnwindSafe for PoolString<'a>

§

impl<'a> !Send for PoolString<'a>

§

impl<'a> !Sync for PoolString<'a>

§

impl<'a> Unpin for PoolString<'a>

§

impl<'a> UnwindSafe for PoolString<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.