[−][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:
- Read the first byte to determine which compression should be used to decompress.
- Read the length of the rest of the buffer.
- 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())?;