gistools/parsers/write/
mod.rs

1/// Buffer Writer for writing data from a vector
2mod buffer;
3/// File Writer for writing data from a file
4#[cfg(feature = "std")]
5mod file;
6
7use alloc::vec::Vec;
8pub use buffer::*;
9#[cfg(feature = "std")]
10pub use file::*;
11
12/// The defacto interface for all writers.
13pub trait Writer {
14    /// Get the current offset of the writer
15    fn offset(&mut self) -> u64;
16    /// Write data at the specified offset to the writer
17    fn write(&mut self, data: &[u8], offset: u64);
18    /// Append data to the writer
19    fn append(&mut self, data: &[u8]);
20    /// Append string to the writer
21    fn append_string(&mut self, string: &str);
22    /// Take the data for oneself
23    fn take(&mut self) -> Vec<u8>;
24    /// Get a slice of written data
25    fn slice(&mut self, start: u64, end: u64) -> Vec<u8>;
26    /// Flush the writer (if applicable)
27    fn flush(&mut self);
28}