pub fn decode_data(inp: &str) -> Result<Vec<u8>, Box<dyn Error>>Expand description
Decode data with support for leading zeroes (that has been encoded using
encode_data).
To keep leading zeroes, the data has before been prepended with a 0x01
byte. To undo that, the 0x01 byte is removed after decoding.
If the decoded data does not start with a 0x01 byte, an error is returned.
§Algorithm
For how the actual decoding works, see decode_num.
§Errors
An error variant is returned
- when the input string contains invlid chars
- if the data was not encoded with the magic byte
0x01at the beginning (described inencode_data). It is then considered invalid data.
§Example
let encoded = "IKN";
let data = bs62::decode_data(&encoded)?;
assert_eq!(data, vec![0x13_u8, 0x37]);