1#![doc = include_str!("../README.md")]
3#![no_std]
4#![cfg_attr(docsrs, feature(doc_auto_cfg))]
5
6#[cfg(feature = "alloc")]
7extern crate alloc;
8#[cfg(feature = "std")]
9extern crate std;
10
11#[cfg(feature = "alloc")]
12use alloc::borrow::{Cow, ToOwned};
13#[cfg(feature = "alloc")]
14use alloc::string::String;
15#[cfg(feature = "alloc")]
16use alloc::vec;
17#[cfg(feature = "alloc")]
18use alloc::vec::Vec;
19use core::convert::TryInto;
20use core::marker::PhantomData;
21use core::mem::MaybeUninit;
22
23macro_rules! check {
24 ($e: expr, $c: expr) => {
25 if !$c {
26 return Err($e);
27 }
28 };
29}
30
31pub trait BitWidth: sealed::BitWidth {}
33
34pub trait Bool: sealed::Bool {}
36
37mod sealed {
38 pub trait BitWidth {
39 const VAL: usize;
40 }
41
42 pub trait Bool {
43 type If<Then: Copy, Else: Copy>: Copy;
44 const VAL: bool;
45 fn open<Then: Copy, Else: Copy>(cond: Self::If<Then, Else>) -> If<Then, Else>;
46 fn make<Then: Copy, Else: Copy>(
47 then: impl FnOnce() -> Then, else_: impl FnOnce() -> Else,
48 ) -> Self::If<Then, Else>;
49 }
50
51 #[derive(Debug, Copy, Clone)]
52 pub enum If<Then, Else> {
53 Then(Then),
54 Else(Else),
55 }
56}
57use sealed::If;
58
59macro_rules! new_bit_width {
60 ($(($N:ident, $v:expr, $b:literal),)*) => {
61 $(
62 #[doc = concat!(" Bit-width of ", $b, " encodings.")]
63 #[derive(Debug)]
64 pub enum $N {}
65 impl BitWidth for $N {}
66 impl sealed::BitWidth for $N { const VAL: usize = $v; }
67 )*
68 };
69}
70new_bit_width![
71 (Bit1, 1, "base2"),
72 (Bit2, 2, "base4"),
73 (Bit3, 3, "base8"),
74 (Bit4, 4, "base16"),
75 (Bit5, 5, "base32"),
76 (Bit6, 6, "base64"),
77];
78
79#[derive(Debug)]
81pub enum False {}
82impl Bool for False {}
83impl sealed::Bool for False {
84 type If<Then: Copy, Else: Copy> = Else;
85 const VAL: bool = false;
86 fn open<Then: Copy, Else: Copy>(cond: Self::If<Then, Else>) -> If<Then, Else> {
87 If::Else(cond)
88 }
89 fn make<Then: Copy, Else: Copy>(
90 _then: impl FnOnce() -> Then, else_: impl FnOnce() -> Else,
91 ) -> Self::If<Then, Else> {
92 else_()
93 }
94}
95
96#[derive(Debug, Copy, Clone)]
98pub enum True {}
99impl Bool for True {}
100impl sealed::Bool for True {
101 type If<Then: Copy, Else: Copy> = Then;
102 const VAL: bool = true;
103 fn open<Then: Copy, Else: Copy>(cond: Self::If<Then, Else>) -> If<Then, Else> {
104 If::Then(cond)
105 }
106 fn make<Then: Copy, Else: Copy>(
107 then: impl FnOnce() -> Then, _else: impl FnOnce() -> Else,
108 ) -> Self::If<Then, Else> {
109 then()
110 }
111}
112
113unsafe fn cast<Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool>(
114 base: &DynEncoding,
115) -> &Encoding<Bit, Msb, Pad, Wrap, Ignore> {
116 let ptr = core::ptr::from_ref(base).cast::<Encoding<Bit, Msb, Pad, Wrap, Ignore>>();
117 unsafe { &*ptr }
118}
119
120macro_rules! dispatch {
121 ($dyn:ident $($body: tt)*) => {
122 dispatch!([] Bit $dyn $($body)*)
123 };
124 ([] Bit $dyn:ident $($body:tt)*) => {
125 match $dyn.bit() {
126 1 => dispatch!([Bit1] Msb $dyn $($body)*),
127 2 => dispatch!([Bit2] Msb $dyn $($body)*),
128 3 => dispatch!([Bit3] Msb $dyn $($body)*),
129 4 => dispatch!([Bit4] Msb $dyn $($body)*),
130 5 => dispatch!([Bit5] Msb $dyn $($body)*),
131 6 => dispatch!([Bit6] Msb $dyn $($body)*),
132 _ => unreachable!(),
133 }
134 };
135 ([$($gen:ty),*] Msb $dyn:ident $($body:tt)*) => {
136 match $dyn.msb() {
137 false => dispatch!([$($gen),*, False] Pad $dyn $($body)*),
138 true => dispatch!([$($gen),*, True] Pad $dyn $($body)*),
139 }
140 };
141 ([$($gen:ty),*] Pad $dyn:ident $($body:tt)*) => {
142 match $dyn.pad().is_some() {
143 false => dispatch!([$($gen),*, False] Wrap $dyn $($body)*),
144 true => dispatch!([$($gen),*, True] Wrap $dyn $($body)*),
145 }
146 };
147 ([$($gen:ty),*] Wrap $dyn:ident $($body:tt)*) => {
148 match $dyn.wrap().is_some() {
149 false => dispatch!([$($gen),*, False] Ignore $dyn $($body)*),
150 true => dispatch!([$($gen),*, True] Ignore $dyn $($body)*),
151 }
152 };
153 ([$($gen:ty),*] Ignore $dyn:ident $($body:tt)*) => {
154 match $dyn.has_ignore() {
155 false => dispatch!({ $($gen),*, False } $dyn $($body)*),
156 true => dispatch!({ $($gen),*, True } $dyn $($body)*),
157 }
158 };
159 ({ $($gen:ty),* } $dyn:ident $($body:tt)*) => {
160 unsafe { cast::<$($gen),*>($dyn) } $($body)*
161 };
162}
163
164unsafe fn chunk_unchecked<T>(x: &[T], n: usize, i: usize) -> &[T] {
165 debug_assert!((i + 1) * n <= x.len());
166 unsafe { core::slice::from_raw_parts(x.as_ptr().add(n * i), n) }
167}
168
169unsafe fn chunk_mut_unchecked<T>(x: &mut [T], n: usize, i: usize) -> &mut [T] {
170 debug_assert!((i + 1) * n <= x.len());
171 unsafe { core::slice::from_raw_parts_mut(x.as_mut_ptr().add(n * i), n) }
172}
173
174unsafe fn copy_from_slice(dst: &mut [MaybeUninit<u8>], src: &[u8]) {
176 dst.copy_from_slice(unsafe { &*(core::ptr::from_ref(src) as *const [MaybeUninit<u8>]) });
177}
178
179unsafe fn slice_assume_init_mut(xs: &mut [MaybeUninit<u8>]) -> &mut [u8] {
181 unsafe { &mut *(core::ptr::from_mut(xs) as *mut [u8]) }
182}
183
184unsafe fn slice_uninit_mut(xs: &mut [u8]) -> &mut [MaybeUninit<u8>] {
185 unsafe { &mut *(core::ptr::from_mut(xs) as *mut [MaybeUninit<u8>]) }
186}
187
188#[cfg(feature = "alloc")]
189fn reserve_spare(xs: &mut Vec<u8>, n: usize) -> &mut [MaybeUninit<u8>] {
190 xs.reserve(n);
191 &mut xs.spare_capacity_mut()[.. n]
192}
193
194fn floor(x: usize, m: usize) -> usize {
195 x / m * m
196}
197
198#[inline]
199fn vectorize<F: FnMut(usize)>(n: usize, bs: usize, mut f: F) {
200 for k in 0 .. n / bs {
201 for i in k * bs .. (k + 1) * bs {
202 f(i);
203 }
204 }
205 for i in floor(n, bs) .. n {
206 f(i);
207 }
208}
209
210#[derive(Debug, Copy, Clone, PartialEq, Eq)]
212pub enum DecodeKind {
213 Length,
215
216 Symbol,
218
219 Trailing,
221
222 Padding,
224}
225
226impl core::fmt::Display for DecodeKind {
227 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
228 let description = match self {
229 DecodeKind::Length => "invalid length",
230 DecodeKind::Symbol => "invalid symbol",
231 DecodeKind::Trailing => "non-zero trailing bits",
232 DecodeKind::Padding => "invalid padding length",
233 };
234 write!(f, "{description}")
235 }
236}
237
238#[derive(Debug, Copy, Clone, PartialEq, Eq)]
240pub struct DecodeError {
241 pub position: usize,
245
246 pub kind: DecodeKind,
248}
249
250#[cfg(feature = "std")]
251impl std::error::Error for DecodeError {}
252
253impl core::fmt::Display for DecodeError {
254 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
255 write!(f, "{} at {}", self.kind, self.position)
256 }
257}
258
259#[derive(Debug, Copy, Clone, PartialEq, Eq)]
261pub struct DecodePartial {
262 pub read: usize,
266
267 pub written: usize,
271
272 pub error: DecodeError,
274}
275
276const INVALID: u8 = 128;
277const IGNORE: u8 = 129;
278const PADDING: u8 = 130;
279
280fn order(msb: bool, n: usize, i: usize) -> usize {
281 if msb { n - 1 - i } else { i }
282}
283
284#[inline]
285fn enc(bit: usize) -> usize {
286 match bit {
287 1 | 2 | 4 => 1,
288 3 | 6 => 3,
289 5 => 5,
290 _ => unreachable!(),
291 }
292}
293
294#[inline]
295fn dec(bit: usize) -> usize {
296 enc(bit) * 8 / bit
297}
298
299fn encode_len<Bit: BitWidth>(len: usize) -> usize {
300 (8 * len).div_ceil(Bit::VAL)
301}
302
303fn encode_block<Bit: BitWidth, Msb: Bool>(
304 symbols: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
305) {
306 debug_assert!(input.len() <= enc(Bit::VAL));
307 debug_assert_eq!(output.len(), encode_len::<Bit>(input.len()));
308 let bit = Bit::VAL;
309 let msb = Msb::VAL;
310 let mut x = 0u64;
311 for (i, input) in input.iter().enumerate() {
312 x |= u64::from(*input) << (8 * order(msb, enc(bit), i));
313 }
314 for (i, output) in output.iter_mut().enumerate() {
315 let y = x >> (bit * order(msb, dec(bit), i));
316 let _ = output.write(symbols[(y & 0xff) as usize]);
317 }
318}
319
320fn encode_mut<Bit: BitWidth, Msb: Bool>(
321 symbols: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
322) {
323 debug_assert_eq!(output.len(), encode_len::<Bit>(input.len()));
324 let bit = Bit::VAL;
325 let enc = enc(bit);
326 let dec = dec(bit);
327 let n = input.len() / enc;
328 let bs = match bit {
329 5 => 2,
330 6 => 4,
331 _ => 1,
332 };
333 vectorize(n, bs, |i| {
334 let input = unsafe { chunk_unchecked(input, enc, i) };
335 let output = unsafe { chunk_mut_unchecked(output, dec, i) };
336 encode_block::<Bit, Msb>(symbols, input, output);
337 });
338 encode_block::<Bit, Msb>(symbols, &input[enc * n ..], &mut output[dec * n ..]);
339}
340
341fn decode_block<Bit: BitWidth, Msb: Bool>(
344 values: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
345) -> Result<(), usize> {
346 debug_assert!(output.len() <= enc(Bit::VAL));
347 debug_assert_eq!(input.len(), encode_len::<Bit>(output.len()));
348 let bit = Bit::VAL;
349 let msb = Msb::VAL;
350 let mut x = 0u64;
351 for j in 0 .. input.len() {
352 let y = values[input[j] as usize];
353 check!(j, y < 1 << bit);
354 x |= u64::from(y) << (bit * order(msb, dec(bit), j));
355 }
356 for (j, output) in output.iter_mut().enumerate() {
357 let _ = output.write((x >> (8 * order(msb, enc(bit), j)) & 0xff) as u8);
358 }
359 Ok(())
360}
361
362fn decode_mut<Bit: BitWidth, Msb: Bool>(
366 values: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
367) -> Result<(), usize> {
368 debug_assert_eq!(input.len(), encode_len::<Bit>(output.len()));
369 let bit = Bit::VAL;
370 let enc = enc(bit);
371 let dec = dec(bit);
372 let n = input.len() / dec;
373 for i in 0 .. n {
374 let input = unsafe { chunk_unchecked(input, dec, i) };
375 let output = unsafe { chunk_mut_unchecked(output, enc, i) };
376 decode_block::<Bit, Msb>(values, input, output).map_err(|e| dec * i + e)?;
377 }
378 decode_block::<Bit, Msb>(values, &input[dec * n ..], &mut output[enc * n ..])
379 .map_err(|e| dec * n + e)
380}
381
382fn check_trail<Bit: BitWidth, Msb: Bool>(
384 ctb: bool, values: &[u8; 256], input: &[u8],
385) -> Result<(), ()> {
386 if 8 % Bit::VAL == 0 || !ctb {
387 return Ok(());
388 }
389 let trail = Bit::VAL * input.len() % 8;
390 if trail == 0 {
391 return Ok(());
392 }
393 let mut mask = (1 << trail) - 1;
394 if !Msb::VAL {
395 mask <<= Bit::VAL - trail;
396 }
397 check!((), values[input[input.len() - 1] as usize] & mask == 0);
398 Ok(())
399}
400
401fn check_pad<Bit: BitWidth>(values: &[u8; 256], input: &[u8]) -> Result<usize, usize> {
404 let bit = Bit::VAL;
405 debug_assert_eq!(input.len(), dec(bit));
406 let is_pad = |x: &&u8| values[**x as usize] == PADDING;
407 let count = input.iter().rev().take_while(is_pad).count();
408 let len = input.len() - count;
409 check!(len, len > 0 && bit * len % 8 < bit);
410 Ok(len)
411}
412
413fn encode_base_len<Bit: BitWidth>(len: usize) -> usize {
414 encode_len::<Bit>(len)
415}
416
417fn encode_base<Bit: BitWidth, Msb: Bool>(
418 symbols: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
419) {
420 debug_assert_eq!(output.len(), encode_base_len::<Bit>(input.len()));
421 encode_mut::<Bit, Msb>(symbols, input, output);
422}
423
424fn encode_pad_len<Bit: BitWidth, Pad: Bool>(len: usize) -> usize {
425 match Pad::VAL {
426 false => encode_base_len::<Bit>(len),
427 true => len.div_ceil(enc(Bit::VAL)) * dec(Bit::VAL),
428 }
429}
430
431fn encode_pad<Bit: BitWidth, Msb: Bool, Pad: Bool>(
432 symbols: &[u8; 256], pad: Pad::If<u8, ()>, input: &[u8], output: &mut [MaybeUninit<u8>],
433) {
434 let pad = match Pad::open(pad) {
435 If::Then(x) => x,
436 If::Else(()) => return encode_base::<Bit, Msb>(symbols, input, output),
437 };
438 debug_assert_eq!(output.len(), encode_pad_len::<Bit, Pad>(input.len()));
439 let olen = encode_base_len::<Bit>(input.len());
440 encode_base::<Bit, Msb>(symbols, input, &mut output[.. olen]);
441 for output in output.iter_mut().skip(olen) {
442 let _ = output.write(pad);
443 }
444}
445
446fn encode_wrap_len<Bit: BitWidth, Pad: Bool, Wrap: Bool>(
447 wrap: Wrap::If<(usize, &[u8]), ()>, ilen: usize,
448) -> usize {
449 let olen = encode_pad_len::<Bit, Pad>(ilen);
450 match Wrap::open(wrap) {
451 If::Then((col, end)) => olen + end.len() * olen.div_ceil(col),
452 If::Else(()) => olen,
453 }
454}
455
456fn encode_wrap_mut<Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool>(
457 symbols: &[u8; 256], pad: Pad::If<u8, ()>, wrap: Wrap::If<(usize, &[u8]), ()>, input: &[u8],
458 output: &mut [MaybeUninit<u8>],
459) {
460 let (col, end) = match Wrap::open(wrap) {
461 If::Then((col, end)) => (col, end),
462 If::Else(()) => return encode_pad::<Bit, Msb, Pad>(symbols, pad, input, output),
463 };
464 debug_assert_eq!(output.len(), encode_wrap_len::<Bit, Pad, Wrap>(wrap, input.len()));
465 debug_assert_eq!(col % dec(Bit::VAL), 0);
466 let bit = Bit::VAL;
467 let col = col / dec(bit);
468 let enc = col * enc(bit);
469 let dec = col * dec(bit) + end.len();
470 let olen = dec - end.len();
471 let n = input.len() / enc;
472 for i in 0 .. n {
473 let input = unsafe { chunk_unchecked(input, enc, i) };
474 let output = unsafe { chunk_mut_unchecked(output, dec, i) };
475 encode_base::<Bit, Msb>(symbols, input, &mut output[.. olen]);
476 unsafe { copy_from_slice(&mut output[olen ..], end) };
477 }
478 if input.len() > enc * n {
479 let olen = dec * n + encode_pad_len::<Bit, Pad>(input.len() - enc * n);
480 encode_pad::<Bit, Msb, Pad>(symbols, pad, &input[enc * n ..], &mut output[dec * n .. olen]);
481 unsafe { copy_from_slice(&mut output[olen ..], end) };
482 }
483}
484
485fn decode_wrap_len<Bit: BitWidth, Pad: Bool>(len: usize) -> (usize, usize) {
487 let bit = Bit::VAL;
488 if Pad::VAL {
489 (floor(len, dec(bit)), len / dec(bit) * enc(bit))
490 } else {
491 let trail = bit * len % 8;
492 (len - trail / bit, bit * len / 8)
493 }
494}
495
496fn decode_pad_len<Bit: BitWidth, Pad: Bool>(len: usize) -> Result<usize, DecodeError> {
499 let (ilen, olen) = decode_wrap_len::<Bit, Pad>(len);
500 check!(DecodeError { position: ilen, kind: DecodeKind::Length }, ilen == len);
501 Ok(olen)
502}
503
504fn decode_base_len<Bit: BitWidth>(len: usize) -> Result<usize, DecodeError> {
507 decode_pad_len::<Bit, False>(len)
508}
509
510fn decode_base_mut<Bit: BitWidth, Msb: Bool>(
514 ctb: bool, values: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
515) -> Result<usize, DecodePartial> {
516 debug_assert_eq!(Ok(output.len()), decode_base_len::<Bit>(input.len()));
517 let bit = Bit::VAL;
518 let fail = |pos, kind| DecodePartial {
519 read: pos / dec(bit) * dec(bit),
520 written: pos / dec(bit) * enc(bit),
521 error: DecodeError { position: pos, kind },
522 };
523 decode_mut::<Bit, Msb>(values, input, output).map_err(|pos| fail(pos, DecodeKind::Symbol))?;
524 check_trail::<Bit, Msb>(ctb, values, input)
525 .map_err(|()| fail(input.len() - 1, DecodeKind::Trailing))?;
526 Ok(output.len())
527}
528
529fn decode_pad_mut<Bit: BitWidth, Msb: Bool, Pad: Bool>(
535 ctb: bool, values: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
536) -> Result<usize, DecodePartial> {
537 if !Pad::VAL {
538 return decode_base_mut::<Bit, Msb>(ctb, values, input, output);
539 }
540 debug_assert_eq!(Ok(output.len()), decode_pad_len::<Bit, Pad>(input.len()));
541 let bit = Bit::VAL;
542 let enc = enc(bit);
543 let dec = dec(bit);
544 let mut inpos = 0;
545 let mut outpos = 0;
546 let mut outend = output.len();
547 while inpos < input.len() {
548 match decode_base_mut::<Bit, Msb>(
549 ctb,
550 values,
551 &input[inpos ..],
552 &mut output[outpos .. outend],
553 ) {
554 Ok(written) => {
555 if cfg!(debug_assertions) {
556 inpos = input.len();
557 }
558 outpos += written;
559 break;
560 }
561 Err(partial) => {
562 inpos += partial.read;
563 outpos += partial.written;
564 }
565 }
566 let inlen = check_pad::<Bit>(values, &input[inpos .. inpos + dec]).map_err(|pos| {
567 DecodePartial {
568 read: inpos,
569 written: outpos,
570 error: DecodeError { position: inpos + pos, kind: DecodeKind::Padding },
571 }
572 })?;
573 let outlen = decode_base_len::<Bit>(inlen).unwrap();
574 let written = decode_base_mut::<Bit, Msb>(
575 ctb,
576 values,
577 &input[inpos .. inpos + inlen],
578 &mut output[outpos .. outpos + outlen],
579 )
580 .map_err(|partial| {
581 debug_assert_eq!(partial.read, 0);
582 debug_assert_eq!(partial.written, 0);
583 DecodePartial {
584 read: inpos,
585 written: outpos,
586 error: DecodeError {
587 position: inpos + partial.error.position,
588 kind: partial.error.kind,
589 },
590 }
591 })?;
592 debug_assert_eq!(written, outlen);
593 inpos += dec;
594 outpos += outlen;
595 outend -= enc - outlen;
596 }
597 debug_assert_eq!(inpos, input.len());
598 debug_assert_eq!(outpos, outend);
599 Ok(outend)
600}
601
602fn skip_ignore(values: &[u8; 256], input: &[u8], mut inpos: usize) -> usize {
603 while inpos < input.len() && values[input[inpos] as usize] == IGNORE {
604 inpos += 1;
605 }
606 inpos
607}
608
609fn decode_wrap_block<Bit: BitWidth, Msb: Bool, Pad: Bool>(
616 ctb: bool, values: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
617) -> Result<(usize, usize), DecodeError> {
618 let bit = Bit::VAL;
619 let dec = dec(bit);
620 let mut buf = [0u8; 8];
621 let mut shift = [0usize; 8];
622 let mut bufpos = 0;
623 let mut inpos = 0;
624 while bufpos < dec {
625 inpos = skip_ignore(values, input, inpos);
626 if inpos == input.len() {
627 break;
628 }
629 shift[bufpos] = inpos;
630 buf[bufpos] = input[inpos];
631 bufpos += 1;
632 inpos += 1;
633 }
634 let olen = decode_pad_len::<Bit, Pad>(bufpos).map_err(|mut e| {
635 e.position = shift[e.position];
636 e
637 })?;
638 let written =
639 decode_pad_mut::<Bit, Msb, Pad>(ctb, values, &buf[.. bufpos], &mut output[.. olen])
640 .map_err(|partial| {
641 debug_assert_eq!(partial.read, 0);
642 debug_assert_eq!(partial.written, 0);
643 DecodeError { position: shift[partial.error.position], kind: partial.error.kind }
644 })?;
645 Ok((inpos, written))
646}
647
648fn decode_wrap_mut<Bit: BitWidth, Msb: Bool, Pad: Bool, Ignore: Bool>(
655 ctb: bool, values: &[u8; 256], input: &[u8], output: &mut [MaybeUninit<u8>],
656) -> Result<usize, DecodePartial> {
657 if !Ignore::VAL {
658 return decode_pad_mut::<Bit, Msb, Pad>(ctb, values, input, output);
659 }
660 debug_assert_eq!(output.len(), decode_wrap_len::<Bit, Pad>(input.len()).1);
661 let mut inpos = 0;
662 let mut outpos = 0;
663 while inpos < input.len() {
664 let (inlen, outlen) = decode_wrap_len::<Bit, Pad>(input.len() - inpos);
665 match decode_pad_mut::<Bit, Msb, Pad>(
666 ctb,
667 values,
668 &input[inpos .. inpos + inlen],
669 &mut output[outpos .. outpos + outlen],
670 ) {
671 Ok(written) => {
672 inpos += inlen;
673 outpos += written;
674 break;
675 }
676 Err(partial) => {
677 inpos += partial.read;
678 outpos += partial.written;
679 }
680 }
681 let (ipos, opos) = decode_wrap_block::<Bit, Msb, Pad>(
682 ctb,
683 values,
684 &input[inpos ..],
685 &mut output[outpos ..],
686 )
687 .map_err(|mut error| {
688 error.position += inpos;
689 DecodePartial { read: inpos, written: outpos, error }
690 })?;
691 inpos += ipos;
692 outpos += opos;
693 }
694 let inpos = skip_ignore(values, input, inpos);
695 if inpos == input.len() {
696 Ok(outpos)
697 } else {
698 Err(DecodePartial {
699 read: inpos,
700 written: outpos,
701 error: DecodeError { position: inpos, kind: DecodeKind::Length },
702 })
703 }
704}
705
706#[derive(Debug, Copy, Clone, PartialEq, Eq)]
708pub enum ConvertError {
709 BitWidth,
711
712 BitOrder,
714
715 Padding,
717
718 Wrap,
720
721 Ignore,
723}
724
725#[derive(Debug, Clone, PartialEq, Eq)]
729#[repr(transparent)]
730pub struct Encoding<Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool> {
731 data: InternalEncoding,
735 _type: PhantomData<(Bit, Msb, Pad, Wrap, Ignore)>,
736}
737
738#[derive(Debug, Clone, PartialEq, Eq)]
761#[repr(transparent)]
762pub struct DynEncoding(InternalEncoding);
763
764#[cfg(feature = "alloc")]
765type InternalEncoding = Cow<'static, [u8]>;
766
767#[cfg(not(feature = "alloc"))]
768type InternalEncoding = &'static [u8];
769
770impl<Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool>
771 Encoding<Bit, Msb, Pad, Wrap, Ignore>
772{
773 fn sym(&self) -> &[u8; 256] {
774 self.data[0 .. 256].try_into().unwrap()
775 }
776
777 fn val(&self) -> &[u8; 256] {
778 self.data[256 .. 512].try_into().unwrap()
779 }
780
781 fn pad(&self) -> Pad::If<u8, ()> {
782 Pad::make(|| self.data[512], || ())
783 }
784
785 fn ctb(&self) -> bool {
786 self.data[513] & 0x10 != 0
787 }
788
789 fn wrap(&self) -> Wrap::If<(usize, &[u8]), ()> {
790 Wrap::make(|| (self.data[514] as usize, &self.data[515 ..]), || ())
791 }
792
793 fn has_ignore(&self) -> bool {
794 self.data.len() >= 515
795 }
796
797 fn block_len(&self) -> (usize, usize) {
799 let bit = Bit::VAL;
800 match Wrap::open(self.wrap()) {
801 If::Then((col, end)) => (col / dec(bit) * enc(bit), col + end.len()),
802 If::Else(()) => (enc(bit), dec(bit)),
803 }
804 }
805
806 #[must_use]
810 pub fn encode_len(&self, len: usize) -> usize {
811 encode_wrap_len::<Bit, Pad, Wrap>(self.wrap(), len)
812 }
813
814 pub fn encode_mut_uninit<'a>(
821 &self, input: &[u8], output: &'a mut [MaybeUninit<u8>],
822 ) -> &'a mut [u8] {
823 assert_eq!(output.len(), self.encode_len(input.len()));
824 encode_wrap_mut::<Bit, Msb, Pad, Wrap>(self.sym(), self.pad(), self.wrap(), input, output);
825 unsafe { slice_assume_init_mut(output) }
826 }
827
828 pub fn encode_mut(&self, input: &[u8], output: &mut [u8]) {
835 let _ = self.encode_mut_uninit(input, unsafe { slice_uninit_mut(output) });
836 }
837
838 #[cfg(feature = "alloc")]
840 pub fn encode_append(&self, input: &[u8], output: &mut String) {
841 let output = unsafe { output.as_mut_vec() };
842 let output_len = output.len();
843 let len = self.encode_len(input.len());
844 let actual_len = self.encode_mut_uninit(input, reserve_spare(output, len)).len();
845 debug_assert_eq!(actual_len, len);
846 unsafe { output.set_len(output_len + len) };
847 }
848
849 pub fn encode_write_buffer_uninit(
869 &self, input: &[u8], output: &mut impl core::fmt::Write, buffer: &mut [MaybeUninit<u8>],
870 ) -> core::fmt::Result {
871 assert!(510 <= buffer.len());
872 let (enc, dec) = self.block_len();
873 for input in input.chunks(buffer.len() / dec * enc) {
874 let buffer = &mut buffer[.. self.encode_len(input.len())];
875 let buffer = self.encode_mut_uninit(input, buffer);
876 output.write_str(unsafe { core::str::from_utf8_unchecked(buffer) })?;
877 }
878 Ok(())
879 }
880
881 pub fn encode_write_buffer(
891 &self, input: &[u8], output: &mut impl core::fmt::Write, buffer: &mut [u8],
892 ) -> core::fmt::Result {
893 self.encode_write_buffer_uninit(input, output, unsafe { slice_uninit_mut(buffer) })
894 }
895
896 pub fn encode_write(
905 &self, input: &[u8], output: &mut impl core::fmt::Write,
906 ) -> core::fmt::Result {
907 self.encode_write_buffer(input, output, &mut [0; 1024])
908 }
909
910 #[cfg(feature = "alloc")]
912 #[must_use]
913 pub fn encode(&self, input: &[u8]) -> String {
914 let mut output = Vec::new();
915 let len = self.encode_len(input.len());
916 let actual_len = self.encode_mut_uninit(input, reserve_spare(&mut output, len)).len();
917 debug_assert_eq!(actual_len, len);
918 unsafe { output.set_len(len) };
919 unsafe { String::from_utf8_unchecked(output) }
920 }
921
922 pub fn decode_len(&self, len: usize) -> Result<usize, DecodeError> {
932 let (ilen, olen) = decode_wrap_len::<Bit, Pad>(len);
933 check!(
934 DecodeError { position: ilen, kind: DecodeKind::Length },
935 self.has_ignore() || len == ilen
936 );
937 Ok(olen)
938 }
939
940 pub fn decode_mut_uninit<'a>(
955 &self, input: &[u8], output: &'a mut [MaybeUninit<u8>],
956 ) -> Result<&'a mut [u8], DecodePartial> {
957 assert_eq!(Ok(output.len()), self.decode_len(input.len()));
958 let len = decode_wrap_mut::<Bit, Msb, Pad, Ignore>(self.ctb(), self.val(), input, output)?;
959 Ok(unsafe { slice_assume_init_mut(&mut output[.. len]) })
960 }
961
962 pub fn decode_mut(&self, input: &[u8], output: &mut [u8]) -> Result<usize, DecodePartial> {
983 Ok(self.decode_mut_uninit(input, unsafe { slice_uninit_mut(output) })?.len())
984 }
985
986 #[cfg(feature = "alloc")]
1005 pub fn decode(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError> {
1006 let max_len = self.decode_len(input.len())?;
1007 let mut output = Vec::new();
1008 let len = self
1009 .decode_mut_uninit(input, reserve_spare(&mut output, max_len))
1010 .map_err(|partial| partial.error)?
1011 .len();
1012 unsafe { output.set_len(len) };
1013 Ok(output)
1014 }
1015
1016 #[cfg(feature = "alloc")]
1018 #[must_use]
1019 pub fn specification(&self) -> Specification {
1020 DynEncoding::specification(self.into())
1021 }
1022
1023 #[must_use]
1025 pub fn as_dyn(&self) -> &DynEncoding {
1026 self.into()
1027 }
1028
1029 #[doc(hidden)]
1030 #[must_use]
1031 pub const unsafe fn new_unchecked(data: &'static [u8]) -> Self {
1032 #[cfg(feature = "alloc")]
1033 let data = Cow::Borrowed(data);
1034 Encoding { data, _type: PhantomData }
1035 }
1036
1037 fn check_compatible(base: &DynEncoding) -> Result<(), ConvertError> {
1038 check!(ConvertError::BitWidth, base.bit() == Bit::VAL);
1039 check!(ConvertError::BitOrder, base.msb() == Msb::VAL);
1040 check!(ConvertError::Padding, base.pad().is_some() == Pad::VAL);
1041 check!(ConvertError::Wrap, base.wrap().is_some() == Wrap::VAL);
1042 check!(ConvertError::Ignore, base.has_ignore() == Ignore::VAL);
1043 Ok(())
1044 }
1045}
1046
1047impl DynEncoding {
1048 fn sym(&self) -> &[u8; 256] {
1049 self.0[0 .. 256].try_into().unwrap()
1050 }
1051
1052 fn val(&self) -> &[u8; 256] {
1053 self.0[256 .. 512].try_into().unwrap()
1054 }
1055
1056 fn pad(&self) -> Option<u8> {
1057 if self.0[512] < 128 { Some(self.0[512]) } else { None }
1058 }
1059
1060 fn ctb(&self) -> bool {
1061 self.0[513] & 0x10 != 0
1062 }
1063
1064 fn msb(&self) -> bool {
1065 self.0[513] & 0x8 != 0
1066 }
1067
1068 fn bit(&self) -> usize {
1069 (self.0[513] & 0x7) as usize
1070 }
1071
1072 fn block_len(&self) -> (usize, usize) {
1074 let bit = self.bit();
1075 match self.wrap() {
1076 Some((col, end)) => (col / dec(bit) * enc(bit), col + end.len()),
1077 None => (enc(bit), dec(bit)),
1078 }
1079 }
1080
1081 fn wrap(&self) -> Option<(usize, &[u8])> {
1082 if self.0.len() <= 515 {
1083 return None;
1084 }
1085 Some((self.0[514] as usize, &self.0[515 ..]))
1086 }
1087
1088 fn has_ignore(&self) -> bool {
1089 self.0.len() >= 515
1090 }
1091
1092 #[must_use]
1098 pub fn encode_len(&self, len: usize) -> usize {
1099 dispatch!(self.encode_len(len))
1100 }
1101
1102 #[allow(clippy::cognitive_complexity)]
1122 pub fn encode_mut(&self, input: &[u8], output: &mut [u8]) {
1123 dispatch!(self.encode_mut(input, output))
1124 }
1125
1126 #[cfg(feature = "alloc")]
1139 pub fn encode_append(&self, input: &[u8], output: &mut String) {
1140 let output = unsafe { output.as_mut_vec() };
1141 let output_len = output.len();
1142 output.resize(output_len + self.encode_len(input.len()), 0u8);
1143 self.encode_mut(input, &mut output[output_len ..]);
1144 }
1145
1146 pub fn encode_write(
1155 &self, input: &[u8], output: &mut impl core::fmt::Write,
1156 ) -> core::fmt::Result {
1157 self.encode_write_buffer(input, output, &mut [0; 1024])
1158 }
1159
1160 pub fn encode_write_buffer(
1170 &self, input: &[u8], output: &mut impl core::fmt::Write, buffer: &mut [u8],
1171 ) -> core::fmt::Result {
1172 assert!(510 <= buffer.len());
1173 let (enc, dec) = self.block_len();
1174 for input in input.chunks(buffer.len() / dec * enc) {
1175 let buffer = &mut buffer[.. self.encode_len(input.len())];
1176 self.encode_mut(input, buffer);
1177 output.write_str(unsafe { core::str::from_utf8_unchecked(buffer) })?;
1178 }
1179 Ok(())
1180 }
1181
1182 #[cfg(feature = "alloc")]
1191 #[must_use]
1192 pub fn encode(&self, input: &[u8]) -> String {
1193 let mut output = vec![0u8; self.encode_len(input.len())];
1194 self.encode_mut(input, &mut output);
1195 unsafe { String::from_utf8_unchecked(output) }
1196 }
1197
1198 pub fn decode_len(&self, len: usize) -> Result<usize, DecodeError> {
1212 dispatch!(self.decode_len(len))
1213 }
1214
1215 #[allow(clippy::cognitive_complexity)]
1253 pub fn decode_mut(&self, input: &[u8], output: &mut [u8]) -> Result<usize, DecodePartial> {
1254 dispatch!(self.decode_mut(input, output))
1255 }
1256
1257 #[cfg(feature = "alloc")]
1287 pub fn decode(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError> {
1288 let mut output = vec![0u8; self.decode_len(input.len())?];
1289 let len = self.decode_mut(input, &mut output).map_err(|partial| partial.error)?;
1290 output.truncate(len);
1291 Ok(output)
1292 }
1293
1294 #[must_use]
1296 pub fn bit_width(&self) -> usize {
1297 self.bit()
1298 }
1299
1300 #[must_use]
1309 pub fn is_canonical(&self) -> bool {
1310 if !self.ctb() {
1311 return false;
1312 }
1313 let bit = self.bit();
1314 let sym = self.sym();
1315 let val = self.val();
1316 for i in 0 .. 256 {
1317 if val[i] == INVALID {
1318 continue;
1319 }
1320 if val[i] >= 1 << bit {
1321 return false;
1322 }
1323 if sym[val[i] as usize] as usize != i {
1324 return false;
1325 }
1326 }
1327 true
1328 }
1329
1330 #[allow(clippy::missing_panics_doc)] #[cfg(feature = "alloc")]
1333 #[must_use]
1334 pub fn specification(&self) -> Specification {
1335 let mut specification = Specification::new();
1336 specification
1337 .symbols
1338 .push_str(core::str::from_utf8(&self.sym()[0 .. 1 << self.bit()]).unwrap());
1339 specification.bit_order =
1340 if self.msb() { MostSignificantFirst } else { LeastSignificantFirst };
1341 specification.check_trailing_bits = self.ctb();
1342 if let Some(pad) = self.pad() {
1343 specification.padding = Some(pad as char);
1344 }
1345 for i in 0 .. 128u8 {
1346 if self.val()[i as usize] != IGNORE {
1347 continue;
1348 }
1349 specification.ignore.push(i as char);
1350 }
1351 if let Some((col, end)) = self.wrap() {
1352 specification.wrap.width = col;
1353 specification.wrap.separator = core::str::from_utf8(end).unwrap().to_owned();
1354 }
1355 for i in 0 .. 128u8 {
1356 let canonical = if self.val()[i as usize] < 1 << self.bit() {
1357 self.sym()[self.val()[i as usize] as usize]
1358 } else if self.val()[i as usize] == PADDING {
1359 self.pad().unwrap()
1360 } else {
1361 continue;
1362 };
1363 if i == canonical {
1364 continue;
1365 }
1366 specification.translate.from.push(i as char);
1367 specification.translate.to.push(canonical as char);
1368 }
1369 specification
1370 }
1371
1372 #[doc(hidden)]
1373 #[must_use]
1374 pub const unsafe fn internal_new(implementation: &'static [u8]) -> DynEncoding {
1375 #[cfg(feature = "alloc")]
1376 let encoding = DynEncoding(Cow::Borrowed(implementation));
1377 #[cfg(not(feature = "alloc"))]
1378 let encoding = DynEncoding(implementation);
1379 encoding
1380 }
1381
1382 #[doc(hidden)]
1383 #[must_use]
1384 pub fn internal_implementation(&self) -> &[u8] {
1385 &self.0
1386 }
1387}
1388
1389impl<Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool> TryFrom<DynEncoding>
1390 for Encoding<Bit, Msb, Pad, Wrap, Ignore>
1391{
1392 type Error = ConvertError;
1393
1394 fn try_from(base: DynEncoding) -> Result<Self, Self::Error> {
1395 Encoding::<Bit, Msb, Pad, Wrap, Ignore>::check_compatible(&base)?;
1396 Ok(Encoding { data: base.0, _type: PhantomData })
1397 }
1398}
1399
1400impl<Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool>
1401 From<Encoding<Bit, Msb, Pad, Wrap, Ignore>> for DynEncoding
1402{
1403 fn from(base: Encoding<Bit, Msb, Pad, Wrap, Ignore>) -> Self {
1404 DynEncoding(base.data)
1405 }
1406}
1407
1408impl<'a, Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool> TryFrom<&'a DynEncoding>
1409 for &'a Encoding<Bit, Msb, Pad, Wrap, Ignore>
1410{
1411 type Error = ConvertError;
1412
1413 fn try_from(base: &'a DynEncoding) -> Result<Self, Self::Error> {
1414 Encoding::<Bit, Msb, Pad, Wrap, Ignore>::check_compatible(base)?;
1415 Ok(unsafe { cast(base) })
1416 }
1417}
1418
1419impl<'a, Bit: BitWidth, Msb: Bool, Pad: Bool, Wrap: Bool, Ignore: Bool>
1420 From<&'a Encoding<Bit, Msb, Pad, Wrap, Ignore>> for &'a DynEncoding
1421{
1422 fn from(base: &'a Encoding<Bit, Msb, Pad, Wrap, Ignore>) -> Self {
1423 unsafe { &*core::ptr::from_ref(base).cast::<DynEncoding>() }
1424 }
1425}
1426
1427#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1453#[cfg(feature = "alloc")]
1454pub enum BitOrder {
1455 MostSignificantFirst,
1464
1465 LeastSignificantFirst,
1479}
1480#[cfg(feature = "alloc")]
1481use crate::BitOrder::*;
1482
1483#[derive(Debug, Clone)]
1490#[cfg(feature = "alloc")]
1491pub struct Translate {
1492 pub from: String,
1494
1495 pub to: String,
1497}
1498
1499#[derive(Debug, Clone)]
1503#[cfg(feature = "alloc")]
1504pub struct Wrap {
1505 pub width: usize,
1515
1516 pub separator: String,
1520}
1521
1522#[derive(Debug, Clone)]
1759#[cfg(feature = "alloc")]
1760pub struct Specification {
1761 pub symbols: String,
1766
1767 pub bit_order: BitOrder,
1771
1772 pub check_trailing_bits: bool,
1777
1778 pub padding: Option<char>,
1783
1784 pub ignore: String,
1789
1790 pub wrap: Wrap,
1795
1796 pub translate: Translate,
1803}
1804
1805#[cfg(feature = "alloc")]
1806impl Default for Specification {
1807 fn default() -> Self {
1808 Self::new()
1809 }
1810}
1811
1812#[derive(Debug, Copy, Clone)]
1813#[cfg(feature = "alloc")]
1814enum SpecificationErrorImpl {
1815 BadSize,
1816 NotAscii,
1817 Duplicate(u8),
1818 ExtraPadding,
1819 WrapLength,
1820 WrapWidth(u8),
1821 FromTo,
1822 Undefined(u8),
1823}
1824#[cfg(feature = "alloc")]
1825use crate::SpecificationErrorImpl::*;
1826
1827#[derive(Debug, Copy, Clone)]
1829#[cfg(feature = "alloc")]
1830pub struct SpecificationError(SpecificationErrorImpl);
1831
1832#[cfg(feature = "alloc")]
1833impl core::fmt::Display for SpecificationError {
1834 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1835 match self.0 {
1836 BadSize => write!(f, "invalid number of symbols"),
1837 NotAscii => write!(f, "non-ascii character"),
1838 Duplicate(c) => write!(f, "{:?} has conflicting definitions", c as char),
1839 ExtraPadding => write!(f, "unnecessary padding"),
1840 WrapLength => write!(f, "invalid wrap width or separator length"),
1841 WrapWidth(x) => write!(f, "wrap width not a multiple of {x}"),
1842 FromTo => write!(f, "translate from/to length mismatch"),
1843 Undefined(c) => write!(f, "{:?} is undefined", c as char),
1844 }
1845 }
1846}
1847
1848#[cfg(feature = "std")]
1849impl std::error::Error for SpecificationError {
1850 fn description(&self) -> &str {
1851 match self.0 {
1852 BadSize => "invalid number of symbols",
1853 NotAscii => "non-ascii character",
1854 Duplicate(_) => "conflicting definitions",
1855 ExtraPadding => "unnecessary padding",
1856 WrapLength => "invalid wrap width or separator length",
1857 WrapWidth(_) => "wrap width not a multiple",
1858 FromTo => "translate from/to length mismatch",
1859 Undefined(_) => "undefined character",
1860 }
1861 }
1862}
1863
1864#[cfg(feature = "alloc")]
1865impl Specification {
1866 #[must_use]
1868 pub fn new() -> Specification {
1869 Specification {
1870 symbols: String::new(),
1871 bit_order: MostSignificantFirst,
1872 check_trailing_bits: true,
1873 padding: None,
1874 ignore: String::new(),
1875 wrap: Wrap { width: 0, separator: String::new() },
1876 translate: Translate { from: String::new(), to: String::new() },
1877 }
1878 }
1879
1880 pub fn encoding(&self) -> Result<DynEncoding, SpecificationError> {
1886 let symbols = self.symbols.as_bytes();
1887 let bit: u8 = match symbols.len() {
1888 2 => 1,
1889 4 => 2,
1890 8 => 3,
1891 16 => 4,
1892 32 => 5,
1893 64 => 6,
1894 _ => return Err(SpecificationError(BadSize)),
1895 };
1896 let mut values = [INVALID; 128];
1897 let set = |v: &mut [u8; 128], i: u8, x: u8| {
1898 check!(SpecificationError(NotAscii), i < 128);
1899 if v[i as usize] == x {
1900 return Ok(());
1901 }
1902 check!(SpecificationError(Duplicate(i)), v[i as usize] == INVALID);
1903 v[i as usize] = x;
1904 Ok(())
1905 };
1906 for (v, symbols) in symbols.iter().enumerate() {
1907 #[allow(clippy::cast_possible_truncation)] set(&mut values, *symbols, v as u8)?;
1909 }
1910 let msb = self.bit_order == MostSignificantFirst;
1911 let ctb = self.check_trailing_bits || 8 % bit == 0;
1912 let pad = match self.padding {
1913 None => None,
1914 Some(pad) => {
1915 check!(SpecificationError(ExtraPadding), 8 % bit != 0);
1916 check!(SpecificationError(NotAscii), pad.len_utf8() == 1);
1917 set(&mut values, pad as u8, PADDING)?;
1918 Some(pad as u8)
1919 }
1920 };
1921 for i in self.ignore.bytes() {
1922 set(&mut values, i, IGNORE)?;
1923 }
1924 let wrap = if self.wrap.separator.is_empty() || self.wrap.width == 0 {
1925 None
1926 } else {
1927 let col = self.wrap.width;
1928 let end = self.wrap.separator.as_bytes();
1929 check!(SpecificationError(WrapLength), col < 256 && end.len() < 256);
1930 #[allow(clippy::cast_possible_truncation)] let col = col as u8;
1932 #[allow(clippy::cast_possible_truncation)] let dec = dec(bit as usize) as u8;
1934 check!(SpecificationError(WrapWidth(dec)), col % dec == 0);
1935 for &i in end {
1936 set(&mut values, i, IGNORE)?;
1937 }
1938 Some((col, end))
1939 };
1940 let from = self.translate.from.as_bytes();
1941 let to = self.translate.to.as_bytes();
1942 check!(SpecificationError(FromTo), from.len() == to.len());
1943 for i in 0 .. from.len() {
1944 check!(SpecificationError(NotAscii), to[i] < 128);
1945 let v = values[to[i] as usize];
1946 check!(SpecificationError(Undefined(to[i])), v != INVALID);
1947 set(&mut values, from[i], v)?;
1948 }
1949 let mut encoding = Vec::new();
1950 for _ in 0 .. 256 / symbols.len() {
1951 encoding.extend_from_slice(symbols);
1952 }
1953 encoding.extend_from_slice(&values);
1954 encoding.extend_from_slice(&[INVALID; 128]);
1955 match pad {
1956 None => encoding.push(INVALID),
1957 Some(pad) => encoding.push(pad),
1958 }
1959 encoding.push(bit);
1960 if msb {
1961 encoding[513] |= 0x08;
1962 }
1963 if ctb {
1964 encoding[513] |= 0x10;
1965 }
1966 if let Some((col, end)) = wrap {
1967 encoding.push(col);
1968 encoding.extend_from_slice(end);
1969 } else if values.contains(&IGNORE) {
1970 encoding.push(0);
1971 }
1972 Ok(DynEncoding(Cow::Owned(encoding)))
1973 }
1974}
1975
1976pub type Hex = Encoding<Bit4, True, False, False, False>;
1978
1979pub type Base32 = Encoding<Bit5, True, True, False, False>;
1981
1982pub type Base32NoPad = Encoding<Bit5, True, False, False, False>;
1984
1985pub type Base32LsbNoPad = Encoding<Bit5, False, False, False, False>;
1987
1988pub type Base64 = Encoding<Bit6, True, True, False, False>;
1990
1991pub type Base64NoPad = Encoding<Bit6, True, False, False, False>;
1993
1994pub type Base64Wrap = Encoding<Bit6, True, True, True, True>;
1996
1997pub static HEXLOWER: Hex = unsafe { Hex::new_unchecked(HEXLOWER_IMPL) };
2017const HEXLOWER_IMPL: &[u8] = &[
2018 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54,
2019 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
2020 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
2021 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
2022 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
2023 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
2024 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
2025 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
2026 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
2027 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
2028 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
2029 56, 57, 97, 98, 99, 100, 101, 102, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2030 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2031 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 1, 2,
2032 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2033 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2034 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2035 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2036 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2037 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2038 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2039 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2040 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2041 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2042 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
2043];
2044
2045pub static HEXLOWER_PERMISSIVE: Hex = unsafe { Hex::new_unchecked(HEXLOWER_PERMISSIVE_IMPL) };
2073const HEXLOWER_PERMISSIVE_IMPL: &[u8] = &[
2074 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54,
2075 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
2076 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
2077 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
2078 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
2079 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
2080 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
2081 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
2082 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
2083 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
2084 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
2085 56, 57, 97, 98, 99, 100, 101, 102, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2086 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2087 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 1, 2,
2088 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128,
2089 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2090 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2091 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2092 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2093 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2094 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2095 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2096 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2097 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2098 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
2099];
2100
2101pub static HEXUPPER: Hex = unsafe { Hex::new_unchecked(HEXUPPER_IMPL) };
2125const HEXUPPER_IMPL: &[u8] = &[
2126 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2127 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2128 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2129 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2130 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2131 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2132 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2133 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2134 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2135 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2136 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 128, 128, 128, 128, 128, 128,
2137 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2138 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2139 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,
2140 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2141 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2142 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2143 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2144 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2145 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2146 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2147 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2148 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2149 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
2150];
2151
2152pub static HEXUPPER_PERMISSIVE: Hex = unsafe { Hex::new_unchecked(HEXUPPER_PERMISSIVE_IMPL) };
2174const HEXUPPER_PERMISSIVE_IMPL: &[u8] = &[
2175 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2176 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2177 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2178 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2179 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2180 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2181 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2182 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2183 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
2184 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2185 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 128, 128, 128, 128, 128, 128,
2186 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2187 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2188 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,
2189 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2190 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128,
2191 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2192 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2193 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2194 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2195 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2196 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2197 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2198 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
2199];
2200
2201pub static BASE32: Base32 = unsafe { Base32::new_unchecked(BASE32_IMPL) };
2217const BASE32_IMPL: &[u8] = &[
2218 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2219 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2220 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2221 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2222 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2223 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2224 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2225 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2226 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2227 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2228 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,
2229 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2230 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2231 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 130, 128, 128,
2232 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2233 25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2234 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2235 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2236 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2237 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2238 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2239 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2240 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2241 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 29,
2242];
2243
2244pub static BASE32_NOPAD: Base32NoPad = unsafe { Base32NoPad::new_unchecked(BASE32_NOPAD_IMPL) };
2255const BASE32_NOPAD_IMPL: &[u8] = &[
2256 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2257 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2258 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2259 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2260 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2261 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2262 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2263 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2264 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2265 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2266 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,
2267 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2268 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2269 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128,
2270 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2271 25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2272 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2273 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2274 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2275 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2276 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2277 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2278 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2279 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2280];
2281
2282pub static BASE32HEX: Base32 = unsafe { Base32::new_unchecked(BASE32HEX_IMPL) };
2298const BASE32HEX_IMPL: &[u8] = &[
2299 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2300 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2301 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2302 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2303 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2304 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2305 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2306 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2307 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2308 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2309 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 128, 128, 128, 128, 128, 128,
2310 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2311 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2312 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 130, 128, 128, 128, 10, 11,
2313 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128,
2314 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2315 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2316 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2317 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2318 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2319 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2320 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2321 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2322 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 29,
2323];
2324
2325pub static BASE32HEX_NOPAD: Base32NoPad =
2336 unsafe { Base32NoPad::new_unchecked(BASE32HEX_NOPAD_IMPL) };
2337const BASE32HEX_NOPAD_IMPL: &[u8] = &[
2338 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2339 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2340 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2341 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2342 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2343 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2344 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2345 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2346 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2347 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2348 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 128, 128, 128, 128, 128, 128,
2349 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2350 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2351 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,
2352 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128,
2353 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2354 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2355 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2356 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2357 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2358 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2359 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2360 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2361 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2362];
2363
2364pub static BASE32_DNSSEC: Base32NoPad = unsafe { Base32NoPad::new_unchecked(BASE32_DNSSEC_IMPL) };
2385const BASE32_DNSSEC_IMPL: &[u8] = &[
2386 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
2387 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
2388 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2389 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104,
2390 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53,
2391 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
2392 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101,
2393 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49,
2394 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
2395 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98,
2396 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2397 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
2398 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 128, 128, 128, 128, 128, 128, 128,
2399 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2400 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2401 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13,
2402 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128,
2403 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
2404 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2405 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2406 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2407 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2408 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2409 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2410 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2411 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2412];
2413
2414#[allow(clippy::doc_markdown)]
2415pub static BASE32_DNSCURVE: Base32LsbNoPad =
2433 unsafe { Base32LsbNoPad::new_unchecked(BASE32_DNSCURVE_IMPL) };
2434const BASE32_DNSCURVE_IMPL: &[u8] = &[
2435 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110,
2436 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
2437 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119,
2438 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107,
2439 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53,
2440 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116,
2441 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103,
2442 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49,
2443 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113,
2444 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99,
2445 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2446 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109,
2447 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 128, 128, 128, 128, 128, 128, 128,
2448 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2449 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2450 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128, 10, 11,
2451 12, 128, 13, 14, 15, 128, 16, 17, 18, 19, 20, 128, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
2452 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 128, 13, 14, 15, 128, 16, 17, 18, 19, 20, 128,
2453 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2454 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2455 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2456 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2457 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2458 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2459 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2460 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 21,
2461];
2462
2463pub static BASE64: Base64 = unsafe { Base64::new_unchecked(BASE64_IMPL) };
2479const BASE64_IMPL: &[u8] = &[
2480 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2481 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2482 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2483 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2484 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2485 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2486 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2487 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2488 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2489 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2490 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2491 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2492 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2493 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2494 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2495 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
2496 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2497 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2498 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2499 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2500 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2501 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2502 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2503 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2504 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30,
2505];
2506
2507pub static BASE64_NOPAD: Base64NoPad = unsafe { Base64NoPad::new_unchecked(BASE64_NOPAD_IMPL) };
2518const BASE64_NOPAD_IMPL: &[u8] = &[
2519 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2520 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2521 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2522 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2523 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2524 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2525 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2526 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2527 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2528 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2529 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2530 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2531 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2532 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2533 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 128, 128,
2534 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
2535 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2536 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2537 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2538 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2539 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2540 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2541 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2542 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2543 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 30,
2544];
2545
2546pub static BASE64_MIME: Base64Wrap = unsafe { Base64Wrap::new_unchecked(BASE64_MIME_IMPL) };
2565const BASE64_MIME_IMPL: &[u8] = &[
2566 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2567 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2568 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2569 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2570 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2571 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2572 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2573 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2574 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2575 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2576 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2577 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2578 128, 128, 128, 128, 128, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2579 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2580 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2581 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
2582 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2583 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2584 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2585 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2586 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2587 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2588 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2589 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2590 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30, 76, 13, 10,
2591];
2592
2593pub static BASE64_MIME_PERMISSIVE: Base64Wrap =
2613 unsafe { Base64Wrap::new_unchecked(BASE64_MIME_PERMISSIVE_IMPL) };
2614const BASE64_MIME_PERMISSIVE_IMPL: &[u8] = &[
2615 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2616 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2617 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2618 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2619 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2620 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2621 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2622 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2623 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2624 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2625 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2626 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2627 128, 128, 128, 128, 128, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2628 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2629 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2630 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
2631 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2632 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2633 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2634 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2635 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2636 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2637 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2638 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2639 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 14, 76, 13, 10,
2640];
2641
2642pub static BASE64URL: Base64 = unsafe { Base64::new_unchecked(BASE64URL_IMPL) };
2658const BASE64URL_IMPL: &[u8] = &[
2659 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2660 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2661 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66,
2662 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2663 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2664 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67,
2665 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2666 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2667 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67, 68,
2668 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2669 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2670 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 128, 128, 128, 128,
2671 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2672 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2673 128, 128, 128, 62, 128, 128, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2674 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
2675 24, 25, 128, 128, 128, 128, 63, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2676 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2677 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2678 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2679 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2680 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2681 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2682 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2683 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30,
2684];
2685
2686pub static BASE64URL_NOPAD: Base64NoPad =
2697 unsafe { Base64NoPad::new_unchecked(BASE64URL_NOPAD_IMPL) };
2698const BASE64URL_NOPAD_IMPL: &[u8] = &[
2699 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2700 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2701 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66,
2702 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2703 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2704 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67,
2705 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2706 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2707 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67, 68,
2708 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2709 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2710 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 128, 128, 128, 128,
2711 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2712 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2713 128, 128, 128, 62, 128, 128, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 128, 128,
2714 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
2715 24, 25, 128, 128, 128, 128, 63, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2716 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2717 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2718 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2719 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2720 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2721 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2722 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2723 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 30,
2724];