Writer

Trait Writer 

Source
pub trait Writer {
    // Required methods
    fn offset(&mut self) -> u64;
    fn write(&mut self, data: &[u8], offset: u64);
    fn append(&mut self, data: &[u8]);
    fn append_string(&mut self, string: &str);
    fn take(&mut self) -> Vec<u8> ;
    fn slice(&mut self, start: u64, end: u64) -> Vec<u8> ;
    fn flush(&mut self);
}
Expand description

The defacto interface for all writers.

Required Methods§

Source

fn offset(&mut self) -> u64

Get the current offset of the writer

Source

fn write(&mut self, data: &[u8], offset: u64)

Write data at the specified offset to the writer

Source

fn append(&mut self, data: &[u8])

Append data to the writer

Source

fn append_string(&mut self, string: &str)

Append string to the writer

Source

fn take(&mut self) -> Vec<u8>

Take the data for oneself

Source

fn slice(&mut self, start: u64, end: u64) -> Vec<u8>

Get a slice of written data

Source

fn flush(&mut self)

Flush the writer (if applicable)

Implementors§

Source§

impl Writer for BufferWriter

Source§

impl Writer for FileWriter

Available on crate feature std only.