Skip to main content

Profile

Struct Profile 

Source
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,

Source

pub const fn new(engine: Engine<A, PAD>, wrap: Option<LineWrap>) -> Self

Creates a profile from an engine and optional strict line wrapping.

Source

pub const fn engine(&self) -> Engine<A, PAD>

Returns the underlying engine.

Source

pub const fn line_wrap(&self) -> Option<LineWrap>

Returns the strict wrapping policy carried by this profile, if any.

Source

pub const fn encoded_len(&self, input_len: usize) -> Result<usize, EncodeError>

Returns the encoded length for this profile.

Source

pub fn decoded_len(&self, input: &[u8]) -> Result<usize, DecodeError>

Returns the exact decoded length for this profile.

Source

pub fn validate_result(&self, input: &[u8]) -> Result<(), DecodeError>

Validates input according to this profile without writing decoded bytes.

Source

pub fn validate(&self, input: &[u8]) -> bool

Returns whether input is valid for this profile.

Source

pub fn encode_slice( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, EncodeError>

Encodes input into output according to this profile.

Source

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.

Source

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.

Source

pub fn decode_slice( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, DecodeError>

Decodes input into output according to this profile.

Source

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.

Source

pub fn encode_vec(&self, input: &[u8]) -> Result<Vec<u8>, EncodeError>

Encodes input into a newly allocated byte vector.

Source

pub fn encode_secret(&self, input: &[u8]) -> Result<SecretBuffer, EncodeError>

Encodes input into a redacted owned secret buffer.

Source

pub fn encode_string(&self, input: &[u8]) -> Result<String, EncodeError>

Encodes input into a newly allocated UTF-8 string.

Source

pub fn decode_vec(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError>

Decodes input into a newly allocated byte vector.

Source

pub fn decode_secret(&self, input: &[u8]) -> Result<SecretBuffer, DecodeError>

Decodes input into a redacted owned secret buffer.

Trait Implementations§

Source§

impl<A: Clone, const PAD: bool> Clone for Profile<A, PAD>

Source§

fn clone(&self) -> Profile<A, PAD>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug, const PAD: bool> Debug for Profile<A, PAD>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: PartialEq, const PAD: bool> PartialEq for Profile<A, PAD>

Source§

fn eq(&self, other: &Profile<A, PAD>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A: Copy, const PAD: bool> Copy for Profile<A, PAD>

Source§

impl<A: Eq, const PAD: bool> Eq for Profile<A, PAD>

Source§

impl<A, const PAD: bool> StructuralPartialEq for Profile<A, PAD>

Auto Trait Implementations§

§

impl<A, const PAD: bool> Freeze for Profile<A, PAD>

§

impl<A, const PAD: bool> RefUnwindSafe for Profile<A, PAD>
where A: RefUnwindSafe,

§

impl<A, const PAD: bool> Send for Profile<A, PAD>
where A: Send,

§

impl<A, const PAD: bool> Sync for Profile<A, PAD>
where A: Sync,

§

impl<A, const PAD: bool> Unpin for Profile<A, PAD>
where A: Unpin,

§

impl<A, const PAD: bool> UnsafeUnpin for Profile<A, PAD>

§

impl<A, const PAD: bool> UnwindSafe for Profile<A, PAD>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.