pub struct Alphabet { /* private fields */ }
Expand description
An alphabet defines the 64 ASCII characters (symbols) used for base64.
Common alphabets are provided as constants, and custom alphabets
can be made via from_str
or the TryFrom<str>
implementation.
Examples
Building and using a custom Alphabet:
let custom = base64::alphabet::Alphabet::new("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").unwrap();
let engine = base64::engine::GeneralPurpose::new(
&custom,
base64::engine::general_purpose::PAD);
Building a const:
use base64::alphabet::Alphabet;
static CUSTOM: Alphabet = {
// Result::unwrap() isn't const yet, but panic!() is OK
match Alphabet::new("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") {
Ok(x) => x,
Err(_) => panic!("creation of alphabet failed"),
}
};
Building a lazy_static:
use base64::{
alphabet::Alphabet,
engine::{general_purpose::GeneralPurpose, GeneralPurposeConfig},
};
lazy_static::lazy_static! {
static ref CUSTOM: Alphabet = Alphabet::new("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").unwrap();
}
Implementations§
Trait Implementations§
source§impl PartialEq<Alphabet> for Alphabet
impl PartialEq<Alphabet> for Alphabet
impl Eq for Alphabet
impl StructuralEq for Alphabet
impl StructuralPartialEq for Alphabet
Auto Trait Implementations§
impl RefUnwindSafe for Alphabet
impl Send for Alphabet
impl Sync for Alphabet
impl Unpin for Alphabet
impl UnwindSafe for Alphabet
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