[go: up one dir, main page]

decode

Function decode 

Source
pub fn decode<T>(input: T) -> Result<Vec<u8>, Error>
where T: AsRef<[u8]>,
Expand description

Decode a base64 encoded string using the standard base64 decoding scheme.

§Arguments

  • input - The base64 encoded input data to decode, which can be any type that implements AsRef<[u8]>.

§Returns

A Result containing a Vec<u8> with the decoded data, or an error if the input is not valid base64.

§Examples

let encoded = "SGVsbG8sIHdvcmxkIQ==";
let decoded = base64::decode(encoded).expect("Decoding should succeed");
assert_eq!(decoded, b"Hello, world!");