1#![no_std]
146#![warn(unused_results, missing_docs)]
147
148#[cfg(feature = "alloc")]
149extern crate alloc;
150#[cfg(feature = "std")]
151extern crate std;
152
153#[cfg(feature = "alloc")]
154use alloc::borrow::{Cow, ToOwned};
155#[cfg(feature = "alloc")]
156use alloc::string::String;
157#[cfg(feature = "alloc")]
158use alloc::vec;
159#[cfg(feature = "alloc")]
160use alloc::vec::Vec;
161
162macro_rules! check {
163 ($e: expr, $c: expr) => {
164 if !$c {
165 return Err($e);
166 }
167 };
168}
169
170trait Static<T: Copy>: Copy {
171 fn val(self) -> T;
172}
173
174macro_rules! define {
175 ($name: ident: $type: ty = $val: expr) => {
176 #[derive(Copy, Clone)]
177 struct $name;
178 impl Static<$type> for $name {
179 fn val(self) -> $type {
180 $val
181 }
182 }
183 };
184}
185
186define!(Bf: bool = false);
187define!(Bt: bool = true);
188define!(N1: usize = 1);
189define!(N2: usize = 2);
190define!(N3: usize = 3);
191define!(N4: usize = 4);
192define!(N5: usize = 5);
193define!(N6: usize = 6);
194
195#[derive(Copy, Clone)]
196struct On;
197
198impl<T: Copy> Static<Option<T>> for On {
199 fn val(self) -> Option<T> {
200 None
201 }
202}
203
204#[derive(Copy, Clone)]
205struct Os<T>(T);
206
207impl<T: Copy> Static<Option<T>> for Os<T> {
208 fn val(self) -> Option<T> {
209 Some(self.0)
210 }
211}
212
213macro_rules! dispatch {
214 (let $var: ident: bool = $val: expr; $($body: tt)*) => {
215 if $val {
216 let $var = Bt; dispatch!($($body)*)
217 } else {
218 let $var = Bf; dispatch!($($body)*)
219 }
220 };
221 (let $var: ident: usize = $val: expr; $($body: tt)*) => {
222 match $val {
223 1 => { let $var = N1; dispatch!($($body)*) },
224 2 => { let $var = N2; dispatch!($($body)*) },
225 3 => { let $var = N3; dispatch!($($body)*) },
226 4 => { let $var = N4; dispatch!($($body)*) },
227 5 => { let $var = N5; dispatch!($($body)*) },
228 6 => { let $var = N6; dispatch!($($body)*) },
229 _ => panic!(),
230 }
231 };
232 (let $var: ident: Option<$type: ty> = $val: expr; $($body: tt)*) => {
233 match $val {
234 None => { let $var = On; dispatch!($($body)*) },
235 Some(x) => { let $var = Os(x); dispatch!($($body)*) },
236 }
237 };
238 ($body: expr) => { $body };
239}
240
241unsafe fn chunk_unchecked(x: &[u8], n: usize, i: usize) -> &[u8] {
242 debug_assert!((i + 1) * n <= x.len());
243 let ptr = x.as_ptr().add(n * i);
244 core::slice::from_raw_parts(ptr, n)
245}
246
247unsafe fn chunk_mut_unchecked(x: &mut [u8], n: usize, i: usize) -> &mut [u8] {
248 debug_assert!((i + 1) * n <= x.len());
249 let ptr = x.as_mut_ptr().add(n * i);
250 core::slice::from_raw_parts_mut(ptr, n)
251}
252
253unsafe fn as_array(x: &[u8]) -> &[u8; 256] {
254 debug_assert_eq!(x.len(), 256);
255 &*(x.as_ptr() as *const [u8; 256])
256}
257
258fn div_ceil(x: usize, m: usize) -> usize {
259 (x + m - 1) / m
260}
261
262fn floor(x: usize, m: usize) -> usize {
263 x / m * m
264}
265
266fn vectorize<F: FnMut(usize)>(n: usize, bs: usize, mut f: F) {
267 for k in 0 .. n / bs {
268 for i in k * bs .. (k + 1) * bs {
269 f(i);
270 }
271 }
272 for i in floor(n, bs) .. n {
273 f(i);
274 }
275}
276
277#[derive(Debug, Copy, Clone, PartialEq, Eq)]
279pub enum DecodeKind {
280 Length,
282
283 Symbol,
285
286 Trailing,
288
289 Padding,
291}
292
293impl core::fmt::Display for DecodeKind {
294 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
295 let description = match self {
296 DecodeKind::Length => "invalid length",
297 DecodeKind::Symbol => "invalid symbol",
298 DecodeKind::Trailing => "non-zero trailing bits",
299 DecodeKind::Padding => "invalid padding length",
300 };
301 write!(f, "{}", description)
302 }
303}
304
305#[derive(Debug, Copy, Clone, PartialEq, Eq)]
307pub struct DecodeError {
308 pub position: usize,
312
313 pub kind: DecodeKind,
315}
316
317#[cfg(feature = "std")]
318impl std::error::Error for DecodeError {}
319
320impl core::fmt::Display for DecodeError {
321 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
322 write!(f, "{} at {}", self.kind, self.position)
323 }
324}
325
326#[derive(Debug, Copy, Clone, PartialEq, Eq)]
328pub struct DecodePartial {
329 pub read: usize,
333
334 pub written: usize,
338
339 pub error: DecodeError,
341}
342
343const INVALID: u8 = 128;
344const IGNORE: u8 = 129;
345const PADDING: u8 = 130;
346
347fn order(msb: bool, n: usize, i: usize) -> usize {
348 if msb {
349 n - 1 - i
350 } else {
351 i
352 }
353}
354
355fn enc(bit: usize) -> usize {
356 debug_assert!(1 <= bit && bit <= 6);
357 match bit {
358 1 | 2 | 4 => 1,
359 3 | 6 => 3,
360 5 => 5,
361 _ => unreachable!(),
362 }
363}
364
365fn dec(bit: usize) -> usize {
366 enc(bit) * 8 / bit
367}
368
369fn encode_len<B: Static<usize>>(bit: B, len: usize) -> usize {
370 div_ceil(8 * len, bit.val())
371}
372
373fn encode_block<B: Static<usize>, M: Static<bool>>(
374 bit: B, msb: M, symbols: &[u8; 256], input: &[u8], output: &mut [u8],
375) {
376 debug_assert!(input.len() <= enc(bit.val()));
377 debug_assert_eq!(output.len(), encode_len(bit, input.len()));
378 let bit = bit.val();
379 let msb = msb.val();
380 let mut x = 0u64;
381 for (i, input) in input.iter().enumerate() {
382 x |= u64::from(*input) << (8 * order(msb, enc(bit), i));
383 }
384 for (i, output) in output.iter_mut().enumerate() {
385 let y = x >> (bit * order(msb, dec(bit), i));
386 *output = symbols[y as usize % 256];
387 }
388}
389
390fn encode_mut<B: Static<usize>, M: Static<bool>>(
391 bit: B, msb: M, symbols: &[u8; 256], input: &[u8], output: &mut [u8],
392) {
393 debug_assert_eq!(output.len(), encode_len(bit, input.len()));
394 let enc = enc(bit.val());
395 let dec = dec(bit.val());
396 let n = input.len() / enc;
397 let bs = match bit.val() {
398 5 => 2,
399 6 => 4,
400 _ => 1,
401 };
402 vectorize(n, bs, |i| {
403 let input = unsafe { chunk_unchecked(input, enc, i) };
404 let output = unsafe { chunk_mut_unchecked(output, dec, i) };
405 encode_block(bit, msb, symbols, input, output);
406 });
407 encode_block(bit, msb, symbols, &input[enc * n ..], &mut output[dec * n ..]);
408}
409
410fn decode_block<B: Static<usize>, M: Static<bool>>(
413 bit: B, msb: M, values: &[u8; 256], input: &[u8], output: &mut [u8],
414) -> Result<(), usize> {
415 debug_assert!(output.len() <= enc(bit.val()));
416 debug_assert_eq!(input.len(), encode_len(bit, output.len()));
417 let bit = bit.val();
418 let msb = msb.val();
419 let mut x = 0u64;
420 for j in 0 .. input.len() {
421 let y = values[input[j] as usize];
422 check!(j, y < 1 << bit);
423 x |= u64::from(y) << (bit * order(msb, dec(bit), j));
424 }
425 for (j, output) in output.iter_mut().enumerate() {
426 *output = (x >> (8 * order(msb, enc(bit), j))) as u8;
427 }
428 Ok(())
429}
430
431fn decode_mut<B: Static<usize>, M: Static<bool>>(
435 bit: B, msb: M, values: &[u8; 256], input: &[u8], output: &mut [u8],
436) -> Result<(), usize> {
437 debug_assert_eq!(input.len(), encode_len(bit, output.len()));
438 let enc = enc(bit.val());
439 let dec = dec(bit.val());
440 let n = input.len() / dec;
441 for i in 0 .. n {
442 let input = unsafe { chunk_unchecked(input, dec, i) };
443 let output = unsafe { chunk_mut_unchecked(output, enc, i) };
444 decode_block(bit, msb, values, input, output).map_err(|e| dec * i + e)?;
445 }
446 decode_block(bit, msb, values, &input[dec * n ..], &mut output[enc * n ..])
447 .map_err(|e| dec * n + e)
448}
449
450fn check_trail<B: Static<usize>, M: Static<bool>>(
452 bit: B, msb: M, ctb: bool, values: &[u8; 256], input: &[u8],
453) -> Result<(), ()> {
454 if 8 % bit.val() == 0 || !ctb {
455 return Ok(());
456 }
457 let trail = bit.val() * input.len() % 8;
458 if trail == 0 {
459 return Ok(());
460 }
461 let mut mask = (1 << trail) - 1;
462 if !msb.val() {
463 mask <<= bit.val() - trail;
464 }
465 check!((), values[input[input.len() - 1] as usize] & mask == 0);
466 Ok(())
467}
468
469fn check_pad<B: Static<usize>>(bit: B, values: &[u8; 256], input: &[u8]) -> Result<usize, usize> {
472 let bit = bit.val();
473 debug_assert_eq!(input.len(), dec(bit));
474 let is_pad = |x: &&u8| values[**x as usize] == PADDING;
475 let count = input.iter().rev().take_while(is_pad).count();
476 let len = input.len() - count;
477 check!(len, len > 0 && bit * len % 8 < bit);
478 Ok(len)
479}
480
481fn encode_base_len<B: Static<usize>>(bit: B, len: usize) -> usize {
482 encode_len(bit, len)
483}
484
485fn encode_base<B: Static<usize>, M: Static<bool>>(
486 bit: B, msb: M, symbols: &[u8; 256], input: &[u8], output: &mut [u8],
487) {
488 debug_assert_eq!(output.len(), encode_base_len(bit, input.len()));
489 encode_mut(bit, msb, symbols, input, output);
490}
491
492fn encode_pad_len<B: Static<usize>, P: Static<Option<u8>>>(bit: B, pad: P, len: usize) -> usize {
493 match pad.val() {
494 None => encode_base_len(bit, len),
495 Some(_) => div_ceil(len, enc(bit.val())) * dec(bit.val()),
496 }
497}
498
499fn encode_pad<B: Static<usize>, M: Static<bool>, P: Static<Option<u8>>>(
500 bit: B, msb: M, symbols: &[u8; 256], spad: P, input: &[u8], output: &mut [u8],
501) {
502 let pad = match spad.val() {
503 None => return encode_base(bit, msb, symbols, input, output),
504 Some(pad) => pad,
505 };
506 debug_assert_eq!(output.len(), encode_pad_len(bit, spad, input.len()));
507 let olen = encode_base_len(bit, input.len());
508 encode_base(bit, msb, symbols, input, &mut output[.. olen]);
509 for output in output.iter_mut().skip(olen) {
510 *output = pad;
511 }
512}
513
514fn encode_wrap_len<
515 'a,
516 B: Static<usize>,
517 P: Static<Option<u8>>,
518 W: Static<Option<(usize, &'a [u8])>>,
519>(
520 bit: B, pad: P, wrap: W, ilen: usize,
521) -> usize {
522 let olen = encode_pad_len(bit, pad, ilen);
523 match wrap.val() {
524 None => olen,
525 Some((col, end)) => olen + end.len() * div_ceil(olen, col),
526 }
527}
528
529fn encode_wrap_mut<
530 'a,
531 B: Static<usize>,
532 M: Static<bool>,
533 P: Static<Option<u8>>,
534 W: Static<Option<(usize, &'a [u8])>>,
535>(
536 bit: B, msb: M, symbols: &[u8; 256], pad: P, wrap: W, input: &[u8], output: &mut [u8],
537) {
538 let (col, end) = match wrap.val() {
539 None => return encode_pad(bit, msb, symbols, pad, input, output),
540 Some((col, end)) => (col, end),
541 };
542 debug_assert_eq!(output.len(), encode_wrap_len(bit, pad, wrap, input.len()));
543 debug_assert_eq!(col % dec(bit.val()), 0);
544 let col = col / dec(bit.val());
545 let enc = col * enc(bit.val());
546 let dec = col * dec(bit.val()) + end.len();
547 let olen = dec - end.len();
548 let n = input.len() / enc;
549 for i in 0 .. n {
550 let input = unsafe { chunk_unchecked(input, enc, i) };
551 let output = unsafe { chunk_mut_unchecked(output, dec, i) };
552 encode_base(bit, msb, symbols, input, &mut output[.. olen]);
553 output[olen ..].copy_from_slice(end);
554 }
555 if input.len() > enc * n {
556 let olen = dec * n + encode_pad_len(bit, pad, input.len() - enc * n);
557 encode_pad(bit, msb, symbols, pad, &input[enc * n ..], &mut output[dec * n .. olen]);
558 output[olen ..].copy_from_slice(end);
559 }
560}
561
562fn decode_wrap_len<B: Static<usize>, P: Static<bool>>(
564 bit: B, pad: P, len: usize,
565) -> (usize, usize) {
566 let bit = bit.val();
567 if pad.val() {
568 (floor(len, dec(bit)), len / dec(bit) * enc(bit))
569 } else {
570 let trail = bit * len % 8;
571 (len - trail / bit, bit * len / 8)
572 }
573}
574
575fn decode_pad_len<B: Static<usize>, P: Static<bool>>(
578 bit: B, pad: P, len: usize,
579) -> Result<usize, DecodeError> {
580 let (ilen, olen) = decode_wrap_len(bit, pad, len);
581 check!(DecodeError { position: ilen, kind: DecodeKind::Length }, ilen == len);
582 Ok(olen)
583}
584
585fn decode_base_len<B: Static<usize>>(bit: B, len: usize) -> Result<usize, DecodeError> {
588 decode_pad_len(bit, Bf, len)
589}
590
591fn decode_base_mut<B: Static<usize>, M: Static<bool>>(
595 bit: B, msb: M, ctb: bool, values: &[u8; 256], input: &[u8], output: &mut [u8],
596) -> Result<usize, DecodePartial> {
597 debug_assert_eq!(Ok(output.len()), decode_base_len(bit, input.len()));
598 let fail = |pos, kind| DecodePartial {
599 read: pos / dec(bit.val()) * dec(bit.val()),
600 written: pos / dec(bit.val()) * enc(bit.val()),
601 error: DecodeError { position: pos, kind },
602 };
603 decode_mut(bit, msb, values, input, output).map_err(|pos| fail(pos, DecodeKind::Symbol))?;
604 check_trail(bit, msb, ctb, values, input)
605 .map_err(|()| fail(input.len() - 1, DecodeKind::Trailing))?;
606 Ok(output.len())
607}
608
609fn decode_pad_mut<B: Static<usize>, M: Static<bool>, P: Static<bool>>(
615 bit: B, msb: M, ctb: bool, values: &[u8; 256], pad: P, input: &[u8], output: &mut [u8],
616) -> Result<usize, DecodePartial> {
617 if !pad.val() {
618 return decode_base_mut(bit, msb, ctb, values, input, output);
619 }
620 debug_assert_eq!(Ok(output.len()), decode_pad_len(bit, pad, input.len()));
621 let enc = enc(bit.val());
622 let dec = dec(bit.val());
623 let mut inpos = 0;
624 let mut outpos = 0;
625 let mut outend = output.len();
626 while inpos < input.len() {
627 match decode_base_mut(
628 bit,
629 msb,
630 ctb,
631 values,
632 &input[inpos ..],
633 &mut output[outpos .. outend],
634 ) {
635 Ok(written) => {
636 if cfg!(debug_assertions) {
637 inpos = input.len();
638 }
639 outpos += written;
640 break;
641 }
642 Err(partial) => {
643 inpos += partial.read;
644 outpos += partial.written;
645 }
646 }
647 let inlen =
648 check_pad(bit, values, &input[inpos .. inpos + dec]).map_err(|pos| DecodePartial {
649 read: inpos,
650 written: outpos,
651 error: DecodeError { position: inpos + pos, kind: DecodeKind::Padding },
652 })?;
653 let outlen = decode_base_len(bit, inlen).unwrap();
654 let written = decode_base_mut(
655 bit,
656 msb,
657 ctb,
658 values,
659 &input[inpos .. inpos + inlen],
660 &mut output[outpos .. outpos + outlen],
661 )
662 .map_err(|partial| {
663 debug_assert_eq!(partial.read, 0);
664 debug_assert_eq!(partial.written, 0);
665 DecodePartial {
666 read: inpos,
667 written: outpos,
668 error: DecodeError {
669 position: inpos + partial.error.position,
670 kind: partial.error.kind,
671 },
672 }
673 })?;
674 debug_assert_eq!(written, outlen);
675 inpos += dec;
676 outpos += outlen;
677 outend -= enc - outlen;
678 }
679 debug_assert_eq!(inpos, input.len());
680 debug_assert_eq!(outpos, outend);
681 Ok(outend)
682}
683
684fn skip_ignore(values: &[u8; 256], input: &[u8], mut inpos: usize) -> usize {
685 while inpos < input.len() && values[input[inpos] as usize] == IGNORE {
686 inpos += 1;
687 }
688 inpos
689}
690
691fn decode_wrap_block<B: Static<usize>, M: Static<bool>, P: Static<bool>>(
698 bit: B, msb: M, ctb: bool, values: &[u8; 256], pad: P, input: &[u8], output: &mut [u8],
699) -> Result<(usize, usize), DecodeError> {
700 let dec = dec(bit.val());
701 let mut buf = [0u8; 8];
702 let mut shift = [0usize; 8];
703 let mut bufpos = 0;
704 let mut inpos = 0;
705 while bufpos < dec {
706 inpos = skip_ignore(values, input, inpos);
707 if inpos == input.len() {
708 break;
709 }
710 shift[bufpos] = inpos;
711 buf[bufpos] = input[inpos];
712 bufpos += 1;
713 inpos += 1;
714 }
715 let olen = decode_pad_len(bit, pad, bufpos).map_err(|mut e| {
716 e.position = shift[e.position];
717 e
718 })?;
719 let written = decode_pad_mut(bit, msb, ctb, values, pad, &buf[.. bufpos], &mut output[.. olen])
720 .map_err(|partial| {
721 debug_assert_eq!(partial.read, 0);
722 debug_assert_eq!(partial.written, 0);
723 DecodeError { position: shift[partial.error.position], kind: partial.error.kind }
724 })?;
725 Ok((inpos, written))
726}
727
728#[allow(clippy::too_many_arguments)]
735fn decode_wrap_mut<B: Static<usize>, M: Static<bool>, P: Static<bool>, I: Static<bool>>(
736 bit: B, msb: M, ctb: bool, values: &[u8; 256], pad: P, has_ignore: I, input: &[u8],
737 output: &mut [u8],
738) -> Result<usize, DecodePartial> {
739 if !has_ignore.val() {
740 return decode_pad_mut(bit, msb, ctb, values, pad, input, output);
741 }
742 debug_assert_eq!(output.len(), decode_wrap_len(bit, pad, input.len()).1);
743 let mut inpos = 0;
744 let mut outpos = 0;
745 while inpos < input.len() {
746 let (inlen, outlen) = decode_wrap_len(bit, pad, input.len() - inpos);
747 match decode_pad_mut(
748 bit,
749 msb,
750 ctb,
751 values,
752 pad,
753 &input[inpos .. inpos + inlen],
754 &mut output[outpos .. outpos + outlen],
755 ) {
756 Ok(written) => {
757 inpos += inlen;
758 outpos += written;
759 break;
760 }
761 Err(partial) => {
762 inpos += partial.read;
763 outpos += partial.written;
764 }
765 }
766 let (ipos, opos) =
767 decode_wrap_block(bit, msb, ctb, values, pad, &input[inpos ..], &mut output[outpos ..])
768 .map_err(|mut error| {
769 error.position += inpos;
770 DecodePartial { read: inpos, written: outpos, error }
771 })?;
772 inpos += ipos;
773 outpos += opos;
774 }
775 let inpos = skip_ignore(values, input, inpos);
776 if inpos == input.len() {
777 Ok(outpos)
778 } else {
779 Err(DecodePartial {
780 read: inpos,
781 written: outpos,
782 error: DecodeError { position: inpos, kind: DecodeKind::Length },
783 })
784 }
785}
786
787#[derive(Debug, Copy, Clone, PartialEq, Eq)]
817#[cfg(feature = "alloc")]
818pub enum BitOrder {
819 MostSignificantFirst,
828
829 LeastSignificantFirst,
843}
844#[cfg(feature = "alloc")]
845use crate::BitOrder::*;
846
847#[doc(hidden)]
848#[cfg(feature = "alloc")]
849pub type InternalEncoding = Cow<'static, [u8]>;
850
851#[doc(hidden)]
852#[cfg(not(feature = "alloc"))]
853pub type InternalEncoding = &'static [u8];
854
855#[derive(Debug, Clone, PartialEq, Eq)]
878pub struct Encoding(pub InternalEncoding);
879
880#[derive(Debug, Clone)]
891#[cfg(feature = "alloc")]
892pub struct Translate {
893 pub from: String,
895
896 pub to: String,
898}
899
900#[derive(Debug, Clone)]
908#[cfg(feature = "alloc")]
909pub struct Wrap {
910 pub width: usize,
920
921 pub separator: String,
925}
926
927#[derive(Debug, Clone)]
1168#[cfg(feature = "alloc")]
1169pub struct Specification {
1170 pub symbols: String,
1175
1176 pub bit_order: BitOrder,
1180
1181 pub check_trailing_bits: bool,
1186
1187 pub padding: Option<char>,
1192
1193 pub ignore: String,
1198
1199 pub wrap: Wrap,
1204
1205 pub translate: Translate,
1212}
1213
1214#[cfg(feature = "alloc")]
1215impl Default for Specification {
1216 fn default() -> Self {
1217 Self::new()
1218 }
1219}
1220
1221impl Encoding {
1222 fn sym(&self) -> &[u8; 256] {
1223 unsafe { as_array(&self.0[0 .. 256]) }
1224 }
1225
1226 fn val(&self) -> &[u8; 256] {
1227 unsafe { as_array(&self.0[256 .. 512]) }
1228 }
1229
1230 fn pad(&self) -> Option<u8> {
1231 if self.0[512] < 128 {
1232 Some(self.0[512])
1233 } else {
1234 None
1235 }
1236 }
1237
1238 fn ctb(&self) -> bool {
1239 self.0[513] & 0x10 != 0
1240 }
1241
1242 fn msb(&self) -> bool {
1243 self.0[513] & 0x8 != 0
1244 }
1245
1246 fn bit(&self) -> usize {
1247 (self.0[513] & 0x7) as usize
1248 }
1249
1250 fn wrap(&self) -> Option<(usize, &[u8])> {
1251 if self.0.len() <= 515 {
1252 return None;
1253 }
1254 Some((self.0[514] as usize, &self.0[515 ..]))
1255 }
1256
1257 fn has_ignore(&self) -> bool {
1258 self.0.len() >= 515
1259 }
1260
1261 pub fn encode_len(&self, len: usize) -> usize {
1267 dispatch! {
1268 let bit: usize = self.bit();
1269 let pad: Option<u8> = self.pad();
1270 let wrap: Option<(usize, &[u8])> = self.wrap();
1271 encode_wrap_len(bit, pad, wrap, len)
1272 }
1273 }
1274
1275 #[allow(clippy::cognitive_complexity)]
1295 pub fn encode_mut(&self, input: &[u8], output: &mut [u8]) {
1296 assert_eq!(output.len(), self.encode_len(input.len()));
1297 dispatch! {
1298 let bit: usize = self.bit();
1299 let msb: bool = self.msb();
1300 let pad: Option<u8> = self.pad();
1301 let wrap: Option<(usize, &[u8])> = self.wrap();
1302 encode_wrap_mut(bit, msb, self.sym(), pad, wrap, input, output)
1303 }
1304 }
1305
1306 #[cfg(feature = "alloc")]
1323 pub fn encode_append(&self, input: &[u8], output: &mut String) {
1324 let output = unsafe { output.as_mut_vec() };
1325 let output_len = output.len();
1326 output.resize(output_len + self.encode_len(input.len()), 0u8);
1327 self.encode_mut(input, &mut output[output_len ..]);
1328 }
1329
1330 #[cfg(feature = "alloc")]
1343 pub fn encode(&self, input: &[u8]) -> String {
1344 let mut output = vec![0u8; self.encode_len(input.len())];
1345 self.encode_mut(input, &mut output);
1346 unsafe { String::from_utf8_unchecked(output) }
1347 }
1348
1349 pub fn decode_len(&self, len: usize) -> Result<usize, DecodeError> {
1362 let (ilen, olen) = dispatch! {
1363 let bit: usize = self.bit();
1364 let pad: bool = self.pad().is_some();
1365 decode_wrap_len(bit, pad, len)
1366 };
1367 check!(
1368 DecodeError { position: ilen, kind: DecodeKind::Length },
1369 self.has_ignore() || len == ilen
1370 );
1371 Ok(olen)
1372 }
1373
1374 #[allow(clippy::cognitive_complexity)]
1412 pub fn decode_mut(&self, input: &[u8], output: &mut [u8]) -> Result<usize, DecodePartial> {
1413 assert_eq!(Ok(output.len()), self.decode_len(input.len()));
1414 dispatch! {
1415 let bit: usize = self.bit();
1416 let msb: bool = self.msb();
1417 let pad: bool = self.pad().is_some();
1418 let has_ignore: bool = self.has_ignore();
1419 decode_wrap_mut(bit, msb, self.ctb(), self.val(), pad, has_ignore,
1420 input, output)
1421 }
1422 }
1423
1424 #[cfg(feature = "alloc")]
1458 pub fn decode(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError> {
1459 let mut output = vec![0u8; self.decode_len(input.len())?];
1460 let len = self.decode_mut(input, &mut output).map_err(|partial| partial.error)?;
1461 output.truncate(len);
1462 Ok(output)
1463 }
1464
1465 pub fn bit_width(&self) -> usize {
1467 self.bit()
1468 }
1469
1470 pub fn is_canonical(&self) -> bool {
1479 if !self.ctb() {
1480 return false;
1481 }
1482 let bit = self.bit();
1483 let sym = self.sym();
1484 let val = self.val();
1485 for i in 0 .. 256 {
1486 if val[i] == INVALID {
1487 continue;
1488 }
1489 if val[i] >= 1 << bit {
1490 return false;
1491 }
1492 if sym[val[i] as usize] != i as u8 {
1493 return false;
1494 }
1495 }
1496 true
1497 }
1498
1499 #[cfg(feature = "alloc")]
1505 pub fn specification(&self) -> Specification {
1506 let mut specification = Specification::new();
1507 specification
1508 .symbols
1509 .push_str(core::str::from_utf8(&self.sym()[0 .. 1 << self.bit()]).unwrap());
1510 specification.bit_order =
1511 if self.msb() { MostSignificantFirst } else { LeastSignificantFirst };
1512 specification.check_trailing_bits = self.ctb();
1513 if let Some(pad) = self.pad() {
1514 specification.padding = Some(pad as char);
1515 }
1516 for i in 0 .. 128u8 {
1517 if self.val()[i as usize] != IGNORE {
1518 continue;
1519 }
1520 specification.ignore.push(i as char);
1521 }
1522 if let Some((col, end)) = self.wrap() {
1523 specification.wrap.width = col;
1524 specification.wrap.separator = core::str::from_utf8(end).unwrap().to_owned();
1525 }
1526 for i in 0 .. 128u8 {
1527 let canonical = if self.val()[i as usize] < 1 << self.bit() {
1528 self.sym()[self.val()[i as usize] as usize]
1529 } else if self.val()[i as usize] == PADDING {
1530 self.pad().unwrap()
1531 } else {
1532 continue;
1533 };
1534 if i == canonical {
1535 continue;
1536 }
1537 specification.translate.from.push(i as char);
1538 specification.translate.to.push(canonical as char);
1539 }
1540 specification
1541 }
1542
1543 #[doc(hidden)]
1544 pub const fn internal_new(implementation: &'static [u8]) -> Encoding {
1545 #[cfg(feature = "alloc")]
1546 let encoding = Encoding(Cow::Borrowed(implementation));
1547 #[cfg(not(feature = "alloc"))]
1548 let encoding = Encoding(implementation);
1549 encoding
1550 }
1551
1552 #[doc(hidden)]
1553 pub fn internal_implementation(&self) -> &[u8] {
1554 &self.0
1555 }
1556}
1557
1558#[derive(Debug, Copy, Clone)]
1559#[cfg(feature = "alloc")]
1560enum SpecificationErrorImpl {
1561 BadSize,
1562 NotAscii,
1563 Duplicate(u8),
1564 ExtraPadding,
1565 WrapLength,
1566 WrapWidth(u8),
1567 FromTo,
1568 Undefined(u8),
1569}
1570#[cfg(feature = "alloc")]
1571use crate::SpecificationErrorImpl::*;
1572
1573#[derive(Debug, Copy, Clone)]
1579#[cfg(feature = "alloc")]
1580pub struct SpecificationError(SpecificationErrorImpl);
1581
1582#[cfg(feature = "alloc")]
1583impl core::fmt::Display for SpecificationError {
1584 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1585 match self.0 {
1586 BadSize => write!(f, "invalid number of symbols"),
1587 NotAscii => write!(f, "non-ascii character"),
1588 Duplicate(c) => write!(f, "{:?} has conflicting definitions", c as char),
1589 ExtraPadding => write!(f, "unnecessary padding"),
1590 WrapLength => write!(f, "invalid wrap width or separator length"),
1591 WrapWidth(x) => write!(f, "wrap width not a multiple of {}", x),
1592 FromTo => write!(f, "translate from/to length mismatch"),
1593 Undefined(c) => write!(f, "{:?} is undefined", c as char),
1594 }
1595 }
1596}
1597
1598#[cfg(feature = "std")]
1599impl std::error::Error for SpecificationError {
1600 fn description(&self) -> &str {
1601 match self.0 {
1602 BadSize => "invalid number of symbols",
1603 NotAscii => "non-ascii character",
1604 Duplicate(_) => "conflicting definitions",
1605 ExtraPadding => "unnecessary padding",
1606 WrapLength => "invalid wrap width or separator length",
1607 WrapWidth(_) => "wrap width not a multiple",
1608 FromTo => "translate from/to length mismatch",
1609 Undefined(_) => "undefined character",
1610 }
1611 }
1612}
1613
1614#[cfg(feature = "alloc")]
1615impl Specification {
1616 pub fn new() -> Specification {
1618 Specification {
1619 symbols: String::new(),
1620 bit_order: MostSignificantFirst,
1621 check_trailing_bits: true,
1622 padding: None,
1623 ignore: String::new(),
1624 wrap: Wrap { width: 0, separator: String::new() },
1625 translate: Translate { from: String::new(), to: String::new() },
1626 }
1627 }
1628
1629 pub fn encoding(&self) -> Result<Encoding, SpecificationError> {
1635 let symbols = self.symbols.as_bytes();
1636 let bit: usize = match symbols.len() {
1637 2 => 1,
1638 4 => 2,
1639 8 => 3,
1640 16 => 4,
1641 32 => 5,
1642 64 => 6,
1643 _ => return Err(SpecificationError(BadSize)),
1644 };
1645 let mut values = [INVALID; 128];
1646 let set = |v: &mut [u8; 128], i: u8, x: u8| {
1647 check!(SpecificationError(NotAscii), i < 128);
1648 if v[i as usize] == x {
1649 return Ok(());
1650 }
1651 check!(SpecificationError(Duplicate(i)), v[i as usize] == INVALID);
1652 v[i as usize] = x;
1653 Ok(())
1654 };
1655 for (v, symbols) in symbols.iter().enumerate() {
1656 set(&mut values, *symbols, v as u8)?;
1657 }
1658 let msb = self.bit_order == MostSignificantFirst;
1659 let ctb = self.check_trailing_bits || 8 % bit == 0;
1660 let pad = match self.padding {
1661 None => None,
1662 Some(pad) => {
1663 check!(SpecificationError(ExtraPadding), 8 % bit != 0);
1664 check!(SpecificationError(NotAscii), pad.len_utf8() == 1);
1665 set(&mut values, pad as u8, PADDING)?;
1666 Some(pad as u8)
1667 }
1668 };
1669 for i in self.ignore.bytes() {
1670 set(&mut values, i, IGNORE)?;
1671 }
1672 let wrap = if self.wrap.separator.is_empty() || self.wrap.width == 0 {
1673 None
1674 } else {
1675 Some((self.wrap.width, self.wrap.separator.as_bytes()))
1676 };
1677 if let Some((col, end)) = wrap {
1678 check!(SpecificationError(WrapLength), col < 256 && end.len() < 256);
1679 check!(SpecificationError(WrapWidth(dec(bit) as u8)), col % dec(bit) == 0);
1680 for i in end.iter() {
1681 set(&mut values, *i, IGNORE)?;
1682 }
1683 }
1684 let from = self.translate.from.as_bytes();
1685 let to = self.translate.to.as_bytes();
1686 check!(SpecificationError(FromTo), from.len() == to.len());
1687 for i in 0 .. from.len() {
1688 check!(SpecificationError(NotAscii), to[i] < 128);
1689 let v = values[to[i] as usize];
1690 check!(SpecificationError(Undefined(to[i])), v != INVALID);
1691 set(&mut values, from[i], v)?;
1692 }
1693 let mut encoding = Vec::new();
1694 for _ in 0 .. 256 / symbols.len() {
1695 encoding.extend_from_slice(symbols);
1696 }
1697 encoding.extend_from_slice(&values);
1698 encoding.extend_from_slice(&[INVALID; 128]);
1699 match pad {
1700 None => encoding.push(INVALID),
1701 Some(pad) => encoding.push(pad),
1702 }
1703 encoding.push(bit as u8);
1704 if msb {
1705 encoding[513] |= 0x08;
1706 }
1707 if ctb {
1708 encoding[513] |= 0x10;
1709 }
1710 if let Some((col, end)) = wrap {
1711 encoding.push(col as u8);
1712 encoding.extend_from_slice(end);
1713 } else if values.contains(&IGNORE) {
1714 encoding.push(0);
1715 }
1716 Ok(Encoding(Cow::Owned(encoding)))
1717 }
1718}
1719
1720pub const HEXLOWER: Encoding = Encoding::internal_new(HEXLOWER_IMPL);
1740const HEXLOWER_IMPL: &[u8] = &[
1741 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54,
1742 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
1743 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
1744 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
1745 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
1746 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
1747 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
1748 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
1749 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
1750 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
1751 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
1752 56, 57, 97, 98, 99, 100, 101, 102, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1753 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1754 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 1, 2,
1755 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1756 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1757 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1758 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1759 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1760 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1761 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1762 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1763 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1764 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1765 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
1766];
1767
1768pub const HEXLOWER_PERMISSIVE: Encoding = Encoding::internal_new(HEXLOWER_PERMISSIVE_IMPL);
1797const HEXLOWER_PERMISSIVE_IMPL: &[u8] = &[
1798 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54,
1799 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
1800 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
1801 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
1802 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
1803 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
1804 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,
1805 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,
1806 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,
1807 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,
1808 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,
1809 56, 57, 97, 98, 99, 100, 101, 102, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1810 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1811 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 1, 2,
1812 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128,
1813 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1814 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1815 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1816 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1817 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1818 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1819 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1820 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1821 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1822 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
1823];
1824
1825pub const HEXUPPER: Encoding = Encoding::internal_new(HEXUPPER_IMPL);
1849const HEXUPPER_IMPL: &[u8] = &[
1850 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1851 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1852 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1853 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1854 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1855 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1856 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1857 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1858 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1859 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1860 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 128, 128, 128, 128, 128, 128,
1861 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1862 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1863 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,
1864 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1865 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1866 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1867 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1868 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1869 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1870 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1871 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1872 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1873 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
1874];
1875
1876pub const HEXUPPER_PERMISSIVE: Encoding = Encoding::internal_new(HEXUPPER_PERMISSIVE_IMPL);
1898const HEXUPPER_PERMISSIVE_IMPL: &[u8] = &[
1899 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1900 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1901 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1902 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1903 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1904 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1905 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1906 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1907 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,
1908 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
1909 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 128, 128, 128, 128, 128, 128,
1910 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1911 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1912 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,
1913 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1914 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128,
1915 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1916 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1917 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1918 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1919 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1920 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1921 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1922 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,
1923];
1924
1925pub const BASE32: Encoding = Encoding::internal_new(BASE32_IMPL);
1941const BASE32_IMPL: &[u8] = &[
1942 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1943 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1944 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
1945 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
1946 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1947 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1948 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
1949 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
1950 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1951 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1952 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,
1953 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1954 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1955 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 130, 128, 128,
1956 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,
1957 25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1958 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1959 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1960 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1961 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1962 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1963 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1964 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1965 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 29,
1966];
1967
1968pub const BASE32_NOPAD: Encoding = Encoding::internal_new(BASE32_NOPAD_IMPL);
1979const BASE32_NOPAD_IMPL: &[u8] = &[
1980 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1981 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1982 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
1983 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
1984 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1985 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1986 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
1987 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
1988 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1989 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1990 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,
1991 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1992 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1993 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128,
1994 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,
1995 25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1996 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1997 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1998 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
1999 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2000 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2001 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2002 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2003 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2004];
2005
2006pub const BASE32HEX: Encoding = Encoding::internal_new(BASE32HEX_IMPL);
2022const BASE32HEX_IMPL: &[u8] = &[
2023 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2024 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2025 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2026 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2027 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2028 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2029 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2030 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2031 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2032 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2033 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 128, 128, 128, 128, 128, 128,
2034 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 130, 128, 128, 128, 10, 11,
2037 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 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, 128, 128, 128, 128, 128, 128, 128,
2043 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2044 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2045 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2046 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 29,
2047];
2048
2049pub const BASE32HEX_NOPAD: Encoding = Encoding::internal_new(BASE32HEX_NOPAD_IMPL);
2060const BASE32HEX_NOPAD_IMPL: &[u8] = &[
2061 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2062 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2063 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2064 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2065 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2066 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2067 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,
2068 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2069 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2070 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,
2071 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 128, 128, 128, 128, 128, 128,
2072 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2073 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2074 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,
2075 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128,
2076 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2077 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2078 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2079 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2080 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2081 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2082 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2083 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2084 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2085];
2086
2087pub const BASE32_DNSSEC: Encoding = Encoding::internal_new(BASE32_DNSSEC_IMPL);
2108const BASE32_DNSSEC_IMPL: &[u8] = &[
2109 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
2110 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
2111 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2112 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104,
2113 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53,
2114 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
2115 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101,
2116 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49,
2117 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
2118 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98,
2119 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2120 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
2121 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 128, 128, 128, 128, 128, 128, 128,
2122 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2123 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2124 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13,
2125 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128,
2126 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
2127 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2128 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2129 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2130 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2131 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2132 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2133 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2134 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2135];
2136
2137pub const BASE32_DNSCURVE: Encoding = Encoding::internal_new(BASE32_DNSCURVE_IMPL);
2155const BASE32_DNSCURVE_IMPL: &[u8] = &[
2156 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110,
2157 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
2158 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119,
2159 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107,
2160 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53,
2161 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116,
2162 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103,
2163 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49,
2164 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113,
2165 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99,
2166 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2167 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109,
2168 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 128, 128, 128, 128, 128, 128, 128,
2169 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2170 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2171 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128, 10, 11,
2172 12, 128, 13, 14, 15, 128, 16, 17, 18, 19, 20, 128, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
2173 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 128, 13, 14, 15, 128, 16, 17, 18, 19, 20, 128,
2174 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2175 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2176 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2177 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2178 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2179 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2180 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2181 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 21,
2182];
2183
2184pub const BASE64: Encoding = Encoding::internal_new(BASE64_IMPL);
2200const BASE64_IMPL: &[u8] = &[
2201 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2202 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2203 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2204 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2205 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2206 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2207 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2208 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2209 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2210 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2211 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2212 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2213 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2214 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2215 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2216 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,
2217 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2218 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2219 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2220 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2221 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2222 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2223 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2224 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2225 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30,
2226];
2227
2228pub const BASE64_NOPAD: Encoding = Encoding::internal_new(BASE64_NOPAD_IMPL);
2239const BASE64_NOPAD_IMPL: &[u8] = &[
2240 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2241 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2242 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2243 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2244 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2245 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2246 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2247 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2248 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2249 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2250 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2251 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2252 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2253 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2254 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 128, 128,
2255 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,
2256 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2257 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2258 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2259 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2260 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2261 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2262 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2263 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2264 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 30,
2265];
2266
2267pub const BASE64_MIME: Encoding = Encoding::internal_new(BASE64_MIME_IMPL);
2286const BASE64_MIME_IMPL: &[u8] = &[
2287 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2288 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2289 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,
2290 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2291 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2292 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,
2293 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2294 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2295 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,
2296 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2297 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2298 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,
2299 128, 128, 128, 128, 128, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2300 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2301 128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2302 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,
2303 24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2304 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2305 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2306 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2307 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2308 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2309 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 61, 30, 76, 13, 10,
2312];
2313
2314pub const BASE64URL: Encoding = Encoding::internal_new(BASE64URL_IMPL);
2330const BASE64URL_IMPL: &[u8] = &[
2331 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2332 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2333 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66,
2334 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2335 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2336 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67,
2337 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2338 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2339 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67, 68,
2340 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2341 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2342 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 128, 128, 128, 128,
2343 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2344 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2345 128, 128, 128, 62, 128, 128, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,
2346 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,
2347 24, 25, 128, 128, 128, 128, 63, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2348 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2352 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 61, 30,
2356];
2357
2358pub const BASE64URL_NOPAD: Encoding = Encoding::internal_new(BASE64URL_NOPAD_IMPL);
2369const BASE64URL_NOPAD_IMPL: &[u8] = &[
2370 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2371 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2372 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66,
2373 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2374 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2375 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67,
2376 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,
2377 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2378 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67, 68,
2379 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,
2380 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2381 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 128, 128, 128, 128,
2382 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2383 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2384 128, 128, 128, 62, 128, 128, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 128, 128,
2385 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,
2386 24, 25, 128, 128, 128, 128, 63, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
2387 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2388 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2389 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2390 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2391 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2392 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2393 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2394 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 30,
2395];