pub struct LzfseEncoder { /* private fields */ }
Expand description
LZFSE encoder.
This basic implementation encodes byte slices into byte vectors.
Implementations§
Source§impl LzfseEncoder
impl LzfseEncoder
Sourcepub fn encode_bytes(&mut self, src: &[u8], dst: &mut Vec<u8>) -> Result<u64>
pub fn encode_bytes(&mut self, src: &[u8], dst: &mut Vec<u8>) -> Result<u64>
Encode src
into dst
returning the number of bytes written into dst
.
§Errors
- ErrorKind::Other in case of
src
ordst
buffer overflow.
§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::LzfseEncoder;
use std::io;
fn main() -> io::Result<()> {
let mut enc = Vec::default();
let mut encoder = LzfseEncoder::default();
let n_bytes = encoder.encode_bytes(b"test", &mut enc)?;
// "test" string encoded.
assert_eq!(enc, &[0x62, 0x76, 0x78, 0x2d, 0x04, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74,
0x62, 0x76, 0x78, 0x24]);
Ok(())
}
Trait Implementations§
Source§impl Debug for LzfseEncoder
impl Debug for LzfseEncoder
Source§impl Default for LzfseEncoder
impl Default for LzfseEncoder
Source§fn default() -> LzfseEncoder
fn default() -> LzfseEncoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LzfseEncoder
impl RefUnwindSafe for LzfseEncoder
impl Send for LzfseEncoder
impl Sync for LzfseEncoder
impl Unpin for LzfseEncoder
impl UnwindSafe for LzfseEncoder
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