Struct aliri_base64::Base64Url
source · [−]#[repr(transparent)]pub struct Base64Url(_);
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
sourceimpl 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>
Trait Implementations
sourceimpl AsRef<Base64UrlRef> for Base64Url
impl AsRef<Base64UrlRef> for Base64Url
sourcefn as_ref(&self) -> &Base64UrlRef
fn as_ref(&self) -> &Base64UrlRef
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl Borrow<Base64UrlRef> for Base64Url
impl Borrow<Base64UrlRef> for Base64Url
sourcefn borrow(&self) -> &Base64UrlRef
fn borrow(&self) -> &Base64UrlRef
Immutably borrows from an owned value. Read more
sourceimpl Deref for Base64Url
impl Deref for Base64Url
type Target = Base64UrlRef
type Target = Base64UrlRef
The resulting type after dereferencing.
sourceimpl DerefMut for Base64Url
impl DerefMut for Base64Url
sourcefn deref_mut(&mut self) -> &mut Base64UrlRef
fn deref_mut(&mut self) -> &mut Base64UrlRef
Mutably dereferences the value.
sourceimpl<'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
sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<&'_ Base64UrlRef> for Base64Url
impl From<&'_ Base64UrlRef> for Base64Url
sourcefn from(val: &Base64UrlRef) -> Self
fn from(val: &Base64UrlRef) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<Base64Url> for Base64UrlRef
impl PartialEq<Base64Url> for Base64UrlRef
sourceimpl PartialEq<Base64UrlRef> for Base64Url
impl PartialEq<Base64UrlRef> for Base64Url
sourceimpl Serialize for Base64Url
Available on crate feature serde
only.
impl Serialize for Base64Url
serde
only.Serialize the underlying byte array as a base64 string
impl Eq for Base64Url
impl StructuralEq for Base64Url
impl StructuralPartialEq for Base64Url
Auto Trait Implementations
impl RefUnwindSafe for Base64Url
impl Send for Base64Url
impl Sync for Base64Url
impl Unpin for Base64Url
impl UnwindSafe for Base64Url
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more