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>
impl<'data> IovIterDest<'data>
Sourcepub unsafe fn from_raw<'iov>(ptr: *mut iov_iter) -> &'iov mut IovIterDest<'data>
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 havedata_source
set toITER_DEST
. - For the duration of
'data
, it must be safe to write to this IO vector using the standard C methods for this purpose.
Sourcepub fn len(&self) -> usize
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.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn advance(&mut self, bytes: usize)
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.
Sourcepub unsafe fn revert(&mut self, bytes: usize)
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.
Sourcepub fn copy_to_iter(&mut self, input: &[u8]) -> usize
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.
Sourcepub fn simple_read_from_buffer(
&mut self,
ppos: &mut i64,
contents: &[u8],
) -> Result<usize>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot
. Read more