1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use super::{Decode, Encode, Variant};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Base64;
impl Variant for Base64 {
type Unpadded = Base64Unpadded;
const PADDED: bool = true;
const BASE: u8 = b'A';
const DECODER: &'static [Decode] = DECODER;
const ENCODER: &'static [Encode] = ENCODER;
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Base64Unpadded;
impl Variant for Base64Unpadded {
type Unpadded = Self;
const PADDED: bool = false;
const BASE: u8 = b'A';
const DECODER: &'static [Decode] = DECODER;
const ENCODER: &'static [Encode] = ENCODER;
}
const DECODER: &[Decode] = &[
Decode::Range(b'A'..b'Z', -64),
Decode::Range(b'a'..b'z', -70),
Decode::Range(b'0'..b'9', 5),
Decode::Eq(b'+', 63),
Decode::Eq(b'/', 64),
];
const ENCODER: &[Encode] = &[
Encode::Diff(25, 6),
Encode::Diff(51, -75),
Encode::Diff(61, -(b'+' as i16 - 0x1c)),
Encode::Diff(62, b'/' as i16 - b'+' as i16 - 1),
];