pub struct Base64Binary { /* private fields */ }Expand description
Base64-encoded byte sequence.
Implementations§
Source§impl Base64Binary
impl Base64Binary
Sourcepub fn encode(iter: impl IntoIterator<Item = u8>) -> Self
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=");Sourcepub fn decode(&self) -> impl Iterator<Item = u8> + '_
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");Sourcepub fn from_encoded(
iter: impl IntoIterator<Item = u8>,
allow_whitespace: bool,
) -> Result<Self, Base64Error>
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
impl Clone for Base64Binary
Source§fn clone(&self) -> Base64Binary
fn clone(&self) -> Base64Binary
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Base64Binary
impl Debug for Base64Binary
Source§impl Display for Base64Binary
impl Display for Base64Binary
Source§impl From<&[u8]> for Base64Binary
impl From<&[u8]> for Base64Binary
Source§impl From<&String> for Base64Binary
impl From<&String> for Base64Binary
Source§impl From<&str> for Base64Binary
impl From<&str> for Base64Binary
Source§impl From<String> for Base64Binary
impl From<String> for Base64Binary
Source§impl FromIterator<u8> for Base64Binary
impl FromIterator<u8> for Base64Binary
Source§impl Hash for Base64Binary
impl Hash for Base64Binary
Source§impl PartialEq for Base64Binary
impl PartialEq for Base64Binary
impl Eq for Base64Binary
impl StructuralPartialEq for Base64Binary
Auto Trait Implementations§
impl Freeze for Base64Binary
impl RefUnwindSafe for Base64Binary
impl Send for Base64Binary
impl Sync for Base64Binary
impl Unpin for Base64Binary
impl UnsafeUnpin for Base64Binary
impl UnwindSafe for Base64Binary
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
Mutably borrows from an owned value. Read more