pub struct Profile<A, const PAD: bool> { /* private fields */ }Expand description
A named Base64 profile with an engine and optional strict line wrapping.
Profiles are convenience values for protocol-shaped Base64. They keep the
same strict alphabet, padding, canonical-bit, and output-buffer rules as
Engine, while carrying the wrapping policy for MIME/PEM-like formats.
Implementations§
Source§impl<A, const PAD: bool> Profile<A, PAD>where
A: Alphabet,
impl<A, const PAD: bool> Profile<A, PAD>where
A: Alphabet,
Sourcepub const fn new(engine: Engine<A, PAD>, wrap: Option<LineWrap>) -> Self
pub const fn new(engine: Engine<A, PAD>, wrap: Option<LineWrap>) -> Self
Creates a profile from an engine and optional strict line wrapping.
Sourcepub const fn line_wrap(&self) -> Option<LineWrap>
pub const fn line_wrap(&self) -> Option<LineWrap>
Returns the strict wrapping policy carried by this profile, if any.
Sourcepub const fn encoded_len(&self, input_len: usize) -> Result<usize, EncodeError>
pub const fn encoded_len(&self, input_len: usize) -> Result<usize, EncodeError>
Returns the encoded length for this profile.
Sourcepub fn decoded_len(&self, input: &[u8]) -> Result<usize, DecodeError>
pub fn decoded_len(&self, input: &[u8]) -> Result<usize, DecodeError>
Returns the exact decoded length for this profile.
Sourcepub fn validate_result(&self, input: &[u8]) -> Result<(), DecodeError>
pub fn validate_result(&self, input: &[u8]) -> Result<(), DecodeError>
Validates input according to this profile without writing decoded bytes.
Sourcepub fn encode_slice(
&self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, EncodeError>
pub fn encode_slice( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, EncodeError>
Encodes input into output according to this profile.
Sourcepub fn encode_slice_clear_tail(
&self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, EncodeError>
pub fn encode_slice_clear_tail( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, EncodeError>
Encodes input into output and clears all bytes after the encoded
prefix.
Sourcepub fn encode_buffer<const CAP: usize>(
&self,
input: &[u8],
) -> Result<EncodedBuffer<CAP>, EncodeError>
pub fn encode_buffer<const CAP: usize>( &self, input: &[u8], ) -> Result<EncodedBuffer<CAP>, EncodeError>
Encodes input into a stack-backed buffer.
This is useful for short values where heap allocation is unnecessary. If encoding fails, the internal backing array is cleared before the error is returned.
Sourcepub fn decode_slice(
&self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, DecodeError>
pub fn decode_slice( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, DecodeError>
Decodes input into output according to this profile.
Sourcepub fn decode_slice_clear_tail(
&self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, DecodeError>
pub fn decode_slice_clear_tail( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, DecodeError>
Decodes input into output and clears all bytes after the decoded
prefix.
Sourcepub fn encode_vec(&self, input: &[u8]) -> Result<Vec<u8>, EncodeError>
pub fn encode_vec(&self, input: &[u8]) -> Result<Vec<u8>, EncodeError>
Encodes input into a newly allocated byte vector.
Sourcepub fn encode_secret(&self, input: &[u8]) -> Result<SecretBuffer, EncodeError>
pub fn encode_secret(&self, input: &[u8]) -> Result<SecretBuffer, EncodeError>
Encodes input into a redacted owned secret buffer.
Sourcepub fn encode_string(&self, input: &[u8]) -> Result<String, EncodeError>
pub fn encode_string(&self, input: &[u8]) -> Result<String, EncodeError>
Encodes input into a newly allocated UTF-8 string.
Sourcepub fn decode_vec(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError>
pub fn decode_vec(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError>
Decodes input into a newly allocated byte vector.
Sourcepub fn decode_secret(&self, input: &[u8]) -> Result<SecretBuffer, DecodeError>
pub fn decode_secret(&self, input: &[u8]) -> Result<SecretBuffer, DecodeError>
Decodes input into a redacted owned secret buffer.