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

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.

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.

Writes raw data to the io buffer from a raw kernel buffer.

Safety

The input buffer must be valid.

Provided Methods

Returns true if the io buffer cannot hold any additional data.

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.

Writes the contents of the given data into the io buffer.

Implementors