Struct lzfse_rust::LzfseWriter
source · pub struct LzfseWriter<'a, O> { /* private fields */ }
Expand description
LZFSE encoding writer.
Exposes, in part, a LZFSE encoder via the Write interface that encodes into an inner writer. Due to the nature of LZFSE streams Write::flush has no effect, instead it is imperative that we call LzfseWriter::finalize after use to complete the encoding process.
Instances are created using LzfseRingEncoder::writer_bytes.
Examples
use lzfse_rust::LzfseRingEncoder;
use std::io::{self, Write};
fn main() -> io::Result<()> {
let mut encoder = LzfseRingEncoder::default();
let inner = Vec::default();
let mut writer = encoder.writer(inner);
writer.write_all(b"test")?;
// It is IMPERATIVE that the writer is finalized.
let enc = writer.finalize()?;
// "test" string encoded.
assert_eq!(enc, &[0x62, 0x76, 0x78, 0x2d, 0x04, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74,
0x62, 0x76, 0x78, 0x24]);
Ok(())
}
Implementations§
Trait Implementations§
source§impl<'a, O> Debug for LzfseWriter<'a, O>
impl<'a, O> Debug for LzfseWriter<'a, O>
source§impl<'a, O: Write> Write for LzfseWriter<'a, O>
impl<'a, O: Write> Write for LzfseWriter<'a, O>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more