[][src]Module devker::deflate

Deflate/Inflate

Examples

Easy to use.

use devker::prelude::{deflate, inflate, BlockType, Cache};

let mut cache = Cache::new();
let v = String::from("Hello world, this is a wonderful world !");
let v_in = v.into_bytes();

// Encode.
let encoded = deflate(&v_in, BlockType::Fixed, &mut cache);
// Decode.
let decoded = inflate(&encoded, &mut cache).unwrap();
assert_eq!(v_in, decoded);

Reusable cache.

use devker::prelude::{deflate, inflate, BlockType, Cache};

let mut cache = Cache::new();

// First try.

let v = String::from("Hello world, this is a wonderful world !");
let v_in = v.into_bytes();

let encoded = deflate(&v_in, BlockType::Fixed, &mut cache);
let decoded = inflate(&encoded, &mut cache).unwrap();
assert_eq!(v_in, decoded);

// Another try.

let v = String::from("The cache can be reused !");
let v_in = v.into_bytes();

let encoded = deflate(&v_in, BlockType::Fixed, &mut cache);
let decoded = inflate(&encoded, &mut cache).unwrap();
assert_eq!(v_in, decoded);

Functions

deflate
inflate
inflate_to