Struct IovIterSource

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

An IO vector that acts as a source of data.

The data may come from many different sources. This includes both things in kernel-space and reading from userspace. It’s not necessarily the case that the data source is immutable, so rewinding the IO vector to read the same data twice is not guaranteed to result in the same bytes. It’s also possible that the data source 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 read from the right context in that scenario.

§Invariants

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

Implementations§

Source§

impl<'data> IovIterSource<'data>

Source

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

Obtain an IovIterSource 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_SOURCE.
  • For the duration of 'data, it must be safe to read from 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_from_iter(&mut self, out: &mut [u8]) -> usize

Read data from this IO vector.

Returns the number of bytes that have been copied.

Source

pub fn copy_from_iter_vec<A: Allocator>( &mut self, out: &mut Vec<u8, A>, flags: Flags, ) -> Result<usize>

Read data from this IO vector and append it to a vector.

Returns the number of bytes that have been copied.

Source

pub fn copy_from_iter_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> &mut [u8]

Read data from this IO vector into potentially uninitialized memory.

Returns the sub-slice of the output that has been initialized. If the returned slice is shorter than the input buffer, then the entire IO vector has been read.

This will never write uninitialized bytes to the provided buffer.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'data> UnwindSafe for IovIterSource<'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.