[][src]Function kvds::encode

pub fn encode(slice: Vec<(u8, Vec<u8>)>) -> Result<Vec<u8>, EncodeError>

Encodes data!

Example

let data = vec![
    (1, "one".as_bytes().to_vec()),
    (2, "two".as_bytes().to_vec()),
];

let encoded = kvds::encode(data)?;

assert_eq!(encoded, vec![1, 0, 3, 111, 110, 101, 2, 0, 3, 116, 119, 111]);

Errors

This function returns an error if any of the values supplied are too long.