Struct base64_simd::Base64

source ·
pub struct Base64 { /* private fields */ }
Expand description

Implementations§

source§

impl Base64

source

pub const STANDARD: Self = _

Standard charset with padding.

source

pub const STANDARD_NO_PAD: Self = _

Standard charset without padding.

source

pub const URL_SAFE: Self = _

URL-safe charset with padding.

source

pub const URL_SAFE_NO_PAD: Self = _

URL-safe charset without padding.

source

pub const fn charset(&self) -> &[u8; 64]

Returns the character set used for encoding.

source

pub const fn encoded_length(&self, n: usize) -> usize

Calculates the encoded length.

Panics

This function panics if any of the conditions below is not satisfied:

  • n <= isize::MAX
source

pub const fn estimated_decoded_length(&self, n: usize) -> usize

Estimates the decoded length.

The result is an upper bound which can be used for allocation.

source

pub fn decoded_length(&self, data: &[u8]) -> Result<usize, Error>

Calculates the decoded length.

The result is a precise value which can be used for allocation.

source

pub fn encode<'s, 'd>( &self, src: &'s [u8], dst: OutBuf<'d, u8> ) -> Result<&'d mut [u8], Error>

Encodes src and writes to dst.

Errors

This function returns Err if:

  • The length of dst is not enough.
source

pub fn encode_as_str<'s, 'd>( &self, src: &'s [u8], dst: OutBuf<'d, u8> ) -> Result<&'d mut str, Error>

Encodes src to dst and returns &mut str.

Errors

This function returns Err if:

  • The length of dst is not enough.
source

pub fn decode<'s, 'd>( &self, src: &'s [u8], dst: OutBuf<'d, u8> ) -> Result<&'d mut [u8], Error>

Decodes src and writes to dst.

Errors

This function returns Err if:

  • The length of dst is not enough.
  • The content of src is invalid.
source

pub fn decode_inplace<'d>( &self, data: &'d mut [u8] ) -> Result<&'d mut [u8], Error>

Decodes data and writes inplace.

Errors

This function returns Err if:

  • The content of data is invalid.
source

pub fn encode_to_boxed_str(&self, data: &[u8]) -> Box<str>

Encodes data and returns Box<str>

Panics

This function panics if:

  • The encoded length of data is greater than isize::MAX
source

pub fn decode_to_boxed_bytes(&self, data: &[u8]) -> Result<Box<[u8]>, Error>

Decodes data and returns Box<[u8]>

Errors

This function returns Err if:

  • The content of data is invalid.
source

pub fn forgiving_decode_inplace(data: &mut [u8]) -> Result<&mut [u8], Error>

Forgiving decodes data and writes inplace.

See https://infra.spec.whatwg.org/#forgiving-base64

Trait Implementations§

source§

impl Debug for Base64

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.