pub struct LzfseWriterBytes<'a> { /* private fields */ }
Expand description
LZFSE encoding byte writer.
Exposes, in part, a LZFSE encoder via the Write interface that encodes into an inner Vec. Due to the nature of LZFSE streams Write::flush has no effect, instead it is imperative that we call LzfseWriterBytes::finalize after use to complete the encoding process.
Instances are created using LzfseRingEncoder::writer_bytes.
§Aborts
With limited system memory Vec may abort when attempting to allocate sufficient memory. This issue will be resolved in future releases when try_reserve() is stabilized.
§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_bytes(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> Debug for LzfseWriterBytes<'a>
impl<'a> Debug for LzfseWriterBytes<'a>
Source§impl<'a> Write for LzfseWriterBytes<'a>
impl<'a> Write for LzfseWriterBytes<'a>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes 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
Auto Trait Implementations§
impl<'a> Freeze for LzfseWriterBytes<'a>
impl<'a> RefUnwindSafe for LzfseWriterBytes<'a>
impl<'a> !Send for LzfseWriterBytes<'a>
impl<'a> !Sync for LzfseWriterBytes<'a>
impl<'a> Unpin for LzfseWriterBytes<'a>
impl<'a> !UnwindSafe for LzfseWriterBytes<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more