Struct lzfse_rust::LzfseEncoder
source · 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