pub fn decoded_len_estimate(encoded_len: usize) -> usize
Expand description

Returns a conservative estimate of the decoded size of encoded_len base64 symbols (rounded up to the next group of 3 decoded bytes).

The resulting length will be a safe choice for the size of a decode buffer, but may have up to 2 trailing bytes that won’t end up being needed.

Examples

use base64::decoded_len_estimate;

assert_eq!(3, decoded_len_estimate(1));
assert_eq!(3, decoded_len_estimate(2));
assert_eq!(3, decoded_len_estimate(3));
assert_eq!(3, decoded_len_estimate(4));
// start of the next quad of encoded symbols
assert_eq!(6, decoded_len_estimate(5));