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.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 2 bytes