Struct aliri_base64::Base64Url
source · pub struct Base64Url(/* private fields */);
Expand description
Owned data to be encoded as URL-safe base64 (no padding)
Encoding alphabet: A
–Z
, a
–z
, 0
–9
, -
, _
Data is held in memory in its raw form. Costs of serialization are only incurred when serializing or displaying the value in its base64 representation.
Implementations of the From
trait assume that assume that the
underlying structure is in raw form.
Implementations§
source§impl Base64Url
impl Base64Url
sourcepub fn from_raw<T: Into<Vec<u8>>>(raw: T) -> Self
pub fn from_raw<T: Into<Vec<u8>>>(raw: T) -> Self
Creates a new buffer from an owned value
This function has no cost for Vec<u8>
. Other types incur
the cost of copying into a buffer.
To decode a base64-encoded buffer, use from_encoded()
.
sourcepub fn from_encoded<T: AsRef<[u8]>>(enc: T) -> Result<Self, InvalidBase64Data>
pub fn from_encoded<T: AsRef<[u8]>>(enc: T) -> Result<Self, InvalidBase64Data>
Constructs a new buffer from a base64-encoded slice
This function will decode the slice into a new owned buffer.
If the underlying buffer has already been decoded, then
transparently wrap the buffer using from_raw()
.
sourcepub fn into_inner(self) -> Vec<u8>
pub fn into_inner(self) -> Vec<u8>
Unwraps the underlying buffer
sourcepub fn as_vec_mut(&mut self) -> &mut Vec<u8>
pub fn as_vec_mut(&mut self) -> &mut Vec<u8>
Provides mutable access to the underlying buffer as a vector
sourcepub const fn calc_encoded_len(len: usize) -> usize
pub const fn calc_encoded_len(len: usize) -> usize
Calculates the expected length of the base64-encoding for a buffer of size len
Methods from Deref<Target = Base64UrlRef>§
sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Calculates the expected length of the base64-encoding of this buffer
sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Provides mutable access to the underlying slice
Trait Implementations§
source§impl AsRef<Base64UrlRef> for Base64Url
impl AsRef<Base64UrlRef> for Base64Url
source§fn as_ref(&self) -> &Base64UrlRef
fn as_ref(&self) -> &Base64UrlRef
source§impl Borrow<Base64UrlRef> for Base64Url
impl Borrow<Base64UrlRef> for Base64Url
source§fn borrow(&self) -> &Base64UrlRef
fn borrow(&self) -> &Base64UrlRef
source§impl DerefMut for Base64Url
impl DerefMut for Base64Url
source§fn deref_mut(&mut self) -> &mut Base64UrlRef
fn deref_mut(&mut self) -> &mut Base64UrlRef
source§impl<'de> Deserialize<'de> for Base64Url
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for Base64Url
serde
only.Deserialize a base64 string and decode it into a byte array
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
source§impl From<&Base64UrlRef> for Base64Url
impl From<&Base64UrlRef> for Base64Url
source§fn from(val: &Base64UrlRef) -> Self
fn from(val: &Base64UrlRef) -> Self
source§impl PartialEq<Base64Url> for Base64UrlRef
impl PartialEq<Base64Url> for Base64UrlRef
source§impl PartialEq<Base64UrlRef> for Base64Url
impl PartialEq<Base64UrlRef> for Base64Url
source§fn eq(&self, other: &Base64UrlRef) -> bool
fn eq(&self, other: &Base64UrlRef) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq for Base64Url
impl PartialEq for Base64Url
source§impl Serialize for Base64Url
Available on crate feature serde
only.
impl Serialize for Base64Url
serde
only.Serialize the underlying byte array as a base64 string