Function base64::decode_engine
source · pub fn decode_engine<E: Engine, T: AsRef<[u8]>>(
input: T,
engine: &E
) -> Result<Vec<u8>, DecodeError>
Expand description
Decode from string reference as octets using the specified Engine.
Returns a Result
containing a Vec<u8>
.
Example
let bytes = base64::decode_engine(
"aGVsbG8gd29ybGR+Cg==",
&base64::engine::DEFAULT_ENGINE,
).unwrap();
println!("{:?}", bytes);
// custom engine setup
let bytes_url = base64::decode_engine(
"aGVsbG8gaW50ZXJuZXR-Cg",
&base64::engine::fast_portable::FastPortable::from(
&base64::alphabet::URL_SAFE,
base64::engine::fast_portable::NO_PAD),
).unwrap();
println!("{:?}", bytes_url);