UserU8SliceWO

Struct UserU8SliceWO 

Source
pub struct UserU8SliceWO {
    addr: usize,
    len: usize,
}
Expand description

A one-time, write-only pointer to a slice of u8 in user-space.

This struct allows the kernel to safely write to a user-space buffer while preventing TOCTOU attacks by taking ownership of the pointer during operations.

Fields§

§addr: usize§len: usize

Implementations§

Source§

impl UserU8SliceWO

Source

pub fn new(addr: usize, len: usize) -> Self

Creates a new UserU8SliceWO instance with the given user-space address and length.

Source

pub fn put(self, other: &[u8]) -> Result<usize, KernelError>

Writes data from a slice to the user-space buffer.

Takes ownership of self to prevent TOCTOU attacks.

Returns Ok(usize) indicating the number of bytes written, or Err(KernelError::BadAddress) on failure.

Trait Implementations§

Source§

impl Debug for UserU8SliceWO

Source§

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

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

impl Ord for UserU8SliceWO

Source§

fn cmp(&self, other: &UserU8SliceWO) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for UserU8SliceWO

Source§

fn eq(&self, other: &UserU8SliceWO) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for UserU8SliceWO

Source§

fn partial_cmp(&self, other: &UserU8SliceWO) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for UserU8SliceWO

Source§

impl StructuralPartialEq for UserU8SliceWO

Auto Trait Implementations§

§

impl Freeze for UserU8SliceWO

§

impl RefUnwindSafe for UserU8SliceWO

§

impl Send for UserU8SliceWO

§

impl Sync for UserU8SliceWO

§

impl Unpin for UserU8SliceWO

§

impl UnwindSafe for UserU8SliceWO

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