pub struct Base64<S> { /* private fields */ }Expand description
A codec value parameterized by one complete sealed specification.
Implementations§
Source§impl<S: Codec> Base64<S>
impl<S: Codec> Base64<S>
Sourcepub fn encode_append(
&self,
input: &[u8],
destination: &mut String,
) -> Result<usize, OneShotError>
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.
Sourcepub fn decode_append(
&self,
input: &[u8],
destination: &mut Vec<u8>,
) -> Result<usize, OneShotError>
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>
impl<S: Codec> Base64<S>
Sourcepub 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>where
P: ProtectedMemoryProvider,
Level: AssuranceLevel,
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>where
P: ProtectedMemoryProvider,
Level: AssuranceLevel,
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.
Sourcepub 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>where
P: ProtectedMemoryProvider,
Level: AssuranceLevel,
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>where
P: ProtectedMemoryProvider,
Level: AssuranceLevel,
Encodes directly through one protected allocation’s typestates.
Source§impl<S: Codec> Base64<S>
impl<S: Codec> Base64<S>
Sourcepub fn encode_bounded<const CAP: usize>(
&self,
input: &[u8],
) -> Result<EncodedArray<CAP>, OneShotError>
pub fn encode_bounded<const CAP: usize>( &self, input: &[u8], ) -> Result<EncodedArray<CAP>, OneShotError>
Encodes into a bounded ordinary stack array.
Sourcepub fn decode_bounded<const CAP: usize>(
&self,
input: &[u8],
) -> Result<DecodedArray<CAP>, OneShotError>
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>
impl<S: Codec> Base64<S>
Sourcepub fn encoded_chunks<'a>(
&self,
input: &'a [u8],
) -> Result<EncodedChunks<'a>, OneShotError>
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>
impl Base64<StrictStandardPadded>
Sourcepub const fn const_settings(&self) -> CodecSettings
pub const fn const_settings(&self) -> CodecSettings
Returns const-capable immutable settings for this codec.
Sourcepub const fn encode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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.
Sourcepub const fn decode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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>
impl Base64<StrictStandardUnpadded>
Sourcepub const fn const_settings(&self) -> CodecSettings
pub const fn const_settings(&self) -> CodecSettings
Returns const-capable immutable settings for this codec.
Sourcepub const fn encode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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.
Sourcepub const fn decode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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>
impl Base64<StrictUrlSafePadded>
Sourcepub const fn const_settings(&self) -> CodecSettings
pub const fn const_settings(&self) -> CodecSettings
Returns const-capable immutable settings for this codec.
Sourcepub const fn encode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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.
Sourcepub const fn decode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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>
impl Base64<StrictUrlSafeUnpadded>
Sourcepub const fn const_settings(&self) -> CodecSettings
pub const fn const_settings(&self) -> CodecSettings
Returns const-capable immutable settings for this codec.
Sourcepub const fn encode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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.
Sourcepub const fn decode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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>
impl Base64<RuntimeSpec>
Sourcepub const fn const_settings(&self) -> CodecSettings
pub const fn const_settings(&self) -> CodecSettings
Returns const-capable immutable settings for this runtime codec.
Sourcepub const fn encode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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.
Sourcepub const fn decode_array<const INPUT: usize, const OUTPUT: usize>(
&self,
input: &[u8; INPUT],
) -> Result<[u8; OUTPUT], ConstTransformError>
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>
impl<S: Codec> Base64<S>
Sourcepub fn display<'a>(
&self,
input: &'a [u8],
) -> Result<EncodedDisplay<'a>, OneShotError>
pub fn display<'a>( &self, input: &'a [u8], ) -> Result<EncodedDisplay<'a>, OneShotError>
Creates a lazy allocation-free display after encoding preflight.
Sourcepub fn encode_to_fmt<W: Write + ?Sized>(
&self,
input: &[u8],
writer: &mut W,
) -> Result<usize, FormatWriteError>
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.
Sourcepub fn encode_to_counted<W: CountedSink + ?Sized>(
&self,
input: &[u8],
writer: &mut W,
) -> Result<usize, CountedWriteError<W::Error>>
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>
impl<S: Codec> Base64<S>
Sourcepub fn encode_in_place(
&self,
buffer: &mut [u8],
input_len: usize,
) -> Result<usize, InPlaceError>
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.
Sourcepub fn decode_in_place(
&self,
buffer: &mut [u8],
input_len: usize,
) -> Result<usize, InPlaceError>
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>
impl<S: Codec> Base64<S>
Sourcepub fn encoder(&self) -> EncoderState
pub fn encoder(&self) -> EncoderState
Constructs a fresh heapless ordinary encoder.
Source§impl<S: Codec> Base64<S>
impl<S: Codec> Base64<S>
Sourcepub fn decoder(&self) -> DecoderState
pub fn decoder(&self) -> DecoderState
Constructs a fresh heapless ordinary decoder.
Source§impl<S: Codec> Base64<S>
impl<S: Codec> Base64<S>
Sourcepub fn encoded_len(&self, input_len: usize) -> Result<usize, OneShotError>
pub fn encoded_len(&self, input_len: usize) -> Result<usize, OneShotError>
Returns the exact encoded length or reports arithmetic overflow.
Sourcepub fn validate(&self, input: &[u8]) -> Result<(), OneShotError>
pub fn validate(&self, input: &[u8]) -> Result<(), OneShotError>
Validates ordinary input without producing decoded bytes.
Sourcepub fn decoded_len(&self, input: &[u8]) -> Result<usize, OneShotError>
pub fn decoded_len(&self, input: &[u8]) -> Result<usize, OneShotError>
Validates input and returns its exact decoded length.
Sourcepub fn encode_into(
&self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, OneShotError>
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.
Sourcepub fn decode_into(
&self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, OneShotError>
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>
impl<S: Codec> Base64<S>
Sourcepub fn encode_to_string(&self, input: &[u8]) -> Result<String, OneShotError>
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.
Sourcepub fn encode_to_string_with_limit(
&self,
input: &[u8],
max_output_len: usize,
) -> Result<String, OneShotError>
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.
Sourcepub fn decode_to_vec(&self, input: &[u8]) -> Result<Vec<u8>, OneShotError>
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.
Sourcepub fn decode_to_vec_with_limit(
&self,
input: &[u8],
max_output_len: usize,
) -> Result<Vec<u8>, OneShotError>
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>
impl<S: Codec> Base64<S>
Sourcepub fn encode_secret_array<const CAP: usize>(
&self,
input: &SecretInput<'_>,
) -> Result<SecretArray<CAP>, SecretEncodeError>
pub fn encode_secret_array<const CAP: usize>( &self, input: &SecretInput<'_>, ) -> Result<SecretArray<CAP>, SecretEncodeError>
Encodes classified input into a bounded wiping array.
Sourcepub fn encode_secret_into<'a>(
&self,
input: &SecretInput<'_>,
output: &'a mut [u8],
) -> Result<SecretOutput<'a>, SecretEncodeError>
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.
Sourcepub fn encode_secret_vec(
&self,
input: &SecretInput<'_>,
) -> Result<SecretVec, SecretEncodeError>
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>
impl<S: Codec> Base64<S>
Sourcepub fn secret_decode_staging_len(
&self,
input_len: usize,
) -> Result<usize, InPlaceError>
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.
Sourcepub fn decode_in_place_staged(
&self,
buffer: &mut [u8],
input_len: usize,
private_staging: &mut [u8],
) -> Result<usize, InPlaceError>
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>
impl<S: Codec> Base64<S>
Sourcepub const fn new(specification: S) -> Self
pub const fn new(specification: S) -> Self
Constructs a codec from one sealed specification value.
Sourcepub const fn specification(&self) -> &S
pub const fn specification(&self) -> &S
Returns the owned specification value.
Sourcepub fn settings(&self) -> CodecSettings
pub fn settings(&self) -> CodecSettings
Returns the codec’s complete validated settings.