Trait kernel::io_buffer::IoBufferWriter
source · [−]pub trait IoBufferWriter {
fn len(&self) -> usize;
fn clear(&mut self, len: usize) -> Result;
unsafe fn write_raw(&mut self, data: *const u8, len: usize) -> Result;
fn is_empty(&self) -> bool { ... }
fn write_slice(&mut self, data: &[u8]) -> Result { ... }
fn write<T: WritableToBytes>(&mut self, data: &T) -> Result { ... }
}
Expand description
Represents a buffer to be written to during IO.
Required Methods
sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the number of bytes left to be written into the io buffer.
Note that even writing less than this number of bytes may fail.
sourcefn clear(&mut self, len: usize) -> Result
fn clear(&mut self, len: usize) -> Result
Writes zeroes to the io buffer.
Differently from the other write functions, clear
will zero as much as it can and update
the writer internal state to reflect this. It will, however, return an error if it cannot
clear len
bytes.
For example, if a caller requests that 100 bytes be cleared but a segfault happens after 20 bytes, then EFAULT is returned and the writer is advanced by 20 bytes.
Provided Methods
sourcefn write_slice(&mut self, data: &[u8]) -> Result
fn write_slice(&mut self, data: &[u8]) -> Result
Writes a byte slice into the io buffer.
Returns EFAULT
if the byte slice is bigger than the remaining size of the io buffer or if
the address does not currently point to mapped, writable memory.
sourcefn write<T: WritableToBytes>(&mut self, data: &T) -> Result
fn write<T: WritableToBytes>(&mut self, data: &T) -> Result
Writes the contents of the given data into the io buffer.