[][src]Function kvds::decode

pub fn decode(slice: Vec<u8>) -> Result<Vec<(u8, Vec<u8>)>, DecodeError>

Decodes a Vec of data into a Vec of key-value pairs.

Note: This function cannot decode values that are more than 1.845*10^19 (or 256^8, or 2^64) bytes (or 18,447 petabytes) long.

Example

let data = vec![1, 0, 3, 111, 110, 101, 2, 0, 3, 116, 119, 111];

let decoded = kvds::decode(data)?;

assert_eq!(decoded, vec![
    (1, "one".as_bytes().to_vec()),
    (2, "two".as_bytes().to_vec()),
]);