Skip to main content

decode

Function decode 

Source
pub fn decode(encoded: &str) -> Result<Vec<u8>, &'static str>
Expand description

Decodes a Base122 encoded string back into its original binary form.

§Errors

Returns an Err if the input string is not a valid Base122 sequence. This can happen if:

  • It contains invalid UTF-8 lead bytes not conforming to Base122 escape patterns.
  • An escape sequence is malformed or truncated.
  • The illegal character index is out of the defined 0-6 range.

§Performance

Decoding is optimized via unaligned 64-bit reads and a lookup-table-based state machine to quickly process 7-bit groups.

§Examples

let data = b"data";
let encoded = base122_fast::encode(data);
let decoded = base122_fast::decode(&encoded).unwrap();

assert_eq!(data, &decoded[..]);