Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/base64ct/src/alphabet/standard.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / base64ct / src / alphabet / standard.rs` 54 lines ยท 1543 bytes Raw Blame History 1 //! Standard Base64 encoding. 2 3 use super::{Alphabet, DecodeStep, EncodeStep}; 4 5 /// Standard Base64 encoding with `=` padding. 6 /// 7 /// ```text 8 /// [A-Z] [a-z] [0-9] + / 9 /// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f 10 /// ``` 11 #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] 12 pub struct Base64; 13 14 impl Alphabet for Base64 { 15 const BASE: u8 = b'A'; 16 const DECODER: &'static [DecodeStep] = DECODER; 17 const ENCODER: &'static [EncodeStep] = ENCODER; 18 const PADDED: bool = true; 19 type Unpadded = Base64Unpadded; 20 } 21 22 /// Standard Base64 encoding *without* padding. 23 /// 24 /// ```text 25 /// [A-Z] [a-z] [0-9] + / 26 /// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f 27 /// ``` 28 #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] 29 pub struct Base64Unpadded; 30 31 impl Alphabet for Base64Unpadded { 32 const BASE: u8 = b'A'; 33 const DECODER: &'static [DecodeStep] = DECODER; 34 const ENCODER: &'static [EncodeStep] = ENCODER; 35 const PADDED: bool = false; 36 type Unpadded = Self; 37 } 38 39 /// Standard Base64 decoder 40 const DECODER: &[DecodeStep] = &[ 41 DecodeStep::Range(b'A'..=b'Z', -64), 42 DecodeStep::Range(b'a'..=b'z', -70), 43 DecodeStep::Range(b'0'..=b'9', 5), 44 DecodeStep::Eq(b'+', 63), 45 DecodeStep::Eq(b'/', 64), 46 ]; 47 48 /// Standard Base64 encoder 49 const ENCODER: &[EncodeStep] = &[ 50 EncodeStep::Diff(25, 6), 51 EncodeStep::Diff(51, -75), 52 EncodeStep::Diff(61, -(b'+' as i16 - 0x1c)), 53 EncodeStep::Diff(62, b'/' as i16 - b'+' as i16 - 1), 54 ];