pub struct UserSliceWriter { /* private fields */ }Expand description
A writer for UserSlice.
Used to incrementally write into the user slice.
Implementations§
Source§impl UserSliceWriter
impl UserSliceWriter
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the amount of space remaining in this buffer.
Note that even writing less than this number of bytes may fail.
Sourcepub fn write_slice(&mut self, data: &[u8]) -> Result
pub fn write_slice(&mut self, data: &[u8]) -> Result
Writes raw data to this user pointer from a kernel buffer.
Fails with EFAULT if the write happens on a bad address, or if the write goes out of
bounds of this UserSliceWriter. This call may modify the associated userspace slice even
if it returns an error.
Sourcepub fn write_slice_partial(
&mut self,
data: &[u8],
offset: usize,
) -> Result<usize>
pub fn write_slice_partial( &mut self, data: &[u8], offset: usize, ) -> Result<usize>
Writes raw data to this user pointer from a kernel buffer partially.
This is the same as Self::write_slice but considers the given offset into data and
truncates the write to the boundaries of self and data.
On success, returns the number of bytes written.
Sourcepub fn write_slice_file(
&mut self,
data: &[u8],
offset: &mut Offset,
) -> Result<usize>
pub fn write_slice_file( &mut self, data: &[u8], offset: &mut Offset, ) -> Result<usize>
Writes raw data to this user pointer from a kernel buffer partially.
This is the same as Self::write_slice_partial but updates the given file::Offset by
the number of bytes written.
This is equivalent to C’s simple_read_from_buffer().
On success, returns the number of bytes written.
Sourcepub fn write<T: AsBytes>(&mut self, value: &T) -> Result
pub fn write<T: AsBytes>(&mut self, value: &T) -> Result
Writes the provided Rust value to this userspace pointer.
Fails with EFAULT if the write happens on a bad address, or if the write goes out of
bounds of this UserSliceWriter. This call may modify the associated userspace slice even
if it returns an error.
Auto Trait Implementations§
impl Freeze for UserSliceWriter
impl RefUnwindSafe for UserSliceWriter
impl !Send for UserSliceWriter
impl !Sync for UserSliceWriter
impl Unpin for UserSliceWriter
impl UnwindSafe for UserSliceWriter
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