base64ct/alphabet/
standard.rsuse super::{Alphabet, DecodeStep, EncodeStep};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Base64;
impl Alphabet for Base64 {
const BASE: u8 = b'A';
const DECODER: &'static [DecodeStep] = DECODER;
const ENCODER: &'static [EncodeStep] = ENCODER;
const PADDED: bool = true;
type Unpadded = Base64Unpadded;
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Base64Unpadded;
impl Alphabet for Base64Unpadded {
const BASE: u8 = b'A';
const DECODER: &'static [DecodeStep] = DECODER;
const ENCODER: &'static [EncodeStep] = ENCODER;
const PADDED: bool = false;
type Unpadded = Self;
}
const DECODER: &[DecodeStep] = &[
DecodeStep::Range(b'A'..=b'Z', -64),
DecodeStep::Range(b'a'..=b'z', -70),
DecodeStep::Range(b'0'..=b'9', 5),
DecodeStep::Eq(b'+', 63),
DecodeStep::Eq(b'/', 64),
];
const ENCODER: &[EncodeStep] = &[
EncodeStep::Diff(25, 6),
EncodeStep::Diff(51, -75),
EncodeStep::Diff(61, -(b'+' as i16 - 0x1c)),
EncodeStep::Diff(62, b'/' as i16 - b'+' as i16 - 1),
];