Skip to main content

UserStringView

Struct UserStringView 

Source
#[repr(C)]
pub struct UserStringView { pub data: UserInPtr<u8>, pub length: usize, }
Expand description

A wrapper around zx_string_view_t passed from userspace into kernel syscalls.

This struct has exact memory layout parity with zx_string_view_t (const char*, size_t), ensuring ABI compatibility when passed by value across FFI boundaries.

Fields§

§data: UserInPtr<u8>

Pointer to userspace UTF-8 bytes.

§length: usize

Length of the string in bytes.

Implementations§

Source§

impl UserStringView

Source

pub fn is_empty(&self) -> bool

Returns true if the string view is empty.

Source

pub fn len(&self) -> usize

Returns the length of the string view in bytes.

Source

pub fn copy_slice_from_user<'a>( &self, dst: &'a mut [MaybeUninit<u8>], ) -> Result<&'a mut [u8], Status>

Copies the string bytes from userspace into a destination slice.

Returns Status::INVALID_ARGS if the slice is smaller than length.

Trait Implementations§

Source§

impl Clone for UserStringView

Source§

fn clone(&self) -> UserStringView

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserStringView

Source§

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

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

impl Default for UserStringView

Source§

fn default() -> UserStringView

Returns the “default value” for a type. Read more
Source§

impl Copy for UserStringView

Auto Trait Implementations§

§

impl Freeze for UserStringView

§

impl RefUnwindSafe for UserStringView

§

impl !Send for UserStringView

§

impl !Sync for UserStringView

§

impl Unpin for UserStringView

§

impl UnsafeUnpin for UserStringView

§

impl UnwindSafe for UserStringView

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.