Skip to main content

decode

Function decode 

Source
pub fn decode(data: &[u8]) -> Result<Vec<u8>, DvplError>
Expand description

Decode a DVPL blob: validate footer, verify CRC32, decompress payload.

See the module-level docs for the footer layout.

§Errors

Returns DvplError if the footer is malformed, the CRC32 doesn’t match, the decompressed size is wrong, or the compression type is unrecognized.

§Examples

use dvpl_engine::COMP_LZ4;
use dvpl_engine::decode;
use dvpl_engine::encode;

let blob = encode(b"round trip", COMP_LZ4).unwrap();
let original = decode(&blob).unwrap();
assert_eq!(original, b"round trip");