[−][src]Trait radix64::Config
Config represents a base64 configuration.
Each Config provides methods to encode and decode according to the configuration. This trait is sealed and not intended to be implemented outside of this crate. Custom configurations can be defined using CustomConfig.
Provided methods
fn encode<I: ?Sized>(self, input: &I) -> String where
I: AsRef<[u8]>,
I: AsRef<[u8]>,
Encode the provided input into a String.
fn encode_with_buffer<'i, 'b, I: ?Sized>(
self,
input: &'i I,
buffer: &'b mut Vec<u8>
) -> &'b str where
I: AsRef<[u8]>,
self,
input: &'i I,
buffer: &'b mut Vec<u8>
) -> &'b str where
I: AsRef<[u8]>,
Encode the provided input into the provided buffer, returning a &str of the encoded input. The returned &str is a view into the beginning of the provided buffer that contains the encoded data. This method overwrites the data in the buffer, it does not append to the buffer. This method exists to provide an efficient way to amortize allocations when repeatedly encoding different inputs. The same buffer can be provided for each invocation and will only be resized when necessary. Any data in the buffer outside the range of the returned &str is not part of the encoded output and should be ignored.
fn encode_slice<I: ?Sized>(self, input: &I, output: &mut [u8]) -> usize where
I: AsRef<[u8]>,
I: AsRef<[u8]>,
Encode the provided input into the provided output slice. The slice must
be large enough to contain the encoded output and panics if it's not.
Use input.len() * 4 / 3 + 3
as a conservative estimate. It returns the
number of bytes of encoded output written to the output slice. This
method allows for the most control over memory placement, but
encode_with_buffer
is typically more ergonomic and just as performant.
fn decode<I: ?Sized>(self, input: &I) -> Result<Vec<u8>, DecodeError> where
I: AsRef<[u8]>,
I: AsRef<[u8]>,
Decode the provided input.
fn decode_with_buffer<'i, 'b, I: ?Sized>(
self,
input: &'i I,
buffer: &'b mut Vec<u8>
) -> Result<&'b [u8], DecodeError> where
I: AsRef<[u8]>,
self,
input: &'i I,
buffer: &'b mut Vec<u8>
) -> Result<&'b [u8], DecodeError> where
I: AsRef<[u8]>,
Decode the provided input into the provided buffer, returning a &u8 of the decoded input. The returned &u8 is a view into the beginning of the provided buffer that contains the decoded data. This method overwrites the data in the buffer, it does not append to the buffer. This method exists to provide an efficient way to amortize allocations when repeatedly decoding different inputs. The same buffer can be provided for each invocation and will only be resized when necessary. Any data in the buffer outside the range of the returned &u8 is not part of the decoded output and should be ignored.
fn decode_slice<I: ?Sized>(
self,
input: &I,
output: &mut [u8]
) -> Result<usize, DecodeError> where
I: AsRef<[u8]>,
self,
input: &I,
output: &mut [u8]
) -> Result<usize, DecodeError> where
I: AsRef<[u8]>,
Decode the provided input into the provided output slice. The slice must
be large enough to contain the decoded output and panics if it's not. Use
input.len() * 6 / 8 + 1
as a conservative estimate. It returns the
number of bytes of decoded output written to the output slice. This
method allows for the most control over memory placement, but
decode_with_buffer
is typically more ergonomic and just as performant.