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::InvalidOutputLength if output.len() != data.len() * 2.

§Example

let mut buf = [0u8; 10];
hex::encode_into(&mut buf, b"hello", hex::Alphabet::Lower).unwrap();
assert_eq!(&buf, b"68656c6c6f");