Function rscache::codec::decode[][src]

pub fn decode(buffer: &[u8]) -> Result<Vec<u8>>
Expand description

Decodes the buffer.

The following process takes place when decoding:

  1. Read the first byte to determine which compression type should be used to decompress.
  2. Read the length of the rest of the buffer.
  3. Decompress the remaining bytes.

Errors

Returns an error if the remaining bytes couldn’t be decompressed.

Examples

use rscache::codec::Compression;
 
let buffer = cache.read(2, 10)?;
let decoded_buffer = rscache::codec::decode(&buffer)?;