Skip to main content

Base64Binary

Struct Base64Binary 

Source
pub struct Base64Binary { /* private fields */ }
Expand description

Base64-encoded byte sequence.

Implementations§

Source§

impl Base64Binary

Source

pub fn encode(iter: impl IntoIterator<Item = u8>) -> Self

Encode a binary sequence to Base64 binary.

§Example
use anyxml_base64::Base64Binary;

let encoded = Base64Binary::encode("Hello".bytes());
assert_eq!(encoded.to_string(), "SGVsbG8=");
Source

pub fn decode(&self) -> impl Iterator<Item = u8> + '_

Decode the Base64 binary back into the original binary sequence.

§Example
use anyxml_base64::Base64Binary;

let encoded = Base64Binary::from_encoded(*b"SGVsbG8=", false).unwrap();
let decoded = encoded.decode().map(|b| b as char).collect::<String>();
assert_eq!(decoded, "Hello");
Source

pub fn from_encoded( iter: impl IntoIterator<Item = u8>, allow_whitespace: bool, ) -> Result<Self, Base64Error>

Construct a Base64Binary from a Base64-encoded byte sequence.

When allow_whitespace is true, bytes for which u8::is_ascii_whitespace returns true are ignored during byte sequence validation.

Returns an error if the iter is invalid as a Base64 byte sequence.

Trait Implementations§

Source§

impl Clone for Base64Binary

Source§

fn clone(&self) -> Base64Binary

Returns a duplicate 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 Base64Binary

Source§

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

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

impl Display for Base64Binary

Source§

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

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

impl From<&[u8]> for Base64Binary

Source§

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

Converts to this type from the input type.
Source§

impl From<&Arc<[u8]>> for Base64Binary

Source§

fn from(value: &Arc<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<&Arc<str>> for Base64Binary

Source§

fn from(value: &Arc<str>) -> Self

Converts to this type from the input type.
Source§

impl From<&Box<[u8]>> for Base64Binary

Source§

fn from(value: &Box<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<&Box<str>> for Base64Binary

Source§

fn from(value: &Box<str>) -> Self

Converts to this type from the input type.
Source§

impl From<&Cow<'_, [u8]>> for Base64Binary

Source§

fn from(value: &Cow<'_, [u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<&Cow<'_, str>> for Base64Binary

Source§

fn from(value: &Cow<'_, str>) -> Self

Converts to this type from the input type.
Source§

impl From<&Rc<[u8]>> for Base64Binary

Source§

fn from(value: &Rc<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<&Rc<str>> for Base64Binary

Source§

fn from(value: &Rc<str>) -> Self

Converts to this type from the input type.
Source§

impl From<&String> for Base64Binary

Source§

fn from(value: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&Vec<u8>> for Base64Binary

Source§

fn from(value: &Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Base64Binary

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Arc<[u8]>> for Base64Binary

Source§

fn from(value: Arc<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Arc<str>> for Base64Binary

Source§

fn from(value: Arc<str>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<[u8]>> for Base64Binary

Source§

fn from(value: Box<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<str>> for Base64Binary

Source§

fn from(value: Box<str>) -> Self

Converts to this type from the input type.
Source§

impl From<Cow<'_, [u8]>> for Base64Binary

Source§

fn from(value: Cow<'_, [u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Cow<'_, str>> for Base64Binary

Source§

fn from(value: Cow<'_, str>) -> Self

Converts to this type from the input type.
Source§

impl From<Rc<[u8]>> for Base64Binary

Source§

fn from(value: Rc<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Rc<str>> for Base64Binary

Source§

fn from(value: Rc<str>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Base64Binary

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Base64Binary

Source§

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

Converts to this type from the input type.
Source§

impl FromIterator<u8> for Base64Binary

Source§

fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Base64Binary

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 for Base64Binary

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Base64Binary

Source§

impl StructuralPartialEq for Base64Binary

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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§

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

Source§

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

Source§

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.