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
pub fn encode_to_string(&self, data: impl AsRef<[u8]>) -> String
Encodes bytes to a base64 string.