Struct base64_simd::Base64
source · pub struct Base64 { /* private fields */ }
Expand description
Base64 variant
Implementations§
source§impl Base64
impl Base64
sourcepub const fn encoded_length(&self, n: usize) -> usize
pub const fn encoded_length(&self, n: usize) -> usize
sourcepub const fn estimated_decoded_length(&self, n: usize) -> usize
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.
sourcepub fn decoded_length(&self, data: &[u8]) -> Result<usize, Error>
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.
sourcepub fn check(&self, data: &[u8]) -> Result<(), Error>
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.
sourcepub fn encode<'d>(&self, src: &[u8], dst: Out<'d, [u8]>) -> &'d mut [u8] ⓘ
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.
sourcepub fn decode_inplace<'d>(
&self,
data: &'d mut [u8]
) -> Result<&'d mut [u8], Error>
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.
sourcepub fn encode_type<T: FromBase64Encode>(&self, data: impl AsRef<[u8]>) -> T
pub fn encode_type<T: FromBase64Encode>(&self, data: impl AsRef<[u8]>) -> T
Encodes bytes to a base64 string and returns a specified type.
sourcepub fn decode_type<T: FromBase64Decode>(
&self,
data: impl AsRef<[u8]>
) -> Result<T, Error>
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.
sourcepub fn encode_append<T: AppendBase64Encode>(
&self,
src: impl AsRef<[u8]>,
dst: &mut T
)
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.
sourcepub fn decode_append<T: AppendBase64Decode>(
&self,
src: impl AsRef<[u8]>,
dst: &mut T
) -> Result<(), Error>
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.
sourcepub fn encode_to_string(&self, data: impl AsRef<[u8]>) -> String
Available on crate feature alloc
only.
pub fn encode_to_string(&self, data: impl AsRef<[u8]>) -> String
alloc
only.Encodes bytes to a base64 string.