Skip to main content

Base64

Struct Base64 

Source
pub struct Base64<S> { /* private fields */ }
Expand description

A codec value parameterized by one complete sealed specification.

Implementations§

Source§

impl<S: Codec> Base64<S>

Source

pub fn encode_append( &self, input: &[u8], destination: &mut String, ) -> Result<usize, OneShotError>

Appends encoded output to destination transactionally.

The existing prefix and entry length are restored on every returned crate error and during unwinding. Capacity growth is not rolled back, and process-aborting allocation failure is outside this guarantee. Returns the number of appended bytes.

Source

pub fn decode_append( &self, input: &[u8], destination: &mut Vec<u8>, ) -> Result<usize, OneShotError>

Appends decoded output to destination transactionally.

Strict validation and exact sizing precede allocation and mutation. The existing prefix and entry length are restored on every returned crate error and during unwinding. Returns the appended plaintext bytes.

Source§

impl<S: Codec> Base64<S>

Source

pub fn decode_assured<'provider, P, Level>( &self, token: &AssuranceToken<'provider, Level>, allocation: ProtectedSecret<'provider, P, Uninitialized, Level>, input: &SecretInput<'_>, ) -> Result<ProtectedSecret<'provider, P, Validated, Level>, AssuredDecodeError>

Decodes directly through one protected allocation’s typestates.

The allocation is consumed on every path. Safe code cannot observe its bytes until the secret result gate succeeds and returns Validated.

Source

pub fn encode_assured<'provider, P, Level>( &self, token: &AssuranceToken<'provider, Level>, allocation: ProtectedSecret<'provider, P, Uninitialized, Level>, input: &SecretInput<'_>, ) -> Result<ProtectedSecret<'provider, P, Validated, Level>, AssuredEncodeError>

Encodes directly through one protected allocation’s typestates.

Source§

impl<S: Codec> Base64<S>

Source

pub fn encode_bounded<const CAP: usize>( &self, input: &[u8], ) -> Result<EncodedArray<CAP>, OneShotError>

Encodes into a bounded ordinary stack array.

Source

pub fn decode_bounded<const CAP: usize>( &self, input: &[u8], ) -> Result<DecodedArray<CAP>, OneShotError>

Decodes into a bounded ordinary stack array transactionally.

Source§

impl<S: Codec> Base64<S>

Source

pub fn encoded_chunks<'a>( &self, input: &'a [u8], ) -> Result<EncodedChunks<'a>, OneShotError>

Returns a borrowed-input iterator over synthesized encoded chunks.

Length arithmetic is checked before the iterator is returned, so iteration itself has no encoding-error path. Empty input yields no chunks. Padding, when configured, appears only in the final chunk.

Source§

impl Base64<StrictStandardPadded>

Source

pub const fn const_settings(&self) -> CodecSettings

Returns const-capable immutable settings for this codec.

Source

pub const fn encode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Encodes into an array whose length must equal the exact result.

Source

pub const fn decode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Decodes into an array whose length must equal the exact result.

Source§

impl Base64<StrictStandardUnpadded>

Source

pub const fn const_settings(&self) -> CodecSettings

Returns const-capable immutable settings for this codec.

Source

pub const fn encode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Encodes into an array whose length must equal the exact result.

Source

pub const fn decode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Decodes into an array whose length must equal the exact result.

Source§

impl Base64<StrictUrlSafePadded>

Source

pub const fn const_settings(&self) -> CodecSettings

Returns const-capable immutable settings for this codec.

Source

pub const fn encode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Encodes into an array whose length must equal the exact result.

Source

pub const fn decode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Decodes into an array whose length must equal the exact result.

Source§

impl Base64<StrictUrlSafeUnpadded>

Source

pub const fn const_settings(&self) -> CodecSettings

Returns const-capable immutable settings for this codec.

Source

pub const fn encode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Encodes into an array whose length must equal the exact result.

Source

pub const fn decode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Decodes into an array whose length must equal the exact result.

Source§

impl Base64<RuntimeSpec>

Source

pub const fn const_settings(&self) -> CodecSettings

Returns const-capable immutable settings for this runtime codec.

Source

pub const fn encode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Encodes into an array whose length must equal the exact result.

Source

pub const fn decode_array<const INPUT: usize, const OUTPUT: usize>( &self, input: &[u8; INPUT], ) -> Result<[u8; OUTPUT], ConstTransformError>

Decodes into an array whose length must equal the exact result.

Source§

impl<S: Codec> Base64<S>

Source

pub fn display<'a>( &self, input: &'a [u8], ) -> Result<EncodedDisplay<'a>, OneShotError>

Creates a lazy allocation-free display after encoding preflight.

Source

pub fn encode_to_fmt<W: Write + ?Sized>( &self, input: &[u8], writer: &mut W, ) -> Result<usize, FormatWriteError>

Encodes through core::fmt::Write without allocating.

On formatter failure, confirmed progress excludes the failing call because fmt::Write cannot report whether that call partially mutated its sink.

Source

pub fn encode_to_counted<W: CountedSink + ?Sized>( &self, input: &[u8], writer: &mut W, ) -> Result<usize, CountedWriteError<W::Error>>

Encodes through an exact-progress counted sink without allocating.

Source§

impl<S: Codec> Base64<S>

Source

pub fn encode_in_place( &self, buffer: &mut [u8], input_len: usize, ) -> Result<usize, InPlaceError>

