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: AZ, az, 09, -, _

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

source

pub const fn new() -> Self

Creates an empty buffer

source

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().

source

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().

source

pub fn into_inner(self) -> Vec<u8>

Unwraps the underlying buffer

source

pub fn as_vec(&self) -> &Vec<u8>

Provides access to the underlying buffer as a vector

source

pub fn as_vec_mut(&mut self) -> &mut Vec<u8>

Provides mutable access to the underlying buffer as a vector

source

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>§

source

pub fn encoded_len(&self) -> usize

Calculates the expected length of the base64-encoding of this buffer

source

pub fn as_slice(&self) -> &[u8]

Provides access to the underlying slice

source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Provides mutable access to the underlying slice

Trait Implementations§

source§

impl AsRef<Base64UrlRef> for Base64Url

source§

fn as_ref(&self) -> &Base64UrlRef

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Base64UrlRef> for Base64Url

source§

fn borrow(&self) -> &Base64UrlRef

Immutably borrows from an owned value. Read more
source§

impl Clone for Base64Url

source§

fn clone(&self) -> Base64Url

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Base64Url

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Base64Url

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Deref for Base64Url

§

type Target = Base64UrlRef

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for Base64Url

source§

fn deref_mut(&mut self) -> &mut Base64UrlRef

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for Base64Url

Available on crate feature 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>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Base64Url

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&[u8]> for Base64Url

source§

fn from(slice: &[u8]) -> Self

Converts to this type from the input type.
source§

impl From<&Base64UrlRef> for Base64Url

source§

fn from(val: &Base64UrlRef) -> Self

Converts to this type from the input type.
source§

impl From<Base64Url> for Vec<u8>

source§

fn from(val: Base64Url) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Base64Url

source§

fn from(buf: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl Hash for Base64Url

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Base64Url> for Base64UrlRef

source§

fn eq(&self, other: &Base64Url) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Base64UrlRef> for Base64Url

source§

fn eq(&self, other: &Base64UrlRef) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Base64Url

source§

fn eq(&self, other: &Base64Url) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Base64Url

Available on crate feature serde only.

Serialize the underlying byte array as a base64 string

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Base64Url

source§

impl StructuralPartialEq for Base64Url

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,