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

pub fn decode<R: Read>(reader: &mut R) -> Result<Vec<u8>, CacheError>

Decodes a buffer. The buffer needs to have the Read trait implemented.

The following process takes place when decoding:

  1. Read the first byte to determine which compression 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)?.to_vec();
let decoded_buffer = rscache::codec::decode(&mut buffer.as_slice())?;