Encodes the first input_len bytes into the same buffer in reverse.

Validation and exact capacity checks finish before mutation. Every returned error leaves the complete buffer unchanged. On success, the returned prefix contains the complete encoded value.

Source

pub fn decode_in_place( &self, buffer: &mut [u8], input_len: usize, ) -> Result<usize, InPlaceError>

Decodes the first input_len bytes by compacting forward in place.

Strict validation and exact sizing finish before mutation. Every returned error leaves the complete buffer unchanged. On success, the returned prefix contains the decoded value; bytes after it are residual ordinary storage and have no cleanup guarantee.

Source§

impl<S: Codec> Base64<S>

Source

pub fn encoder(&self) -> EncoderState

Constructs a fresh heapless ordinary encoder.

Source§

impl<S: Codec> Base64<S>

Source

pub fn decoder(&self) -> DecoderState

Constructs a fresh heapless ordinary decoder.

Source§

impl<S: Codec> Base64<S>

Source

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

Returns the exact encoded length or reports arithmetic overflow.

Source

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

Validates ordinary input without producing decoded bytes.

Source

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

Validates input and returns its exact decoded length.

Source

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

Encodes into a caller-owned slice transactionally.

Every returned error leaves the complete destination unchanged. On success, bytes after the returned initialized prefix are unchanged.

Source

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

Decodes into a caller-owned slice transactionally.

Validation and exact sizing complete before the first destination write. Every returned error therefore leaves the destination unchanged.

Source§

impl<S: Codec> Base64<S>

Source

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

Encodes into a newly allocated string.

Allocation uses try_reserve_exact; allocation failure is returned as OneShotError::AllocationFailed. Process-aborting allocators remain outside Rust’s returned-error contract.

Source

pub fn encode_to_string_with_limit( &self, input: &[u8], max_output_len: usize, ) -> Result<String, OneShotError>

Encodes into a string subject to an exact output-byte limit.

Source

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

Decodes into a newly allocated byte vector.

Complete validation and exact sizing happen before allocation. No plaintext is materialized before the full allocation is reserved.

Source

pub fn decode_to_vec_with_limit( &self, input: &[u8], max_output_len: usize, ) -> Result<Vec<u8>, OneShotError>

Decodes into a byte vector subject to an exact output-byte limit.

Source§

impl<S: Codec> Base64<S>

Source

pub fn encode_secret_array<const CAP: usize>( &self, input: &SecretInput<'_>, ) -> Result<SecretArray<CAP>, SecretEncodeError>

Encodes classified input into a bounded wiping array.

Source

pub fn encode_secret_into<'a>( &self, input: &SecretInput<'_>, output: &'a mut [u8], ) -> Result<SecretOutput<'a>, SecretEncodeError>

Encodes classified input into a wiping borrowed output guard.

Source

pub fn encode_secret_vec( &self, input: &SecretInput<'_>, ) -> Result<SecretVec, SecretEncodeError>

Encodes classified input into preallocated wiping heap storage.

Source§

impl<S: Codec> Base64<S>

Source

pub fn secret_decode_staging_len( &self, input_len: usize, ) -> Result<usize, InPlaceError>

Returns the private staging capacity required by secret in-place decode.

The capacity depends only on the public encoded length. It deliberately reserves three candidate bytes for every complete or partial encoded block so padding validity is not inspected during preflight.

Source

pub fn decode_in_place_staged( &self, buffer: &mut [u8], input_len: usize, private_staging: &mut [u8], ) -> Result<usize, InPlaceError>

Decodes a secret-bearing encoded prefix through disjoint private staging.

Preflight errors leave both buffers byte-for-byte unchanged. Every post-preflight input, valid or invalid, receives the same number of alphabet scans for its public length. Invalid input leaves buffer unchanged and wipes all staging. Success copies the staged plaintext into buffer only after the result gate, then wipes all staging.

The complete buffer and private_staging byte ranges must be disjoint. Unsafe callers must validate raw ranges before constructing mutable references; this check cannot repair pre-existing aliased references. Validity and successful release become public after the result gate; the success-only copy is outside the fixed-work claim.

Source§

impl<S: Codec> Base64<S>

Source

pub const fn new(specification: S) -> Self

Constructs a codec from one sealed specification value.

Source

pub const fn specification(&self) -> &S

Returns the owned specification value.

Source

pub fn settings(&self) -> CodecSettings

Returns the codec’s complete validated settings.

Trait Implementations§

Source§

impl<S: Clone> Clone for Base64<S>

Source§

fn clone(&self) -> Base64<S>

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<S: Copy> Copy for Base64<S>

Source§

impl<S: Debug> Debug for Base64<S>

Source§

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

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

impl<S: Eq> Eq for Base64<S>

Source§

impl<S: Hash> Hash for Base64<S>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S: PartialEq> PartialEq for Base64<S>

Source§

fn eq(&self, other: &Base64<S>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<S: PartialEq> StructuralPartialEq for Base64<S>

Auto Trait Implementations§

§

impl<S> Freeze for Base64<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Base64<S>
where S: RefUnwindSafe,

§

impl<S> Send for Base64<S>
where S: Send,

§

impl<S> Sync for Base64<S>
where S: Sync,

§

impl<S> Unpin for Base64<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Base64<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Base64<S>
where S: 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.