Struct lzfse_rust::LzfseDecoder
source · pub struct LzfseDecoder { /* private fields */ }
Expand description
LZFSE decoder.
This basic implementation decodes byte slices into byte vectors.
Implementations§
source§impl LzfseDecoder
impl LzfseDecoder
sourcepub fn decode_bytes(&mut self, src: &[u8], dst: &mut Vec<u8>) -> Result<u64>
pub fn decode_bytes(&mut self, src: &[u8], dst: &mut Vec<u8>) -> Result<u64>
Decode src
into dst
returning the number of bytes written into dst
.
Errors
- Error detailing the nature of any errors.
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::LzfseDecoder;
use std::io;
fn main() -> io::Result<()> {
// "test" string encoded.
let enc = vec![
0x62, 0x76, 0x78, 0x2d, 0x04, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x62, 0x76,
0x78, 0x24,
];
let mut decoder = LzfseDecoder::default();
let mut dec = Vec::default();
let n_bytes = decoder.decode_bytes(&enc, &mut dec)?;
assert_eq!(n_bytes, 4);
assert_eq!(dec, b"test");
Ok(())
}
Trait Implementations§
source§impl AsMut<LzfseDecoder> for LzfseRingDecoder
impl AsMut<LzfseDecoder> for LzfseRingDecoder
source§fn as_mut(&mut self) -> &mut LzfseDecoder
fn as_mut(&mut self) -> &mut LzfseDecoder
Converts this type into a mutable reference of the (usually inferred) input type.
source§impl Debug for LzfseDecoder
impl Debug for LzfseDecoder
source§impl Default for LzfseDecoder
impl Default for LzfseDecoder
source§fn default() -> LzfseDecoder
fn default() -> LzfseDecoder
Returns the “default value” for a type. Read more