use crate::{
codec::alphabet::{Alphabet, DecodeStep, EncodeStep},
misc::int_conv::u8i16,
};
use core::range::RangeInclusive;
#[derive(Debug)]
pub(crate) struct Standard;
impl Alphabet for Standard {
const BASE: u8 = b'A';
const DECODER: &'static [DecodeStep] = DECODER;
const ENCODER: &'static [EncodeStep] = ENCODER;
const PAD: Option<u8> = Some(b'=');
}
#[derive(Debug)]
pub(crate) struct StandardNoPad;
impl Alphabet for StandardNoPad {
const BASE: u8 = b'A';
const DECODER: &'static [DecodeStep] = DECODER;
const ENCODER: &'static [EncodeStep] = ENCODER;
const PAD: Option<u8> = None;
}
const DECODER: &[DecodeStep] = &[
DecodeStep::Range(RangeInclusive { start: b'A', last: b'Z' }, -64),
DecodeStep::Range(RangeInclusive { start: b'a', last: b'z' }, -70),
DecodeStep::Range(RangeInclusive { start: b'0', last: 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, -(u8i16(b'+') - 0x1c)),
EncodeStep::Diff(62, u8i16(b'/') - u8i16(b'+') - 1),
];