Function decode_check

Source
pub fn decode_check<'a, S>(str: S) -> Result<(u8, Vec<u8>), Error>
where S: Into<Cow<'a, str>>,
Available on crate features check and alloc only.
Expand description

Decodes a Crockford Base32Check-encoded string.

§Returns

  • Ok((u8, Vec<u8>)): The version byte and decoded bytes.
  • Err(Error): If any errors occur during the decoding process.

§Errors

§Examples

let encoded = "P7AWVHENJJ0RB441K6JVK5DNJ7J3V5";

// decode string with into a vector
let (version, decoded) = c32::decode_check(encoded)?;

let expected = b"usque ad finem";
assert_eq!(decoded, expected);
assert_eq!(version, 22);