base64_simd

Struct Base64

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

Base64 variant

Implementations§

Source§

impl Base64

Source

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

Returns the character set.

Source

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

Calculates the encoded length.

§Panics

This function will panic if 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.

§Errors

This function returns Err if the content of data is partially invalid.

Source

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

Checks whether data is a base64 string.

§Errors

This function returns Err if the content of data is invalid.

Source

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

Encodes bytes to a base64 string.

§Panics

This function will panic if the length of dst is not enough.

Source

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

Encodes bytes to a base64 string and returns &mut str.

§Panics

This function will panic if the length of dst is not enough.

Source

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

Decodes a base64 string to bytes.

§Errors

This function returns Err if the content of src is invalid.

§Panics

This function will panic if the length of dst is not enough.

Source

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

Decodes a base64 string to bytes and writes inplace.

§Errors

This function returns Err if the content of data is invalid.

Source

pub fn encode_type<T: FromBase64Encode>(&self, data: impl AsRef<[u8]>) -> T

Encodes bytes to a base64 string and returns a specified type.

Source

pub fn decode_type<T: FromBase64Decode>( &self, data: impl AsRef<[u8]>, ) -> Result<T, Error>

Decodes a base64 string to bytes and returns a specified type.

§Errors

This function returns Err if the content of data is invalid.

Source

pub fn encode_append<T: AppendBase64Encode>( &self, src: impl AsRef<[u8]>, dst: &mut T, )

Encodes bytes to a base64 string and appends to a specified type.

Source

pub fn decode_append<T: AppendBase64Decode>( &self, src: impl AsRef<[u8]>, dst: &mut T, ) -> Result<(), Error>

Decodes a base64 string to bytes and appends to a specified type.

§Errors

This function returns Err if the content of src is invalid.

Source

pub fn encode_to_string(&self, data: impl AsRef<[u8]>) -> String

Encodes bytes to a base64 string.

Source

pub fn decode_to_vec(&self, data: impl AsRef<[u8]>) -> Result<Vec<u8>, Error>

Decodes a base64 string to bytes.

§Errors

This function returns Err if the content of data is invalid.

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§

§

impl Freeze for Base64

§

impl RefUnwindSafe for Base64

§

impl Send for Base64

§

impl Sync for Base64

§

impl Unpin for Base64

§

impl UnwindSafe for Base64

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