Skip to main content

encode_into

Function encode_into 

Source
pub fn encode_into(
    output: &mut [u8],
    data: &[u8],
    alphabet: Alphabet,
) -> Result<(), EncodeError>
Expand description

Encodes bytes into an existing buffer.

Dispatches to a SIMD-accelerated implementation (AVX2 or NEON) when the target feature is available.

See encode_into_constant_time for security-sensitive and cryptographic operations.

§Errors

Returns EncodeError if output.len() does not match the expected encoded length or if the encoded length overflows usize.

§Example

let mut buf = [0u8; 16];
base64::encode_into(&mut buf, b"hello world", base64::Alphabet::Standard).unwrap();
assert_eq!(&buf, b"aGVsbG8gd29ybGQ=");