pub trait Encoding: Alphabet {
    fn decode(src: impl AsRef<[u8]>, dst: &mut [u8]) -> Result<&[u8], Error>;
    fn decode_in_place(buf: &mut [u8]) -> Result<&[u8], InvalidEncodingError>;
    fn decode_vec(input: &str) -> Result<Vec<u8>, Error>;
    fn encode<'a>(
        src: &[u8],
        dst: &'a mut [u8]
    ) -> Result<&'a str, InvalidLengthError>; fn encode_string(input: &[u8]) -> String; fn encoded_len(bytes: &[u8]) -> usize; }
Expand description

Base64 encoding trait.

This trait must be imported to make use of any Base64 alphabet defined in this crate.

The following encoding types impl this trait:

Required Methods

Decode a Base64 string into the provided destination buffer.

Decode a Base64 string in-place.

NOTE: this method does not (yet) validate that padding is well-formed, if the given Base64 encoding is padded.

Available on crate feature alloc only.

Decode a Base64 string into a byte vector.

Encode the input byte slice as Base64.

Writes the result into the provided destination slice, returning an ASCII-encoded Base64 string value.

Available on crate feature alloc only.

Encode input byte slice into a String containing Base64.


If input length is greater than usize::MAX/4.

Get the length of Base64 produced by encoding the given bytes.

WARNING: this function will return 0 for lengths greater than usize::MAX/4!