pub struct Writer { /* private fields */ }
Expand description
A sans-io writer state machine.
Implementations§
source§impl Writer
impl Writer
sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
Get a reference to the output data buffer where data should be taken from.
The amount of data copied should be marked with [consume
].
sourcepub fn space(&mut self) -> &mut [u8] ⓘ
pub fn space(&mut self) -> &mut [u8] ⓘ
Get a reference to the space data buffer where data should inserted.
sourcepub fn step_write_header(&mut self) -> Result<WriterAction<()>, Error>
pub fn step_write_header(&mut self) -> Result<WriterAction<()>, Error>
Step the state machine, performing the action of writing the header.
If the header has already been written, Ok(Writer::Done(()))
is returned and no work is performed.
Calling this method is optional.
The state machine will automatically write the header is if has not been written.
sourcepub fn step_write_file_header(
&mut self,
name: &str,
size: u32,
) -> Result<WriterAction<()>, Error>
pub fn step_write_file_header( &mut self, name: &str, size: u32, ) -> Result<WriterAction<()>, Error>
Step the state machine, performing the action of writing the next file header.
This will write the header if it has not been written already.
sourcepub fn step_write_file_data(
&mut self,
size: usize,
) -> Result<WriterAction<usize>, Error>
pub fn step_write_file_data( &mut self, size: usize, ) -> Result<WriterAction<usize>, Error>
Step the state machine, performing the action of writing the file data.
This will write the header if it has not been written already. Populate the space buffer with the bytes to write, then pass the number of bytes written to this function.