Struct IovIterDest

Source
pub struct IovIterDest<'data> { /* private fields */ }
Expand description

An IO vector that acts as a destination for data.

IO vectors support many different types of destinations. This includes both buffers in kernel-space and writing to userspace. It’s possible that the destination buffer is mapped in a thread-local manner using e.g. kmap_local_page(), so this type is not Send to ensure that the mapping is written to the right context in that scenario.

§Invariants

Must hold a valid struct iov_iter with data_source set to ITER_DEST. For the duration of 'data, it must be safe to write to this IO vector using the standard C methods for this purpose.

Implementations§

Source§

impl<'data> IovIterDest<'data>

Source

pub unsafe fn from_raw<'iov>(ptr: *mut iov_iter) -> &'iov mut IovIterDest<'data>

Obtain an IovIterDest from a raw pointer.

§Safety
  • The referenced struct iov_iter must be valid and must only be accessed through the returned reference for the duration of 'iov.
  • The referenced struct iov_iter must have data_source set to ITER_DEST.
  • For the duration of 'data, it must be safe to write to this IO vector using the standard C methods for this purpose.
Source

pub fn as_raw(&mut self) -> *mut iov_iter

Access this as a raw struct iov_iter.

Source

pub fn len(&self) -> usize

Returns the number of bytes available in this IO vector.

Note that this may overestimate the number of bytes. For example, reading from userspace memory could fail with EFAULT, which will be treated as the end of the IO vector.

Source

pub fn is_empty(&self) -> bool

Returns whether there are any bytes left in this IO vector.

This may return true even if there are no more bytes available. For example, reading from userspace memory could fail with EFAULT, which will be treated as the end of the IO vector.

Source

pub fn advance(&mut self, bytes: usize)

Advance this IO vector by bytes bytes.

If bytes is larger than the size of this IO vector, it is advanced to the end.

Source

pub unsafe fn revert(&mut self, bytes: usize)

Advance this IO vector backwards by bytes bytes.

§Safety

The IO vector must not be reverted to before its beginning.

Source

pub fn copy_to_iter(&mut self, input: &[u8]) -> usize

Write data to this IO vector.

Returns the number of bytes that were written. If this is shorter than the provided slice, then no more bytes can be written.

Source

pub fn simple_read_from_buffer( &mut self, ppos: &mut i64, contents: &[u8], ) -> Result<usize>

Utility for implementing read_iter given the full contents of the file.

The full contents of the file being read from is represented by contents. This call will write the appropriate sub-slice of contents and update the file position in ppos so that the file will appear to contain contents even if takes multiple reads to read the entire file.

Auto Trait Implementations§

§

impl<'data> !Freeze for IovIterDest<'data>

§

impl<'data> !RefUnwindSafe for IovIterDest<'data>

§

impl<'data> !Send for IovIterDest<'data>

§

impl<'data> !Sync for IovIterDest<'data>

§

impl<'data> !Unpin for IovIterDest<'data>

§

impl<'data> !UnwindSafe for IovIterDest<'data>

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> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

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

Source§

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

Source§

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.