Skip to main content

UserInPtr

Struct UserInPtr 

Source
pub struct UserInPtr<T> { /* private fields */ }
Expand description

A wrapper around a const pointer to user memory.

Implementations§

Source§

impl<T> UserInPtr<T>

Source

pub const fn new(ptr: *const T) -> Self

Constructs a new UserInPtr.

Source

pub fn is_null(&self) -> bool

Returns true if the underlying pointer is null.

Source

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

Returns the underlying raw pointer.

Source

pub fn byte_offset(&self, count: isize) -> Self

Returns a pointer offset by count bytes.

Source

pub fn element_offset(&self, index: usize) -> Self

Returns a pointer offset by index elements.

Source

pub fn reinterpret<U>(&self) -> UserInPtr<U>

Reinterprets the pointer as a pointer to type U.

Source

pub fn copy_from_user<'a>( &self, dst: &'a mut MaybeUninit<T>, ) -> Result<&'a mut T, Status>
where T: FromBytes + IntoBytes,

Copies a single element from userspace into dst.

Source

pub fn read(&self) -> Result<T, Status>

Reads and returns a single copyable element from userspace.

Source

pub fn copy_slice_from_user<'a>( &self, dst: &'a mut [MaybeUninit<T>], ) -> Result<&'a mut [T], Status>
where T: FromBytes + IntoBytes,

Copies a slice of elements from userspace into dst.

Trait Implementations§

Source§

impl<T: Clone> Clone for UserInPtr<T>

Source§

fn clone(&self) -> UserInPtr<T>

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<T: Debug> Debug for UserInPtr<T>

Source§

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

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

impl<T: Default> Default for UserInPtr<T>

Source§

fn default() -> UserInPtr<T>

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

impl<T: Copy> Copy for UserInPtr<T>

Auto Trait Implementations§

§

impl<T> Freeze for UserInPtr<T>

§

impl<T> RefUnwindSafe for UserInPtr<T>
where T: RefUnwindSafe,

§

impl<T> !Send for UserInPtr<T>

§

impl<T> !Sync for UserInPtr<T>

§

impl<T> Unpin for UserInPtr<T>

§

impl<T> UnsafeUnpin for UserInPtr<T>

§

impl<T> UnwindSafe for UserInPtr<T>
where T: RefUnwindSafe,

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.