[][src]Function kvds::decode_from_file

pub fn decode_from_file(
    name: &str
) -> Result<Vec<(u8, Vec<u8>)>, DecodeFromFileError>

Decodes a key-value list from a file.

Example

let decoded = kvds::decode_from_file("data")?;

assert_eq!(decoded, vec![
    (1, "Hello".as_bytes().to_vec()),
    (2, ", ".as_bytes().to_vec()),
    (4, "world".as_bytes().to_vec()),
    (1, "!".as_bytes().to_vec()),
]);

Errors

This function returns an error if something goes wrong with opening or reading a file, or an error occurs in decoding the data.