/rust/registry/src/index.crates.io-1949cf8c6b5b557f/data-encoding-2.9.0/src/lib.rs
Line  | Count  | Source  | 
1  |  | //! Efficient and customizable data-encoding functions like base64, base32, and hex  | 
2  |  | //!  | 
3  |  | //! This [crate] provides little-endian ASCII base-conversion encodings for  | 
4  |  | //! bases of size 2, 4, 8, 16, 32, and 64. It supports:  | 
5  |  | //!  | 
6  |  | //! - [padding] for streaming  | 
7  |  | //! - canonical encodings (e.g. [trailing bits] are checked)  | 
8  |  | //! - in-place [encoding] and [decoding] functions  | 
9  |  | //! - partial [decoding] functions (e.g. for error recovery)  | 
10  |  | //! - character [translation] (e.g. for case-insensitivity)  | 
11  |  | //! - most and least significant [bit-order]  | 
12  |  | //! - [ignoring] characters when decoding (e.g. for skipping newlines)  | 
13  |  | //! - [wrapping] the output when encoding  | 
14  |  | //! - no-std environments with `default-features = false, features = ["alloc"]`  | 
15  |  | //! - no-alloc environments with `default-features = false`  | 
16  |  | //!  | 
17  |  | //! You may use the [binary] or the [website] to play around.  | 
18  |  | //!  | 
19  |  | //! # Examples  | 
20  |  | //!  | 
21  |  | //! This crate provides predefined encodings as [constants]. These constants are of type  | 
22  |  | //! [`Encoding`]. This type provides encoding and decoding functions with in-place or allocating  | 
23  |  | //! variants. Here is an example using the allocating encoding function of [`BASE64`]:  | 
24  |  | //!  | 
25  |  | //! ```rust  | 
26  |  | //! use data_encoding::BASE64;  | 
27  |  | //! assert_eq!(BASE64.encode(b"Hello world"), "SGVsbG8gd29ybGQ=");  | 
28  |  | //! ```  | 
29  |  | //!  | 
30  |  | //! Here is an example using the in-place decoding function of [`BASE32`]:  | 
31  |  | //!  | 
32  |  | //! ```rust  | 
33  |  | //! use data_encoding::BASE32;  | 
34  |  | //! let input = b"JBSWY3DPEB3W64TMMQ======";  | 
35  |  | //! let mut output = vec![0; BASE32.decode_len(input.len()).unwrap()];  | 
36  |  | //! let len = BASE32.decode_mut(input, &mut output).unwrap();  | 
37  |  | //! assert_eq!(&output[0 .. len], b"Hello world");  | 
38  |  | //! ```  | 
39  |  | //!  | 
40  |  | //! You are not limited to the predefined encodings. You may define your own encodings (with the  | 
41  |  | //! same correctness and performance properties as the predefined ones) using the [`Specification`]  | 
42  |  | //! type:  | 
43  |  | //!  | 
44  |  | //! ```rust  | 
45  |  | //! use data_encoding::Specification;  | 
46  |  | //! let hex = { | 
47  |  | //!     let mut spec = Specification::new();  | 
48  |  | //!     spec.symbols.push_str("0123456789abcdef"); | 
49  |  | //!     spec.encoding().unwrap()  | 
50  |  | //! };  | 
51  |  | //! assert_eq!(hex.encode(b"hello"), "68656c6c6f");  | 
52  |  | //! ```  | 
53  |  | //!  | 
54  |  | //! You may use the [macro] library to define a compile-time custom encoding:  | 
55  |  | //!  | 
56  |  | //! ```rust,ignore  | 
57  |  | //! use data_encoding::Encoding;  | 
58  |  | //! use data_encoding_macro::new_encoding;  | 
59  |  | //! const HEX: Encoding = new_encoding!{ | 
60  |  | //!     symbols: "0123456789abcdef",  | 
61  |  | //!     translate_from: "ABCDEF",  | 
62  |  | //!     translate_to: "abcdef",  | 
63  |  | //! };  | 
64  |  | //! const BASE64: Encoding = new_encoding!{ | 
65  |  | //!     symbols: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",  | 
66  |  | //!     padding: '=',  | 
67  |  | //! };  | 
68  |  | //! ```  | 
69  |  | //!  | 
70  |  | //! # Properties  | 
71  |  | //!  | 
72  |  | //! The [`HEXUPPER`], [`BASE32`], [`BASE32HEX`], [`BASE64`], and [`BASE64URL`] predefined encodings  | 
73  |  | //! conform to [RFC4648].  | 
74  |  | //!  | 
75  |  | //! In general, the encoding and decoding functions satisfy the following properties:  | 
76  |  | //!  | 
77  |  | //! - They are deterministic: their output only depends on their input  | 
78  |  | //! - They have no side-effects: they do not modify any hidden mutable state  | 
79  |  | //! - They are correct: encoding followed by decoding gives the initial data  | 
80  |  | //! - They are canonical (unless [`is_canonical`] returns false): decoding followed by encoding  | 
81  |  | //!   gives the initial data  | 
82  |  | //!  | 
83  |  | //! This last property is usually not satisfied by base64 implementations. This is a matter of  | 
84  |  | //! choice and this crate has made the choice to let the user choose. Support for canonical encoding  | 
85  |  | //! as described by the [RFC][canonical] is provided. But it is also possible to disable checking  | 
86  |  | //! trailing bits, to add characters translation, to decode concatenated padded inputs, and to  | 
87  |  | //! ignore some characters. Note that non-canonical encodings may be an attack vector as described  | 
88  |  | //! in [Base64 Malleability in Practice](https://eprint.iacr.org/2022/361.pdf).  | 
89  |  | //!  | 
90  |  | //! Since the RFC specifies the encoding function on all inputs and the decoding function on all  | 
91  |  | //! possible encoded outputs, the differences between implementations come from the decoding  | 
92  |  | //! function which may be more or less permissive. In this crate, the decoding function of canonical  | 
93  |  | //! encodings rejects all inputs that are not a possible output of the encoding function. Here are  | 
94  |  | //! some concrete examples of decoding differences between this crate, the `base64` crate, and the  | 
95  |  | //! `base64` GNU program:  | 
96  |  | //!  | 
97  |  | //! | Input      | `data-encoding` | `base64`  | GNU `base64`  |  | 
98  |  | //! | ---------- | --------------- | --------- | ------------- |  | 
99  |  | //! | `AAB=`     | `Trailing(2)`   | `Last(2)` | `\x00\x00`    |  | 
100  |  | //! | `AA\nB=`   | `Length(4)`     | `Byte(2)` | `\x00\x00`    |  | 
101  |  | //! | `AAB`      | `Length(0)`     | `Padding` | Invalid input |  | 
102  |  | //! | `AAA`      | `Length(0)`     | `Padding` | Invalid input |  | 
103  |  | //! | `A\rA\nB=` | `Length(4)`     | `Byte(1)` | Invalid input |  | 
104  |  | //! | `-_\r\n`   | `Symbol(0)`     | `Byte(0)` | Invalid input |  | 
105  |  | //! | `AA==AA==` | `[0, 0]`        | `Byte(2)` | `\x00\x00`    |  | 
106  |  | //!  | 
107  |  | //! We can summarize these discrepancies as follows:  | 
108  |  | //!  | 
109  |  | //! | Discrepancy                | `data-encoding` | `base64` | GNU `base64` |  | 
110  |  | //! | -------------------------- | --------------- | -------- | ------------ |  | 
111  |  | //! | Check trailing bits        | Yes             | Yes      | No           |  | 
112  |  | //! | Ignored characters         | None            | None     | `\n`         |  | 
113  |  | //! | Translated characters      | None            | None     | None         |  | 
114  |  | //! | Check padding              | Yes             | No       | Yes          |  | 
115  |  | //! | Support concatenated input | Yes             | No       | Yes          |  | 
116  |  | //!  | 
117  |  | //! This crate permits to disable checking trailing bits. It permits to ignore some characters. It  | 
118  |  | //! permits to translate characters. It permits to use unpadded encodings. However, for padded  | 
119  |  | //! encodings, support for concatenated inputs cannot be disabled. This is simply because it doesn't  | 
120  |  | //! make sense to use padding if it is not to support concatenated inputs.  | 
121  |  | //!  | 
122  |  | //! [RFC4648]: https://tools.ietf.org/html/rfc4648  | 
123  |  | //! [`BASE32HEX`]: constant.BASE32HEX.html  | 
124  |  | //! [`BASE32`]: constant.BASE32.html  | 
125  |  | //! [`BASE64URL`]: constant.BASE64URL.html  | 
126  |  | //! [`BASE64`]: constant.BASE64.html  | 
127  |  | //! [`Encoding`]: struct.Encoding.html  | 
128  |  | //! [`HEXUPPER`]: constant.HEXUPPER.html  | 
129  |  | //! [`Specification`]: struct.Specification.html  | 
130  |  | //! [`is_canonical`]: struct.Encoding.html#method.is_canonical  | 
131  |  | //! [binary]: https://crates.io/crates/data-encoding-bin  | 
132  |  | //! [bit-order]: struct.Specification.html#structfield.bit_order  | 
133  |  | //! [canonical]: https://tools.ietf.org/html/rfc4648#section-3.5  | 
134  |  | //! [constants]: index.html#constants  | 
135  |  | //! [crate]: https://crates.io/crates/data-encoding  | 
136  |  | //! [decoding]: struct.Encoding.html#method.decode_mut  | 
137  |  | //! [encoding]: struct.Encoding.html#method.encode_mut  | 
138  |  | //! [ignoring]: struct.Specification.html#structfield.ignore  | 
139  |  | //! [macro]: https://crates.io/crates/data-encoding-macro  | 
140  |  | //! [padding]: struct.Specification.html#structfield.padding  | 
141  |  | //! [trailing bits]: struct.Specification.html#structfield.check_trailing_bits  | 
142  |  | //! [translation]: struct.Specification.html#structfield.translate  | 
143  |  | //! [website]: https://data-encoding.rs  | 
144  |  | //! [wrapping]: struct.Specification.html#structfield.wrap  | 
145  |  |  | 
146  |  | #![no_std]  | 
147  |  | #![cfg_attr(docsrs, feature(doc_auto_cfg))]  | 
148  |  |  | 
149  |  | #[cfg(feature = "alloc")]  | 
150  |  | extern crate alloc;  | 
151  |  | #[cfg(feature = "std")]  | 
152  |  | extern crate std;  | 
153  |  |  | 
154  |  | #[cfg(feature = "alloc")]  | 
155  |  | use alloc::borrow::{Cow, ToOwned}; | 
156  |  | #[cfg(feature = "alloc")]  | 
157  |  | use alloc::string::String;  | 
158  |  | #[cfg(feature = "alloc")]  | 
159  |  | use alloc::vec;  | 
160  |  | #[cfg(feature = "alloc")]  | 
161  |  | use alloc::vec::Vec;  | 
162  |  | use core::convert::TryInto;  | 
163  |  | use core::debug_assert as safety_assert;  | 
164  |  |  | 
165  |  | macro_rules! check { | 
166  |  |     ($e: expr, $c: expr) => { | 
167  |  |         if !$c { | 
168  |  |             return Err($e);  | 
169  |  |         }  | 
170  |  |     };  | 
171  |  | }  | 
172  |  |  | 
173  |  | trait Static<T: Copy>: Copy { | 
174  |  |     fn val(self) -> T;  | 
175  |  | }  | 
176  |  |  | 
177  |  | macro_rules! define { | 
178  |  |     ($name: ident: $type: ty = $val: expr) => { | 
179  |  |         #[derive(Copy, Clone)]  | 
180  |  |         struct $name;  | 
181  |  |         impl Static<$type> for $name { | 
182  | 0  |             fn val(self) -> $type { | 
183  |  |                 $val  | 
184  | 0  |             } Unexecuted instantiation: <data_encoding::Bf as data_encoding::Static<bool>>::val Unexecuted instantiation: <data_encoding::Bt as data_encoding::Static<bool>>::val Unexecuted instantiation: <data_encoding::N1 as data_encoding::Static<usize>>::val Unexecuted instantiation: <data_encoding::N2 as data_encoding::Static<usize>>::val Unexecuted instantiation: <data_encoding::N3 as data_encoding::Static<usize>>::val Unexecuted instantiation: <data_encoding::N4 as data_encoding::Static<usize>>::val Unexecuted instantiation: <data_encoding::N5 as data_encoding::Static<usize>>::val Unexecuted instantiation: <data_encoding::N6 as data_encoding::Static<usize>>::val  | 
185  |  |         }  | 
186  |  |     };  | 
187  |  | }  | 
188  |  |  | 
189  |  | define!(Bf: bool = false);  | 
190  |  | define!(Bt: bool = true);  | 
191  |  | define!(N1: usize = 1);  | 
192  |  | define!(N2: usize = 2);  | 
193  |  | define!(N3: usize = 3);  | 
194  |  | define!(N4: usize = 4);  | 
195  |  | define!(N5: usize = 5);  | 
196  |  | define!(N6: usize = 6);  | 
197  |  |  | 
198  |  | #[derive(Copy, Clone)]  | 
199  |  | struct On;  | 
200  |  |  | 
201  |  | impl<T: Copy> Static<Option<T>> for On { | 
202  | 0  |     fn val(self) -> Option<T> { | 
203  | 0  |         None  | 
204  | 0  |     } Unexecuted instantiation: <data_encoding::On as data_encoding::Static<core::option::Option<(usize, &[u8])>>>::val Unexecuted instantiation: <data_encoding::On as data_encoding::Static<core::option::Option<u8>>>::val  | 
205  |  | }  | 
206  |  |  | 
207  |  | #[derive(Copy, Clone)]  | 
208  |  | struct Os<T>(T);  | 
209  |  |  | 
210  |  | impl<T: Copy> Static<Option<T>> for Os<T> { | 
211  | 0  |     fn val(self) -> Option<T> { | 
212  | 0  |         Some(self.0)  | 
213  | 0  |     } Unexecuted instantiation: <data_encoding::Os<(usize, &[u8])> as data_encoding::Static<core::option::Option<(usize, &[u8])>>>::val Unexecuted instantiation: <data_encoding::Os<u8> as data_encoding::Static<core::option::Option<u8>>>::val  | 
214  |  | }  | 
215  |  |  | 
216  |  | macro_rules! dispatch { | 
217  |  |     (let $var: ident: bool = $val: expr; $($body: tt)*) => { | 
218  |  |         if $val { | 
219  |  |             let $var = Bt; dispatch!($($body)*)  | 
220  |  |         } else { | 
221  |  |             let $var = Bf; dispatch!($($body)*)  | 
222  |  |         }  | 
223  |  |     };  | 
224  |  |     (let $var: ident: usize = $val: expr; $($body: tt)*) => { | 
225  |  |         match $val { | 
226  |  |             1 => { let $var = N1; dispatch!($($body)*) }, | 
227  |  |             2 => { let $var = N2; dispatch!($($body)*) }, | 
228  |  |             3 => { let $var = N3; dispatch!($($body)*) }, | 
229  |  |             4 => { let $var = N4; dispatch!($($body)*) }, | 
230  |  |             5 => { let $var = N5; dispatch!($($body)*) }, | 
231  |  |             6 => { let $var = N6; dispatch!($($body)*) }, | 
232  |  |             _ => panic!(),  | 
233  |  |         }  | 
234  |  |     };  | 
235  |  |     (let $var: ident: Option<$type: ty> = $val: expr; $($body: tt)*) => { | 
236  |  |         match $val { | 
237  |  |             None => { let $var = On; dispatch!($($body)*) }, | 
238  |  |             Some(x) => { let $var = Os(x); dispatch!($($body)*) }, | 
239  |  |         }  | 
240  |  |     };  | 
241  |  |     ($body: expr) => { $body }; | 
242  |  | }  | 
243  |  |  | 
244  | 0  | fn chunk_unchecked<T>(x: &[T], n: usize, i: usize) -> &[T] { | 
245  | 0  |     safety_assert!((i + 1) * n <= x.len());  | 
246  |  |     // SAFETY: Ensured by correctness requirements (and asserted above).  | 
247  | 0  |     unsafe { core::slice::from_raw_parts(x.as_ptr().add(n * i), n) } | 
248  | 0  | }  | 
249  |  |  | 
250  | 0  | fn chunk_mut_unchecked<T>(x: &mut [T], n: usize, i: usize) -> &mut [T] { | 
251  | 0  |     safety_assert!((i + 1) * n <= x.len());  | 
252  |  |     // SAFETY: Ensured by correctness requirements (and asserted above).  | 
253  | 0  |     unsafe { core::slice::from_raw_parts_mut(x.as_mut_ptr().add(n * i), n) } | 
254  | 0  | }  | 
255  |  |  | 
256  | 0  | fn div_ceil(x: usize, m: usize) -> usize { | 
257  | 0  |     (x + m - 1) / m  | 
258  | 0  | }  | 
259  |  |  | 
260  | 0  | fn floor(x: usize, m: usize) -> usize { | 
261  | 0  |     x / m * m  | 
262  | 0  | }  | 
263  |  |  | 
264  |  | #[inline]  | 
265  | 0  | fn vectorize<F: FnMut(usize)>(n: usize, bs: usize, mut f: F) { | 
266  | 0  |     for k in 0 .. n / bs { | 
267  | 0  |         for i in k * bs .. (k + 1) * bs { | 
268  | 0  |             f(i);  | 
269  | 0  |         }  | 
270  |  |     }  | 
271  | 0  |     for i in floor(n, bs) .. n { | 
272  | 0  |         f(i);  | 
273  | 0  |     }  | 
274  | 0  | } Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N1, data_encoding::Bf>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N1, data_encoding::Bt>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N2, data_encoding::Bf>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N2, data_encoding::Bt>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N3, data_encoding::Bf>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N3, data_encoding::Bt>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N4, data_encoding::Bf>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N4, data_encoding::Bt>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N5, data_encoding::Bf>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N5, data_encoding::Bt>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N6, data_encoding::Bf>::{closure#0}>Unexecuted instantiation: data_encoding::vectorize::<data_encoding::encode_mut<data_encoding::N6, data_encoding::Bt>::{closure#0}> | 
275  |  |  | 
276  |  | /// Decoding error kind  | 
277  |  | #[derive(Debug, Copy, Clone, PartialEq, Eq)]  | 
278  |  | pub enum DecodeKind { | 
279  |  |     /// Invalid length  | 
280  |  |     Length,  | 
281  |  |  | 
282  |  |     /// Invalid symbol  | 
283  |  |     Symbol,  | 
284  |  |  | 
285  |  |     /// Non-zero trailing bits  | 
286  |  |     Trailing,  | 
287  |  |  | 
288  |  |     /// Invalid padding length  | 
289  |  |     Padding,  | 
290  |  | }  | 
291  |  |  | 
292  |  | impl core::fmt::Display for DecodeKind { | 
293  | 0  |     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 
294  | 0  |         let description = match self { | 
295  | 0  |             DecodeKind::Length => "invalid length",  | 
296  | 0  |             DecodeKind::Symbol => "invalid symbol",  | 
297  | 0  |             DecodeKind::Trailing => "non-zero trailing bits",  | 
298  | 0  |             DecodeKind::Padding => "invalid padding length",  | 
299  |  |         };  | 
300  | 0  |         write!(f, "{}", description) | 
301  | 0  |     }  | 
302  |  | }  | 
303  |  |  | 
304  |  | /// Decoding error  | 
305  |  | #[derive(Debug, Copy, Clone, PartialEq, Eq)]  | 
306  |  | pub struct DecodeError { | 
307  |  |     /// Error position  | 
308  |  |     ///  | 
309  |  |     /// This position is always a valid input position and represents the first encountered error.  | 
310  |  |     pub position: usize,  | 
311  |  |  | 
312  |  |     /// Error kind  | 
313  |  |     pub kind: DecodeKind,  | 
314  |  | }  | 
315  |  |  | 
316  |  | #[cfg(feature = "std")]  | 
317  |  | impl std::error::Error for DecodeError {} | 
318  |  |  | 
319  |  | impl core::fmt::Display for DecodeError { | 
320  | 0  |     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 
321  | 0  |         write!(f, "{} at {}", self.kind, self.position) | 
322  | 0  |     }  | 
323  |  | }  | 
324  |  |  | 
325  |  | /// Decoding error with partial result  | 
326  |  | #[derive(Debug, Copy, Clone, PartialEq, Eq)]  | 
327  |  | pub struct DecodePartial { | 
328  |  |     /// Number of bytes read from input  | 
329  |  |     ///  | 
330  |  |     /// This number does not exceed the error position: `read <= error.position`.  | 
331  |  |     pub read: usize,  | 
332  |  |  | 
333  |  |     /// Number of bytes written to output  | 
334  |  |     ///  | 
335  |  |     /// This number does not exceed the decoded length: `written <= decode_len(read)`.  | 
336  |  |     pub written: usize,  | 
337  |  |  | 
338  |  |     /// Decoding error  | 
339  |  |     pub error: DecodeError,  | 
340  |  | }  | 
341  |  |  | 
342  |  | const INVALID: u8 = 128;  | 
343  |  | const IGNORE: u8 = 129;  | 
344  |  | const PADDING: u8 = 130;  | 
345  |  |  | 
346  | 0  | fn order(msb: bool, n: usize, i: usize) -> usize { | 
347  | 0  |     if msb { | 
348  | 0  |         n - 1 - i  | 
349  |  |     } else { | 
350  | 0  |         i  | 
351  |  |     }  | 
352  | 0  | }  | 
353  |  |  | 
354  |  | #[inline]  | 
355  | 0  | fn enc(bit: usize) -> usize { | 
356  | 0  |     match bit { | 
357  | 0  |         1 | 2 | 4 => 1,  | 
358  | 0  |         3 | 6 => 3,  | 
359  | 0  |         5 => 5,  | 
360  | 0  |         _ => unreachable!(),  | 
361  |  |     }  | 
362  | 0  | }  | 
363  |  |  | 
364  |  | #[inline]  | 
365  | 0  | fn dec(bit: usize) -> usize { | 
366  | 0  |     enc(bit) * 8 / bit  | 
367  | 0  | }  | 
368  |  |  | 
369  | 0  | fn encode_len<B: Static<usize>>(bit: B, len: usize) -> usize { | 
370  | 0  |     div_ceil(8 * len, bit.val())  | 
371  | 0  | } Unexecuted instantiation: data_encoding::encode_len::<data_encoding::N1> Unexecuted instantiation: data_encoding::encode_len::<data_encoding::N2> Unexecuted instantiation: data_encoding::encode_len::<data_encoding::N3> Unexecuted instantiation: data_encoding::encode_len::<data_encoding::N4> Unexecuted instantiation: data_encoding::encode_len::<data_encoding::N5> Unexecuted instantiation: data_encoding::encode_len::<data_encoding::N6>  | 
372  |  |  | 
373  | 0  | fn encode_block<B: Static<usize>, M: Static<bool>>(  | 
374  | 0  |     bit: B, msb: M, symbols: &[u8; 256], input: &[u8], output: &mut [u8],  | 
375  | 0  | ) { | 
376  | 0  |     debug_assert!(input.len() <= enc(bit.val()));  | 
377  | 0  |     debug_assert_eq!(output.len(), encode_len(bit, input.len()));  | 
378  | 0  |     let bit = bit.val();  | 
379  | 0  |     let msb = msb.val();  | 
380  | 0  |     let mut x = 0u64;  | 
381  | 0  |     for (i, input) in input.iter().enumerate() { | 
382  | 0  |         x |= u64::from(*input) << (8 * order(msb, enc(bit), i));  | 
383  | 0  |     }  | 
384  | 0  |     for (i, output) in output.iter_mut().enumerate() { | 
385  | 0  |         let y = x >> (bit * order(msb, dec(bit), i));  | 
386  | 0  |         *output = symbols[(y & 0xff) as usize];  | 
387  | 0  |     }  | 
388  | 0  | } Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_block::<data_encoding::N6, data_encoding::Bt>  | 
389  |  |  | 
390  | 0  | fn encode_mut<B: Static<usize>, M: Static<bool>>(  | 
391  | 0  |     bit: B, msb: M, symbols: &[u8; 256], input: &[u8], output: &mut [u8],  | 
392  | 0  | ) { | 
393  | 0  |     debug_assert_eq!(output.len(), encode_len(bit, input.len()));  | 
394  | 0  |     let enc = enc(bit.val());  | 
395  | 0  |     let dec = dec(bit.val());  | 
396  | 0  |     let n = input.len() / enc;  | 
397  | 0  |     let bs = match bit.val() { | 
398  | 0  |         5 => 2,  | 
399  | 0  |         6 => 4,  | 
400  | 0  |         _ => 1,  | 
401  |  |     };  | 
402  | 0  |     vectorize(n, bs, |i| { | 
403  | 0  |         let input = chunk_unchecked(input, enc, i);  | 
404  | 0  |         let output = chunk_mut_unchecked(output, dec, i);  | 
405  | 0  |         encode_block(bit, msb, symbols, input, output);  | 
406  | 0  |     }); Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N1, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N1, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N2, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N2, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N3, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N3, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N4, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N4, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N5, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N5, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N6, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N6, data_encoding::Bt>::{closure#0} | 
407  | 0  |     encode_block(bit, msb, symbols, &input[enc * n ..], &mut output[dec * n ..]);  | 
408  | 0  | } Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_mut::<data_encoding::N6, data_encoding::Bt>  | 
409  |  |  | 
410  |  | // Fails if an input character does not translate to a symbol. The error is the  | 
411  |  | // lowest index of such character. The output is not written to.  | 
412  | 0  | fn decode_block<B: Static<usize>, M: Static<bool>>(  | 
413  | 0  |     bit: B, msb: M, values: &[u8; 256], input: &[u8], output: &mut [u8],  | 
414  | 0  | ) -> Result<(), usize> { | 
415  | 0  |     debug_assert!(output.len() <= enc(bit.val()));  | 
416  | 0  |     debug_assert_eq!(input.len(), encode_len(bit, output.len()));  | 
417  | 0  |     let bit = bit.val();  | 
418  | 0  |     let msb = msb.val();  | 
419  | 0  |     let mut x = 0u64;  | 
420  | 0  |     for j in 0 .. input.len() { | 
421  | 0  |         let y = values[input[j] as usize];  | 
422  | 0  |         check!(j, y < 1 << bit);  | 
423  | 0  |         x |= u64::from(y) << (bit * order(msb, dec(bit), j));  | 
424  |  |     }  | 
425  | 0  |     for (j, output) in output.iter_mut().enumerate() { | 
426  | 0  |         *output = ((x >> (8 * order(msb, enc(bit), j))) & 0xff) as u8;  | 
427  | 0  |     }  | 
428  | 0  |     Ok(())  | 
429  | 0  | } Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_block::<data_encoding::N6, data_encoding::Bt>  | 
430  |  |  | 
431  |  | // Fails if an input character does not translate to a symbol. The error `pos`  | 
432  |  | // is the lowest index of such character. The output is valid up to `pos / dec *  | 
433  |  | // enc` excluded.  | 
434  | 0  | fn decode_mut<B: Static<usize>, M: Static<bool>>(  | 
435  | 0  |     bit: B, msb: M, values: &[u8; 256], input: &[u8], output: &mut [u8],  | 
436  | 0  | ) -> Result<(), usize> { | 
437  | 0  |     debug_assert_eq!(input.len(), encode_len(bit, output.len()));  | 
438  | 0  |     let enc = enc(bit.val());  | 
439  | 0  |     let dec = dec(bit.val());  | 
440  | 0  |     let n = input.len() / dec;  | 
441  | 0  |     for i in 0 .. n { | 
442  | 0  |         let input = chunk_unchecked(input, dec, i);  | 
443  | 0  |         let output = chunk_mut_unchecked(output, enc, i);  | 
444  | 0  |         decode_block(bit, msb, values, input, output).map_err(|e| dec * i + e)?; Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N1, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N1, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N2, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N2, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N3, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N3, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N4, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N4, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N5, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N5, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N6, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N6, data_encoding::Bt>::{closure#0} | 
445  |  |     }  | 
446  | 0  |     decode_block(bit, msb, values, &input[dec * n ..], &mut output[enc * n ..])  | 
447  | 0  |         .map_err(|e| dec * n + e) Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N1, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N1, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N2, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N2, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N3, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N3, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N4, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N4, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N5, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N5, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N6, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N6, data_encoding::Bt>::{closure#1} | 
448  | 0  | } Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_mut::<data_encoding::N6, data_encoding::Bt>  | 
449  |  |  | 
450  |  | // Fails if there are non-zero trailing bits.  | 
451  | 0  | fn check_trail<B: Static<usize>, M: Static<bool>>(  | 
452  | 0  |     bit: B, msb: M, ctb: bool, values: &[u8; 256], input: &[u8],  | 
453  | 0  | ) -> Result<(), ()> { | 
454  | 0  |     if 8 % bit.val() == 0 || !ctb { | 
455  | 0  |         return Ok(());  | 
456  | 0  |     }  | 
457  | 0  |     let trail = bit.val() * input.len() % 8;  | 
458  | 0  |     if trail == 0 { | 
459  | 0  |         return Ok(());  | 
460  | 0  |     }  | 
461  | 0  |     let mut mask = (1 << trail) - 1;  | 
462  | 0  |     if !msb.val() { | 
463  | 0  |         mask <<= bit.val() - trail;  | 
464  | 0  |     }  | 
465  | 0  |     check!((), values[input[input.len() - 1] as usize] & mask == 0);  | 
466  | 0  |     Ok(())  | 
467  | 0  | } Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::check_trail::<data_encoding::N6, data_encoding::Bt>  | 
468  |  |  | 
469  |  | // Fails if the padding length is invalid. The error is the index of the first  | 
470  |  | // padding character.  | 
471  | 0  | fn check_pad<B: Static<usize>>(bit: B, values: &[u8; 256], input: &[u8]) -> Result<usize, usize> { | 
472  | 0  |     let bit = bit.val();  | 
473  | 0  |     debug_assert_eq!(input.len(), dec(bit));  | 
474  | 0  |     let is_pad = |x: &&u8| values[**x as usize] == PADDING; Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N1>::{closure#0}Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N2>::{closure#0}Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N3>::{closure#0}Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N4>::{closure#0}Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N5>::{closure#0}Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N6>::{closure#0} | 
475  | 0  |     let count = input.iter().rev().take_while(is_pad).count();  | 
476  | 0  |     let len = input.len() - count;  | 
477  | 0  |     check!(len, len > 0 && bit * len % 8 < bit);  | 
478  | 0  |     Ok(len)  | 
479  | 0  | } Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N1> Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N2> Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N3> Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N4> Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N5> Unexecuted instantiation: data_encoding::check_pad::<data_encoding::N6>  | 
480  |  |  | 
481  | 0  | fn encode_base_len<B: Static<usize>>(bit: B, len: usize) -> usize { | 
482  | 0  |     encode_len(bit, len)  | 
483  | 0  | } Unexecuted instantiation: data_encoding::encode_base_len::<data_encoding::N1> Unexecuted instantiation: data_encoding::encode_base_len::<data_encoding::N2> Unexecuted instantiation: data_encoding::encode_base_len::<data_encoding::N3> Unexecuted instantiation: data_encoding::encode_base_len::<data_encoding::N4> Unexecuted instantiation: data_encoding::encode_base_len::<data_encoding::N5> Unexecuted instantiation: data_encoding::encode_base_len::<data_encoding::N6>  | 
484  |  |  | 
485  | 0  | fn encode_base<B: Static<usize>, M: Static<bool>>(  | 
486  | 0  |     bit: B, msb: M, symbols: &[u8; 256], input: &[u8], output: &mut [u8],  | 
487  | 0  | ) { | 
488  | 0  |     debug_assert_eq!(output.len(), encode_base_len(bit, input.len()));  | 
489  | 0  |     encode_mut(bit, msb, symbols, input, output);  | 
490  | 0  | } Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::encode_base::<data_encoding::N6, data_encoding::Bt>  | 
491  |  |  | 
492  | 0  | fn encode_pad_len<B: Static<usize>, P: Static<Option<u8>>>(bit: B, pad: P, len: usize) -> usize { | 
493  | 0  |     match pad.val() { | 
494  | 0  |         None => encode_base_len(bit, len),  | 
495  | 0  |         Some(_) => div_ceil(len, enc(bit.val())) * dec(bit.val()),  | 
496  |  |     }  | 
497  | 0  | } Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N1, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N1, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N2, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N2, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N3, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N3, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N4, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N4, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N5, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N5, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N6, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad_len::<data_encoding::N6, data_encoding::On>  | 
498  |  |  | 
499  | 0  | fn encode_pad<B: Static<usize>, M: Static<bool>, P: Static<Option<u8>>>(  | 
500  | 0  |     bit: B, msb: M, symbols: &[u8; 256], spad: P, input: &[u8], output: &mut [u8],  | 
501  | 0  | ) { | 
502  | 0  |     let pad = match spad.val() { | 
503  | 0  |         None => return encode_base(bit, msb, symbols, input, output),  | 
504  | 0  |         Some(pad) => pad,  | 
505  |  |     };  | 
506  | 0  |     debug_assert_eq!(output.len(), encode_pad_len(bit, spad, input.len()));  | 
507  | 0  |     let olen = encode_base_len(bit, input.len());  | 
508  | 0  |     encode_base(bit, msb, symbols, input, &mut output[.. olen]);  | 
509  | 0  |     for output in output.iter_mut().skip(olen) { | 
510  | 0  |         *output = pad;  | 
511  | 0  |     }  | 
512  | 0  | } Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N1, data_encoding::Bf, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N1, data_encoding::Bf, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N1, data_encoding::Bt, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N1, data_encoding::Bt, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N2, data_encoding::Bf, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N2, data_encoding::Bf, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N2, data_encoding::Bt, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N2, data_encoding::Bt, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N3, data_encoding::Bf, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N3, data_encoding::Bf, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N3, data_encoding::Bt, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N3, data_encoding::Bt, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N4, data_encoding::Bf, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N4, data_encoding::Bf, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N4, data_encoding::Bt, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N4, data_encoding::Bt, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N5, data_encoding::Bf, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N5, data_encoding::Bf, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N5, data_encoding::Bt, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N5, data_encoding::Bt, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N6, data_encoding::Bf, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N6, data_encoding::Bf, data_encoding::On> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N6, data_encoding::Bt, data_encoding::Os<u8>> Unexecuted instantiation: data_encoding::encode_pad::<data_encoding::N6, data_encoding::Bt, data_encoding::On>  | 
513  |  |  | 
514  | 0  | fn encode_wrap_len<  | 
515  | 0  |     'a,  | 
516  | 0  |     B: Static<usize>,  | 
517  | 0  |     P: Static<Option<u8>>,  | 
518  | 0  |     W: Static<Option<(usize, &'a [u8])>>,  | 
519  | 0  | >(  | 
520  | 0  |     bit: B, pad: P, wrap: W, ilen: usize,  | 
521  | 0  | ) -> usize { | 
522  | 0  |     let olen = encode_pad_len(bit, pad, ilen);  | 
523  | 0  |     match wrap.val() { | 
524  | 0  |         None => olen,  | 
525  | 0  |         Some((col, end)) => olen + end.len() * div_ceil(olen, col),  | 
526  |  |     }  | 
527  | 0  | } Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N1, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N1, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N1, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N1, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N2, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N2, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N2, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N2, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N3, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N3, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N3, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N3, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N4, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N4, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N4, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N4, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N5, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N5, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N5, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N5, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N6, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N6, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N6, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_len::<data_encoding::N6, data_encoding::On, data_encoding::Os<(usize, &[u8])>>  | 
528  |  |  | 
529  | 0  | fn encode_wrap_mut<  | 
530  | 0  |     'a,  | 
531  | 0  |     B: Static<usize>,  | 
532  | 0  |     M: Static<bool>,  | 
533  | 0  |     P: Static<Option<u8>>,  | 
534  | 0  |     W: Static<Option<(usize, &'a [u8])>>,  | 
535  | 0  | >(  | 
536  | 0  |     bit: B, msb: M, symbols: &[u8; 256], pad: P, wrap: W, input: &[u8], output: &mut [u8],  | 
537  | 0  | ) { | 
538  | 0  |     let (col, end) = match wrap.val() { | 
539  | 0  |         None => return encode_pad(bit, msb, symbols, pad, input, output),  | 
540  | 0  |         Some((col, end)) => (col, end),  | 
541  |  |     };  | 
542  | 0  |     debug_assert_eq!(output.len(), encode_wrap_len(bit, pad, wrap, input.len()));  | 
543  | 0  |     debug_assert_eq!(col % dec(bit.val()), 0);  | 
544  | 0  |     let col = col / dec(bit.val());  | 
545  | 0  |     let enc = col * enc(bit.val());  | 
546  | 0  |     let dec = col * dec(bit.val()) + end.len();  | 
547  | 0  |     let olen = dec - end.len();  | 
548  | 0  |     let n = input.len() / enc;  | 
549  | 0  |     for i in 0 .. n { | 
550  | 0  |         let input = chunk_unchecked(input, enc, i);  | 
551  | 0  |         let output = chunk_mut_unchecked(output, dec, i);  | 
552  | 0  |         encode_base(bit, msb, symbols, input, &mut output[.. olen]);  | 
553  | 0  |         output[olen ..].copy_from_slice(end);  | 
554  | 0  |     }  | 
555  | 0  |     if input.len() > enc * n { | 
556  | 0  |         let olen = dec * n + encode_pad_len(bit, pad, input.len() - enc * n);  | 
557  | 0  |         encode_pad(bit, msb, symbols, pad, &input[enc * n ..], &mut output[dec * n .. olen]);  | 
558  | 0  |         output[olen ..].copy_from_slice(end);  | 
559  | 0  |     }  | 
560  | 0  | } Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::On, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::Os<(usize, &[u8])>> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Os<u8>, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::On, data_encoding::On> Unexecuted instantiation: data_encoding::encode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::On, data_encoding::Os<(usize, &[u8])>>  | 
561  |  |  | 
562  |  | // Returns the longest valid input length and associated output length.  | 
563  | 0  | fn decode_wrap_len<B: Static<usize>, P: Static<bool>>(  | 
564  | 0  |     bit: B, pad: P, len: usize,  | 
565  | 0  | ) -> (usize, usize) { | 
566  | 0  |     let bit = bit.val();  | 
567  | 0  |     if pad.val() { | 
568  | 0  |         (floor(len, dec(bit)), len / dec(bit) * enc(bit))  | 
569  |  |     } else { | 
570  | 0  |         let trail = bit * len % 8;  | 
571  | 0  |         (len - trail / bit, bit * len / 8)  | 
572  |  |     }  | 
573  | 0  | } Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_len::<data_encoding::N6, data_encoding::Bt>  | 
574  |  |  | 
575  |  | // Fails with Length if length is invalid. The error is the largest valid  | 
576  |  | // length.  | 
577  | 0  | fn decode_pad_len<B: Static<usize>, P: Static<bool>>(  | 
578  | 0  |     bit: B, pad: P, len: usize,  | 
579  | 0  | ) -> Result<usize, DecodeError> { | 
580  | 0  |     let (ilen, olen) = decode_wrap_len(bit, pad, len);  | 
581  | 0  |     check!(DecodeError { position: ilen, kind: DecodeKind::Length }, ilen == len); | 
582  | 0  |     Ok(olen)  | 
583  | 0  | } Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_len::<data_encoding::N6, data_encoding::Bt>  | 
584  |  |  | 
585  |  | // Fails with Length if length is invalid. The error is the largest valid  | 
586  |  | // length.  | 
587  | 0  | fn decode_base_len<B: Static<usize>>(bit: B, len: usize) -> Result<usize, DecodeError> { | 
588  | 0  |     decode_pad_len(bit, Bf, len)  | 
589  | 0  | } Unexecuted instantiation: data_encoding::decode_base_len::<data_encoding::N1> Unexecuted instantiation: data_encoding::decode_base_len::<data_encoding::N2> Unexecuted instantiation: data_encoding::decode_base_len::<data_encoding::N3> Unexecuted instantiation: data_encoding::decode_base_len::<data_encoding::N4> Unexecuted instantiation: data_encoding::decode_base_len::<data_encoding::N5> Unexecuted instantiation: data_encoding::decode_base_len::<data_encoding::N6>  | 
590  |  |  | 
591  |  | // Fails with Symbol if an input character does not translate to a symbol. The  | 
592  |  | // error is the lowest index of such character.  | 
593  |  | // Fails with Trailing if there are non-zero trailing bits.  | 
594  | 0  | fn decode_base_mut<B: Static<usize>, M: Static<bool>>(  | 
595  | 0  |     bit: B, msb: M, ctb: bool, values: &[u8; 256], input: &[u8], output: &mut [u8],  | 
596  | 0  | ) -> Result<usize, DecodePartial> { | 
597  | 0  |     debug_assert_eq!(Ok(output.len()), decode_base_len(bit, input.len()));  | 
598  | 0  |     let fail = |pos, kind| DecodePartial { | 
599  | 0  |         read: pos / dec(bit.val()) * dec(bit.val()),  | 
600  | 0  |         written: pos / dec(bit.val()) * enc(bit.val()),  | 
601  | 0  |         error: DecodeError { position: pos, kind }, | 
602  | 0  |     }; Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bt>::{closure#0} | 
603  | 0  |     decode_mut(bit, msb, values, input, output).map_err(|pos| fail(pos, DecodeKind::Symbol))?; Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bt>::{closure#1} | 
604  | 0  |     check_trail(bit, msb, ctb, values, input)  | 
605  | 0  |         .map_err(|()| fail(input.len() - 1, DecodeKind::Trailing))?; Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bf>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bt>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bf>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bt>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bf>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bt>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bf>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bt>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bf>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bt>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bf>::{closure#2}Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bt>::{closure#2} | 
606  | 0  |     Ok(output.len())  | 
607  | 0  | } Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N1, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N2, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N3, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N4, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N5, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_base_mut::<data_encoding::N6, data_encoding::Bt>  | 
608  |  |  | 
609  |  | // Fails with Symbol if an input character does not translate to a symbol. The  | 
610  |  | // error is the lowest index of such character.  | 
611  |  | // Fails with Padding if some padding length is invalid. The error is the index  | 
612  |  | // of the first padding character of the invalid padding.  | 
613  |  | // Fails with Trailing if there are non-zero trailing bits.  | 
614  | 0  | fn decode_pad_mut<B: Static<usize>, M: Static<bool>, P: Static<bool>>(  | 
615  | 0  |     bit: B, msb: M, ctb: bool, values: &[u8; 256], pad: P, input: &[u8], output: &mut [u8],  | 
616  | 0  | ) -> Result<usize, DecodePartial> { | 
617  | 0  |     if !pad.val() { | 
618  | 0  |         return decode_base_mut(bit, msb, ctb, values, input, output);  | 
619  | 0  |     }  | 
620  | 0  |     debug_assert_eq!(Ok(output.len()), decode_pad_len(bit, pad, input.len()));  | 
621  | 0  |     let enc = enc(bit.val());  | 
622  | 0  |     let dec = dec(bit.val());  | 
623  | 0  |     let mut inpos = 0;  | 
624  | 0  |     let mut outpos = 0;  | 
625  | 0  |     let mut outend = output.len();  | 
626  | 0  |     while inpos < input.len() { | 
627  | 0  |         match decode_base_mut(  | 
628  | 0  |             bit,  | 
629  | 0  |             msb,  | 
630  | 0  |             ctb,  | 
631  | 0  |             values,  | 
632  | 0  |             &input[inpos ..],  | 
633  | 0  |             &mut output[outpos .. outend],  | 
634  | 0  |         ) { | 
635  | 0  |             Ok(written) => { | 
636  | 0  |                 if cfg!(debug_assertions) { | 
637  | 0  |                     inpos = input.len();  | 
638  | 0  |                 }  | 
639  | 0  |                 outpos += written;  | 
640  | 0  |                 break;  | 
641  |  |             }  | 
642  | 0  |             Err(partial) => { | 
643  | 0  |                 inpos += partial.read;  | 
644  | 0  |                 outpos += partial.written;  | 
645  | 0  |             }  | 
646  |  |         }  | 
647  | 0  |         let inlen =  | 
648  | 0  |             check_pad(bit, values, &input[inpos .. inpos + dec]).map_err(|pos| DecodePartial { | 
649  | 0  |                 read: inpos,  | 
650  | 0  |                 written: outpos,  | 
651  | 0  |                 error: DecodeError { position: inpos + pos, kind: DecodeKind::Padding }, | 
652  | 0  |             })?; Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf>::{closure#0} | 
653  | 0  |         let outlen = decode_base_len(bit, inlen).unwrap();  | 
654  | 0  |         let written = decode_base_mut(  | 
655  | 0  |             bit,  | 
656  | 0  |             msb,  | 
657  | 0  |             ctb,  | 
658  | 0  |             values,  | 
659  | 0  |             &input[inpos .. inpos + inlen],  | 
660  | 0  |             &mut output[outpos .. outpos + outlen],  | 
661  |  |         )  | 
662  | 0  |         .map_err(|partial| { | 
663  | 0  |             debug_assert_eq!(partial.read, 0);  | 
664  | 0  |             debug_assert_eq!(partial.written, 0);  | 
665  | 0  |             DecodePartial { | 
666  | 0  |                 read: inpos,  | 
667  | 0  |                 written: outpos,  | 
668  | 0  |                 error: DecodeError { | 
669  | 0  |                     position: inpos + partial.error.position,  | 
670  | 0  |                     kind: partial.error.kind,  | 
671  | 0  |                 },  | 
672  | 0  |             }  | 
673  | 0  |         })?; Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf>::{closure#1} | 
674  | 0  |         debug_assert_eq!(written, outlen);  | 
675  | 0  |         inpos += dec;  | 
676  | 0  |         outpos += outlen;  | 
677  | 0  |         outend -= enc - outlen;  | 
678  |  |     }  | 
679  | 0  |     debug_assert_eq!(inpos, input.len());  | 
680  | 0  |     debug_assert_eq!(outpos, outend);  | 
681  | 0  |     Ok(outend)  | 
682  | 0  | } Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_pad_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf>  | 
683  |  |  | 
684  | 0  | fn skip_ignore(values: &[u8; 256], input: &[u8], mut inpos: usize) -> usize { | 
685  | 0  |     while inpos < input.len() && values[input[inpos] as usize] == IGNORE { | 
686  | 0  |         inpos += 1;  | 
687  | 0  |     }  | 
688  | 0  |     inpos  | 
689  | 0  | }  | 
690  |  |  | 
691  |  | // Returns next input and output position.  | 
692  |  | // Fails with Symbol if an input character does not translate to a symbol. The  | 
693  |  | // error is the lowest index of such character.  | 
694  |  | // Fails with Padding if some padding length is invalid. The error is the index  | 
695  |  | // of the first padding character of the invalid padding.  | 
696  |  | // Fails with Trailing if there are non-zero trailing bits.  | 
697  | 0  | fn decode_wrap_block<B: Static<usize>, M: Static<bool>, P: Static<bool>>(  | 
698  | 0  |     bit: B, msb: M, ctb: bool, values: &[u8; 256], pad: P, input: &[u8], output: &mut [u8],  | 
699  | 0  | ) -> Result<(usize, usize), DecodeError> { | 
700  | 0  |     let dec = dec(bit.val());  | 
701  | 0  |     let mut buf = [0u8; 8];  | 
702  | 0  |     let mut shift = [0usize; 8];  | 
703  | 0  |     let mut bufpos = 0;  | 
704  | 0  |     let mut inpos = 0;  | 
705  | 0  |     while bufpos < dec { | 
706  | 0  |         inpos = skip_ignore(values, input, inpos);  | 
707  | 0  |         if inpos == input.len() { | 
708  | 0  |             break;  | 
709  | 0  |         }  | 
710  | 0  |         shift[bufpos] = inpos;  | 
711  | 0  |         buf[bufpos] = input[inpos];  | 
712  | 0  |         bufpos += 1;  | 
713  | 0  |         inpos += 1;  | 
714  |  |     }  | 
715  | 0  |     let olen = decode_pad_len(bit, pad, bufpos).map_err(|mut e| { | 
716  | 0  |         e.position = shift[e.position];  | 
717  | 0  |         e  | 
718  | 0  |     })?; Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf>::{closure#0} | 
719  | 0  |     let written = decode_pad_mut(bit, msb, ctb, values, pad, &buf[.. bufpos], &mut output[.. olen])  | 
720  | 0  |         .map_err(|partial| { | 
721  | 0  |             debug_assert_eq!(partial.read, 0);  | 
722  | 0  |             debug_assert_eq!(partial.written, 0);  | 
723  | 0  |             DecodeError { position: shift[partial.error.position], kind: partial.error.kind } | 
724  | 0  |         })?; Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt>::{closure#1}Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf>::{closure#1} | 
725  | 0  |     Ok((inpos, written))  | 
726  | 0  | } Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_block::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf>  | 
727  |  |  | 
728  |  | // Fails with Symbol if an input character does not translate to a symbol. The  | 
729  |  | // error is the lowest index of such character.  | 
730  |  | // Fails with Padding if some padding length is invalid. The error is the index  | 
731  |  | // of the first padding character of the invalid padding.  | 
732  |  | // Fails with Trailing if there are non-zero trailing bits.  | 
733  |  | // Fails with Length if input length (without ignored characters) is invalid.  | 
734  |  | #[allow(clippy::too_many_arguments)]  | 
735  | 0  | fn decode_wrap_mut<B: Static<usize>, M: Static<bool>, P: Static<bool>, I: Static<bool>>(  | 
736  | 0  |     bit: B, msb: M, ctb: bool, values: &[u8; 256], pad: P, has_ignore: I, input: &[u8],  | 
737  | 0  |     output: &mut [u8],  | 
738  | 0  | ) -> Result<usize, DecodePartial> { | 
739  | 0  |     if !has_ignore.val() { | 
740  | 0  |         return decode_pad_mut(bit, msb, ctb, values, pad, input, output);  | 
741  | 0  |     }  | 
742  | 0  |     debug_assert_eq!(output.len(), decode_wrap_len(bit, pad, input.len()).1);  | 
743  | 0  |     let mut inpos = 0;  | 
744  | 0  |     let mut outpos = 0;  | 
745  | 0  |     while inpos < input.len() { | 
746  | 0  |         let (inlen, outlen) = decode_wrap_len(bit, pad, input.len() - inpos);  | 
747  | 0  |         match decode_pad_mut(  | 
748  | 0  |             bit,  | 
749  | 0  |             msb,  | 
750  | 0  |             ctb,  | 
751  | 0  |             values,  | 
752  | 0  |             pad,  | 
753  | 0  |             &input[inpos .. inpos + inlen],  | 
754  | 0  |             &mut output[outpos .. outpos + outlen],  | 
755  | 0  |         ) { | 
756  | 0  |             Ok(written) => { | 
757  | 0  |                 inpos += inlen;  | 
758  | 0  |                 outpos += written;  | 
759  | 0  |                 break;  | 
760  |  |             }  | 
761  | 0  |             Err(partial) => { | 
762  | 0  |                 inpos += partial.read;  | 
763  | 0  |                 outpos += partial.written;  | 
764  | 0  |             }  | 
765  |  |         }  | 
766  | 0  |         let (ipos, opos) =  | 
767  | 0  |             decode_wrap_block(bit, msb, ctb, values, pad, &input[inpos ..], &mut output[outpos ..])  | 
768  | 0  |                 .map_err(|mut error| { | 
769  | 0  |                     error.position += inpos;  | 
770  | 0  |                     DecodePartial { read: inpos, written: outpos, error } | 
771  | 0  |                 })?; Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf>::{closure#0}Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>::{closure#0} | 
772  | 0  |         inpos += ipos;  | 
773  | 0  |         outpos += opos;  | 
774  |  |     }  | 
775  | 0  |     let inpos = skip_ignore(values, input, inpos);  | 
776  | 0  |     if inpos == input.len() { | 
777  | 0  |         Ok(outpos)  | 
778  |  |     } else { | 
779  | 0  |         Err(DecodePartial { | 
780  | 0  |             read: inpos,  | 
781  | 0  |             written: outpos,  | 
782  | 0  |             error: DecodeError { position: inpos, kind: DecodeKind::Length }, | 
783  | 0  |         })  | 
784  |  |     }  | 
785  | 0  | } Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N1, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N2, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N3, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N4, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N5, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bf, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bf, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt, data_encoding::Bt> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bt, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf, data_encoding::Bf> Unexecuted instantiation: data_encoding::decode_wrap_mut::<data_encoding::N6, data_encoding::Bt, data_encoding::Bf, data_encoding::Bt>  | 
786  |  |  | 
787  |  | /// Order in which bits are read from a byte  | 
788  |  | ///  | 
789  |  | /// The base-conversion encoding is always little-endian. This means that the least significant  | 
790  |  | /// **byte** is always first. However, we can still choose whether, within a byte, this is the most  | 
791  |  | /// significant or the least significant **bit** that is first. If the terminology is confusing,  | 
792  |  | /// testing on an asymmetrical example should be enough to choose the correct value.  | 
793  |  | ///  | 
794  |  | /// # Examples  | 
795  |  | ///  | 
796  |  | /// In the following example, we can see that a base with the `MostSignificantFirst` bit-order has  | 
797  |  | /// the most significant bit first in the encoded output. In particular, the output is in the same  | 
798  |  | /// order as the bits in the byte. The opposite happens with the `LeastSignificantFirst` bit-order.  | 
799  |  | /// The least significant bit is first and the output is in the reverse order.  | 
800  |  | ///  | 
801  |  | /// ```rust  | 
802  |  | /// use data_encoding::{BitOrder, Specification}; | 
803  |  | /// let mut spec = Specification::new();  | 
804  |  | /// spec.symbols.push_str("01"); | 
805  |  | /// spec.bit_order = BitOrder::MostSignificantFirst;  // default  | 
806  |  | /// let msb = spec.encoding().unwrap();  | 
807  |  | /// spec.bit_order = BitOrder::LeastSignificantFirst;  | 
808  |  | /// let lsb = spec.encoding().unwrap();  | 
809  |  | /// assert_eq!(msb.encode(&[0b01010011]), "01010011");  | 
810  |  | /// assert_eq!(lsb.encode(&[0b01010011]), "11001010");  | 
811  |  | /// ```  | 
812  |  | #[derive(Debug, Copy, Clone, PartialEq, Eq)]  | 
813  |  | #[cfg(feature = "alloc")]  | 
814  |  | pub enum BitOrder { | 
815  |  |     /// Most significant bit first  | 
816  |  |     ///  | 
817  |  |     /// This is the most common and most intuitive bit-order. In particular, this is the bit-order  | 
818  |  |     /// used by [RFC4648] and thus the usual hexadecimal, base64, base32, base64url, and base32hex  | 
819  |  |     /// encodings. This is the default bit-order when [specifying](struct.Specification.html) a  | 
820  |  |     /// base.  | 
821  |  |     ///  | 
822  |  |     /// [RFC4648]: https://tools.ietf.org/html/rfc4648  | 
823  |  |     MostSignificantFirst,  | 
824  |  |  | 
825  |  |     /// Least significant bit first  | 
826  |  |     ///  | 
827  |  |     /// # Examples  | 
828  |  |     ///  | 
829  |  |     /// DNSCurve [base32] uses least significant bit first:  | 
830  |  |     ///  | 
831  |  |     /// ```rust  | 
832  |  |     /// use data_encoding::BASE32_DNSCURVE;  | 
833  |  |     /// assert_eq!(BASE32_DNSCURVE.encode(&[0x64, 0x88]), "4321");  | 
834  |  |     /// assert_eq!(BASE32_DNSCURVE.decode(b"4321").unwrap(), vec![0x64, 0x88]);  | 
835  |  |     /// ```  | 
836  |  |     ///  | 
837  |  |     /// [base32]: constant.BASE32_DNSCURVE.html  | 
838  |  |     LeastSignificantFirst,  | 
839  |  | }  | 
840  |  | #[cfg(feature = "alloc")]  | 
841  |  | use crate::BitOrder::*;  | 
842  |  |  | 
843  |  | #[doc(hidden)]  | 
844  |  | #[cfg(feature = "alloc")]  | 
845  |  | pub type InternalEncoding = Cow<'static, [u8]>;  | 
846  |  |  | 
847  |  | #[doc(hidden)]  | 
848  |  | #[cfg(not(feature = "alloc"))]  | 
849  |  | pub type InternalEncoding = &'static [u8];  | 
850  |  |  | 
851  |  | /// Base-conversion encoding  | 
852  |  | ///  | 
853  |  | /// See [Specification](struct.Specification.html) for technical details or how to define a new one.  | 
854  |  | // Required fields:  | 
855  |  | //   0 - 256 (256) symbols  | 
856  |  | // 256 - 512 (256) values  | 
857  |  | // 512 - 513 (  1) padding  | 
858  |  | // 513 - 514 (  1) reserved(3),ctb(1),msb(1),bit(3)  | 
859  |  | // Optional fields:  | 
860  |  | // 514 - 515 (  1) width  | 
861  |  | // 515 -   * (  N) separator  | 
862  |  | // Invariants:  | 
863  |  | // - symbols is 2^bit unique characters repeated 2^(8-bit) times  | 
864  |  | // - values[128 ..] are INVALID  | 
865  |  | // - values[0 .. 128] are either INVALID, IGNORE, PADDING, or < 2^bit  | 
866  |  | // - padding is either < 128 or INVALID  | 
867  |  | // - values[padding] is PADDING if padding < 128  | 
868  |  | // - values and symbols are inverse  | 
869  |  | // - ctb is true if 8 % bit == 0  | 
870  |  | // - width is present if there is x such that values[x] is IGNORE  | 
871  |  | // - width % dec(bit) == 0  | 
872  |  | // - for all x in separator values[x] is IGNORE  | 
873  |  | #[derive(Debug, Clone, PartialEq, Eq)]  | 
874  |  | #[repr(transparent)]  | 
875  |  | pub struct Encoding(#[doc(hidden)] pub InternalEncoding);  | 
876  |  |  | 
877  |  | /// How to translate characters when decoding  | 
878  |  | ///  | 
879  |  | /// The order matters. The first character of the `from` field is translated to the first character  | 
880  |  | /// of the `to` field. The second to the second. Etc.  | 
881  |  | ///  | 
882  |  | /// See [Specification](struct.Specification.html) for more information.  | 
883  |  | #[derive(Debug, Clone)]  | 
884  |  | #[cfg(feature = "alloc")]  | 
885  |  | pub struct Translate { | 
886  |  |     /// Characters to translate from  | 
887  |  |     pub from: String,  | 
888  |  |  | 
889  |  |     /// Characters to translate to  | 
890  |  |     pub to: String,  | 
891  |  | }  | 
892  |  |  | 
893  |  | /// How to wrap the output when encoding  | 
894  |  | ///  | 
895  |  | /// See [Specification](struct.Specification.html) for more information.  | 
896  |  | #[derive(Debug, Clone)]  | 
897  |  | #[cfg(feature = "alloc")]  | 
898  |  | pub struct Wrap { | 
899  |  |     /// Wrapping width  | 
900  |  |     ///  | 
901  |  |     /// Must be a multiple of:  | 
902  |  |     ///  | 
903  |  |     /// - 8 for a bit-width of 1 (binary), 3 (octal), and 5 (base32)  | 
904  |  |     /// - 4 for a bit-width of 2 (base4) and 6 (base64)  | 
905  |  |     /// - 2 for a bit-width of 4 (hexadecimal)  | 
906  |  |     ///  | 
907  |  |     /// Wrapping is disabled if null.  | 
908  |  |     pub width: usize,  | 
909  |  |  | 
910  |  |     /// Wrapping characters  | 
911  |  |     ///  | 
912  |  |     /// Wrapping is disabled if empty.  | 
913  |  |     pub separator: String,  | 
914  |  | }  | 
915  |  |  | 
916  |  | /// Base-conversion specification  | 
917  |  | ///  | 
918  |  | /// It is possible to define custom encodings given a specification. To do so, it is important to  | 
919  |  | /// understand the theory first.  | 
920  |  | ///  | 
921  |  | /// # Theory  | 
922  |  | ///  | 
923  |  | /// Each subsection has an equivalent subsection in the [Practice](#practice) section.  | 
924  |  | ///  | 
925  |  | /// ## Basics  | 
926  |  | ///  | 
927  |  | /// The main idea of a [base-conversion] encoding is to see `[u8]` as numbers written in  | 
928  |  | /// little-endian base256 and convert them in another little-endian base. For performance reasons,  | 
929  |  | /// this crate restricts this other base to be of size 2 (binary), 4 (base4), 8 (octal), 16  | 
930  |  | /// (hexadecimal), 32 (base32), or 64 (base64). The converted number is written as `[u8]` although  | 
931  |  | /// it doesn't use all the 256 possible values of `u8`. This crate encodes to ASCII, so only values  | 
932  |  | /// smaller than 128 are allowed.  | 
933  |  | ///  | 
934  |  | /// More precisely, we need the following elements:  | 
935  |  | ///  | 
936  |  | /// - The bit-width N: 1 for binary, 2 for base4, 3 for octal, 4 for hexadecimal, 5 for base32, and  | 
937  |  | ///   6 for base64  | 
938  |  | /// - The [bit-order](enum.BitOrder.html): most or least significant bit first  | 
939  |  | /// - The symbols function S from [0, 2<sup>N</sup>) (called values and written `uN`) to symbols  | 
940  |  | ///   (represented as `u8` although only ASCII symbols are allowed, i.e. smaller than 128)  | 
941  |  | /// - The values partial function V from ASCII to [0, 2<sup>N</sup>), i.e. from `u8` to `uN`  | 
942  |  | /// - Whether trailing bits are checked: trailing bits are leading zeros in theory, but since  | 
943  |  | ///   numbers are little-endian they come last  | 
944  |  | ///  | 
945  |  | /// For the encoding to be correct (i.e. encoding then decoding gives back the initial input),  | 
946  |  | /// V(S(i)) must be defined and equal to i for all i in [0, 2<sup>N</sup>). For the encoding to be  | 
947  |  | /// [canonical][canonical] (i.e. different inputs decode to different outputs, or equivalently,  | 
948  |  | /// decoding then encoding gives back the initial input), trailing bits must be checked and if V(i)  | 
949  |  | /// is defined then S(V(i)) is equal to i for all i.  | 
950  |  | ///  | 
951  |  | /// Encoding and decoding are given by the following pipeline:  | 
952  |  | ///  | 
953  |  | /// ```text  | 
954  |  | /// [u8] <--1--> [[bit; 8]] <--2--> [[bit; N]] <--3--> [uN] <--4--> [u8]  | 
955  |  | /// 1: Map bit-order between each u8 and [bit; 8]  | 
956  |  | /// 2: Base conversion between base 2^8 and base 2^N (check trailing bits)  | 
957  |  | /// 3: Map bit-order between each [bit; N] and uN  | 
958  |  | /// 4: Map symbols/values between each uN and u8 (values must be defined)  | 
959  |  | /// ```  | 
960  |  | ///  | 
961  |  | /// ## Extensions  | 
962  |  | ///  | 
963  |  | /// All these extensions make the encoding not canonical.  | 
964  |  | ///  | 
965  |  | /// ### Padding  | 
966  |  | ///  | 
967  |  | /// Padding is useful if the following conditions are met:  | 
968  |  | ///  | 
969  |  | /// - the bit-width is 3 (octal), 5 (base32), or 6 (base64)  | 
970  |  | /// - the length of the data to encode is not known in advance  | 
971  |  | /// - the data must be sent without buffering  | 
972  |  | ///  | 
973  |  | /// Bases for which the bit-width N does not divide 8 may not concatenate encoded data. This comes  | 
974  |  | /// from the fact that it is not possible to make the difference between trailing bits and encoding  | 
975  |  | /// bits. Padding solves this issue by adding a new character to discriminate between trailing bits  | 
976  |  | /// and encoding bits. The idea is to work by blocks of lcm(8, N) bits, where lcm(8, N) is the least  | 
977  |  | /// common multiple of 8 and N. When such block is not complete, it is padded.  | 
978  |  | ///  | 
979  |  | /// To preserve correctness, the padding character must not be a symbol.  | 
980  |  | ///  | 
981  |  | /// ### Ignore characters when decoding  | 
982  |  | ///  | 
983  |  | /// Ignoring characters when decoding is useful if after encoding some characters are added for  | 
984  |  | /// convenience or any other reason (like wrapping). In that case we want to first ignore those  | 
985  |  | /// characters before decoding.  | 
986  |  | ///  | 
987  |  | /// To preserve correctness, ignored characters must not contain symbols or the padding character.  | 
988  |  | ///  | 
989  |  | /// ### Wrap output when encoding  | 
990  |  | ///  | 
991  |  | /// Wrapping output when encoding is useful if the output is meant to be printed in a document where  | 
992  |  | /// width is limited (typically 80-columns documents). In that case, the wrapping width and the  | 
993  |  | /// wrapping separator have to be defined.  | 
994  |  | ///  | 
995  |  | /// To preserve correctness, the wrapping separator characters must be ignored (see previous  | 
996  |  | /// subsection). As such, wrapping separator characters must also not contain symbols or the padding  | 
997  |  | /// character.  | 
998  |  | ///  | 
999  |  | /// ### Translate characters when decoding  | 
1000  |  | ///  | 
1001  |  | /// Translating characters when decoding is useful when encoded data may be copied by a humain  | 
1002  |  | /// instead of a machine. Humans tend to confuse some characters for others. In that case we want to  | 
1003  |  | /// translate those characters before decoding.  | 
1004  |  | ///  | 
1005  |  | /// To preserve correctness, the characters we translate _from_ must not contain symbols or the  | 
1006  |  | /// padding character, and the characters we translate _to_ must only contain symbols or the padding  | 
1007  |  | /// character.  | 
1008  |  | ///  | 
1009  |  | /// # Practice  | 
1010  |  | ///  | 
1011  |  | /// ## Basics  | 
1012  |  | ///  | 
1013  |  | /// ```rust  | 
1014  |  | /// use data_encoding::{Encoding, Specification}; | 
1015  |  | /// fn make_encoding(symbols: &str) -> Encoding { | 
1016  |  | ///     let mut spec = Specification::new();  | 
1017  |  | ///     spec.symbols.push_str(symbols);  | 
1018  |  | ///     spec.encoding().unwrap()  | 
1019  |  | /// }  | 
1020  |  | /// let binary = make_encoding("01"); | 
1021  |  | /// let octal = make_encoding("01234567"); | 
1022  |  | /// let hexadecimal = make_encoding("0123456789abcdef"); | 
1023  |  | /// assert_eq!(binary.encode(b"Bit"), "010000100110100101110100");  | 
1024  |  | /// assert_eq!(octal.encode(b"Bit"), "20464564");  | 
1025  |  | /// assert_eq!(hexadecimal.encode(b"Bit"), "426974");  | 
1026  |  | /// ```  | 
1027  |  | ///  | 
1028  |  | /// The `binary` base has 2 symbols `0` and `1` with value 0 and 1 respectively. The `octal` base  | 
1029  |  | /// has 8 symbols `0` to `7` with value 0 to 7. The `hexadecimal` base has 16 symbols `0` to `9` and  | 
1030  |  | /// `a` to `f` with value 0 to 15. The following diagram gives the idea of how encoding works in the  | 
1031  |  | /// previous example (note that we can actually write such diagram only because the bit-order is  | 
1032  |  | /// most significant first):  | 
1033  |  | ///  | 
1034  |  | /// ```text  | 
1035  |  | /// [      octal] |  2  :  0  :  4  :  6  :  4  :  5  :  6  :  4  |  | 
1036  |  | /// [     binary] |0 1 0 0 0 0 1 0|0 1 1 0 1 0 0 1|0 1 1 1 0 1 0 0|  | 
1037  |  | /// [hexadecimal] |   4   :   2   |   6   :   9   |   7   :   4   |  | 
1038  |  | ///                ^-- LSB                                       ^-- MSB  | 
1039  |  | /// ```  | 
1040  |  | ///  | 
1041  |  | /// Note that in theory, these little-endian numbers are read from right to left (the most  | 
1042  |  | /// significant bit is at the right). Since leading zeros are meaningless (in our usual decimal  | 
1043  |  | /// notation 0123 is the same as 123), it explains why trailing bits must be zero. Trailing bits may  | 
1044  |  | /// occur when the bit-width of a base does not divide 8. Only binary, base4, and hexadecimal don't  | 
1045  |  | /// have trailing bits issues. So let's consider octal and base64, which have trailing bits in  | 
1046  |  | /// similar circumstances:  | 
1047  |  | ///  | 
1048  |  | /// ```rust  | 
1049  |  | /// use data_encoding::{Specification, BASE64_NOPAD}; | 
1050  |  | /// let octal = { | 
1051  |  | ///     let mut spec = Specification::new();  | 
1052  |  | ///     spec.symbols.push_str("01234567"); | 
1053  |  | ///     spec.encoding().unwrap()  | 
1054  |  | /// };  | 
1055  |  | /// assert_eq!(BASE64_NOPAD.encode(b"B"), "Qg");  | 
1056  |  | /// assert_eq!(octal.encode(b"B"), "204");  | 
1057  |  | /// ```  | 
1058  |  | ///  | 
1059  |  | /// We have the following diagram, where the base64 values are written between parentheses:  | 
1060  |  | ///  | 
1061  |  | /// ```text  | 
1062  |  | /// [base64] |   Q(16)   :   g(32)   : [has 4 zero trailing bits]  | 
1063  |  | /// [ octal] |  2  :  0  :  4  :       [has 1 zero trailing bit ]  | 
1064  |  | ///          |0 1 0 0 0 0 1 0|0 0 0 0  | 
1065  |  | /// [ ascii] |       B       |  | 
1066  |  | ///                           ^-^-^-^-- leading zeros / trailing bits  | 
1067  |  | /// ```  | 
1068  |  | ///  | 
1069  |  | /// ## Extensions  | 
1070  |  | ///  | 
1071  |  | /// ### Padding  | 
1072  |  | ///  | 
1073  |  | /// For octal and base64, lcm(8, 3) == lcm(8, 6) == 24 bits or 3 bytes. For base32, lcm(8, 5) is 40  | 
1074  |  | /// bits or 5 bytes. Let's consider octal and base64:  | 
1075  |  | ///  | 
1076  |  | /// ```rust  | 
1077  |  | /// use data_encoding::{Specification, BASE64}; | 
1078  |  | /// let octal = { | 
1079  |  | ///     let mut spec = Specification::new();  | 
1080  |  | ///     spec.symbols.push_str("01234567"); | 
1081  |  | ///     spec.padding = Some('='); | 
1082  |  | ///     spec.encoding().unwrap()  | 
1083  |  | /// };  | 
1084  |  | /// // We start encoding but we only have "B" for now.  | 
1085  |  | /// assert_eq!(BASE64.encode(b"B"), "Qg==");  | 
1086  |  | /// assert_eq!(octal.encode(b"B"), "204=====");  | 
1087  |  | /// // Now we have "it".  | 
1088  |  | /// assert_eq!(BASE64.encode(b"it"), "aXQ=");  | 
1089  |  | /// assert_eq!(octal.encode(b"it"), "322720==");  | 
1090  |  | /// // By concatenating everything, we may decode the original data.  | 
1091  |  | /// assert_eq!(BASE64.decode(b"Qg==aXQ=").unwrap(), b"Bit");  | 
1092  |  | /// assert_eq!(octal.decode(b"204=====322720==").unwrap(), b"Bit");  | 
1093  |  | /// ```  | 
1094  |  | ///  | 
1095  |  | /// We have the following diagrams:  | 
1096  |  | ///  | 
1097  |  | /// ```text  | 
1098  |  | /// [base64] |   Q(16)   :   g(32)   :     =     :     =     |  | 
1099  |  | /// [ octal] |  2  :  0  :  4  :  =  :  =  :  =  :  =  :  =  |  | 
1100  |  | ///          |0 1 0 0 0 0 1 0|. . . . . . . .|. . . . . . . .|  | 
1101  |  | /// [ ascii] |       B       |        end of block aligned --^  | 
1102  |  | ///          ^-- beginning of block aligned  | 
1103  |  | ///  | 
1104  |  | /// [base64] |   a(26)   :   X(23)   :   Q(16)   :     =     |  | 
1105  |  | /// [ octal] |  3  :  2  :  2  :  7  :  2  :  0  :  =  :  =  |  | 
1106  |  | ///          |0 1 1 0 1 0 0 1|0 1 1 1 0 1 0 0|. . . . . . . .|  | 
1107  |  | /// [ ascii] |       i       |       t       |  | 
1108  |  | /// ```  | 
1109  |  | ///  | 
1110  |  | /// ### Ignore characters when decoding  | 
1111  |  | ///  | 
1112  |  | /// The typical use-case is to ignore newlines (`\r` and `\n`). But to keep the example small, we  | 
1113  |  | /// will ignore spaces.  | 
1114  |  | ///  | 
1115  |  | /// ```rust  | 
1116  |  | /// let mut spec = data_encoding::HEXLOWER.specification();  | 
1117  |  | /// spec.ignore.push_str(" \t"); | 
1118  |  | /// let base = spec.encoding().unwrap();  | 
1119  |  | /// assert_eq!(base.decode(b"42 69 74"), base.decode(b"426974"));  | 
1120  |  | /// ```  | 
1121  |  | ///  | 
1122  |  | /// ### Wrap output when encoding  | 
1123  |  | ///  | 
1124  |  | /// The typical use-case is to wrap after 64 or 76 characters with a newline (`\r\n` or `\n`). But  | 
1125  |  | /// to keep the example small, we will wrap after 8 characters with a space.  | 
1126  |  | ///  | 
1127  |  | /// ```rust  | 
1128  |  | /// let mut spec = data_encoding::BASE64.specification();  | 
1129  |  | /// spec.wrap.width = 8;  | 
1130  |  | /// spec.wrap.separator.push_str(" "); | 
1131  |  | /// let base64 = spec.encoding().unwrap();  | 
1132  |  | /// assert_eq!(base64.encode(b"Hey you"), "SGV5IHlv dQ== ");  | 
1133  |  | /// ```  | 
1134  |  | ///  | 
1135  |  | /// Note that the output always ends with the separator.  | 
1136  |  | ///  | 
1137  |  | /// ### Translate characters when decoding  | 
1138  |  | ///  | 
1139  |  | /// The typical use-case is to translate lowercase to uppercase or reciprocally, but it is also used  | 
1140  |  | /// for letters that look alike, like `O0` or `Il1`. Let's illustrate both examples.  | 
1141  |  | ///  | 
1142  |  | /// ```rust  | 
1143  |  | /// let mut spec = data_encoding::HEXLOWER.specification();  | 
1144  |  | /// spec.translate.from.push_str("ABCDEFOIl"); | 
1145  |  | /// spec.translate.to.push_str("abcdef011"); | 
1146  |  | /// let base = spec.encoding().unwrap();  | 
1147  |  | /// assert_eq!(base.decode(b"BOIl"), base.decode(b"b011"));  | 
1148  |  | /// ```  | 
1149  |  | ///  | 
1150  |  | /// [base-conversion]: https://en.wikipedia.org/wiki/Positional_notation#Base_conversion  | 
1151  |  | /// [canonical]: https://tools.ietf.org/html/rfc4648#section-3.5  | 
1152  |  | #[derive(Debug, Clone)]  | 
1153  |  | #[cfg(feature = "alloc")]  | 
1154  |  | pub struct Specification { | 
1155  |  |     /// Symbols  | 
1156  |  |     ///  | 
1157  |  |     /// The number of symbols must be 2, 4, 8, 16, 32, or 64. Symbols must be ASCII characters  | 
1158  |  |     /// (smaller than 128) and they must be unique.  | 
1159  |  |     pub symbols: String,  | 
1160  |  |  | 
1161  |  |     /// Bit-order  | 
1162  |  |     ///  | 
1163  |  |     /// The default is to use most significant bit first since it is the most common.  | 
1164  |  |     pub bit_order: BitOrder,  | 
1165  |  |  | 
1166  |  |     /// Check trailing bits  | 
1167  |  |     ///  | 
1168  |  |     /// The default is to check trailing bits. This field is ignored when unnecessary (i.e. for  | 
1169  |  |     /// base2, base4, and base16).  | 
1170  |  |     pub check_trailing_bits: bool,  | 
1171  |  |  | 
1172  |  |     /// Padding  | 
1173  |  |     ///  | 
1174  |  |     /// The default is to not use padding. The padding character must be ASCII and must not be a  | 
1175  |  |     /// symbol.  | 
1176  |  |     pub padding: Option<char>,  | 
1177  |  |  | 
1178  |  |     /// Characters to ignore when decoding  | 
1179  |  |     ///  | 
1180  |  |     /// The default is to not ignore characters when decoding. The characters to ignore must be  | 
1181  |  |     /// ASCII and must not be symbols or the padding character.  | 
1182  |  |     pub ignore: String,  | 
1183  |  |  | 
1184  |  |     /// How to wrap the output when encoding  | 
1185  |  |     ///  | 
1186  |  |     /// The default is to not wrap the output when encoding. The wrapping characters must be ASCII  | 
1187  |  |     /// and must not be symbols or the padding character.  | 
1188  |  |     pub wrap: Wrap,  | 
1189  |  |  | 
1190  |  |     /// How to translate characters when decoding  | 
1191  |  |     ///  | 
1192  |  |     /// The default is to not translate characters when decoding. The characters to translate from  | 
1193  |  |     /// must be ASCII and must not have already been assigned a semantics. The characters to  | 
1194  |  |     /// translate to must be ASCII and must have been assigned a semantics (symbol, padding  | 
1195  |  |     /// character, or ignored character).  | 
1196  |  |     pub translate: Translate,  | 
1197  |  | }  | 
1198  |  |  | 
1199  |  | #[cfg(feature = "alloc")]  | 
1200  |  | impl Default for Specification { | 
1201  | 0  |     fn default() -> Self { | 
1202  | 0  |         Self::new()  | 
1203  | 0  |     }  | 
1204  |  | }  | 
1205  |  |  | 
1206  |  | impl Encoding { | 
1207  | 0  |     fn sym(&self) -> &[u8; 256] { | 
1208  | 0  |         self.0[0 .. 256].try_into().unwrap()  | 
1209  | 0  |     }  | 
1210  |  |  | 
1211  | 0  |     fn val(&self) -> &[u8; 256] { | 
1212  | 0  |         self.0[256 .. 512].try_into().unwrap()  | 
1213  | 0  |     }  | 
1214  |  |  | 
1215  | 0  |     fn pad(&self) -> Option<u8> { | 
1216  | 0  |         if self.0[512] < 128 { | 
1217  | 0  |             Some(self.0[512])  | 
1218  |  |         } else { | 
1219  | 0  |             None  | 
1220  |  |         }  | 
1221  | 0  |     }  | 
1222  |  |  | 
1223  | 0  |     fn ctb(&self) -> bool { | 
1224  | 0  |         self.0[513] & 0x10 != 0  | 
1225  | 0  |     }  | 
1226  |  |  | 
1227  | 0  |     fn msb(&self) -> bool { | 
1228  | 0  |         self.0[513] & 0x8 != 0  | 
1229  | 0  |     }  | 
1230  |  |  | 
1231  | 0  |     fn bit(&self) -> usize { | 
1232  | 0  |         (self.0[513] & 0x7) as usize  | 
1233  | 0  |     }  | 
1234  |  |  | 
1235  |  |     /// Minimum number of input and output blocks when encoding  | 
1236  | 0  |     fn block_len(&self) -> (usize, usize) { | 
1237  | 0  |         let bit = self.bit();  | 
1238  | 0  |         match self.wrap() { | 
1239  | 0  |             Some((col, end)) => (col / dec(bit) * enc(bit), col + end.len()),  | 
1240  | 0  |             None => (enc(bit), dec(bit)),  | 
1241  |  |         }  | 
1242  | 0  |     }  | 
1243  |  |  | 
1244  | 0  |     fn wrap(&self) -> Option<(usize, &[u8])> { | 
1245  | 0  |         if self.0.len() <= 515 { | 
1246  | 0  |             return None;  | 
1247  | 0  |         }  | 
1248  | 0  |         Some((self.0[514] as usize, &self.0[515 ..]))  | 
1249  | 0  |     }  | 
1250  |  |  | 
1251  | 0  |     fn has_ignore(&self) -> bool { | 
1252  | 0  |         self.0.len() >= 515  | 
1253  | 0  |     }  | 
1254  |  |  | 
1255  |  |     /// Returns the encoded length of an input of length `len`  | 
1256  |  |     ///  | 
1257  |  |     /// See [`encode_mut`] for when to use it.  | 
1258  |  |     ///  | 
1259  |  |     /// [`encode_mut`]: struct.Encoding.html#method.encode_mut  | 
1260  |  |     #[must_use]  | 
1261  | 0  |     pub fn encode_len(&self, len: usize) -> usize { | 
1262  | 0  |         dispatch! { | 
1263  | 0  |             let bit: usize = self.bit();  | 
1264  | 0  |             let pad: Option<u8> = self.pad();  | 
1265  | 0  |             let wrap: Option<(usize, &[u8])> = self.wrap();  | 
1266  | 0  |             encode_wrap_len(bit, pad, wrap, len)  | 
1267  |  |         }  | 
1268  | 0  |     }  | 
1269  |  |  | 
1270  |  |     /// Encodes `input` in `output`  | 
1271  |  |     ///  | 
1272  |  |     /// # Panics  | 
1273  |  |     ///  | 
1274  |  |     /// Panics if the `output` length does not match the result of [`encode_len`] for the `input`  | 
1275  |  |     /// length.  | 
1276  |  |     ///  | 
1277  |  |     /// # Examples  | 
1278  |  |     ///  | 
1279  |  |     /// ```rust  | 
1280  |  |     /// use data_encoding::BASE64;  | 
1281  |  |     /// # let mut buffer = vec![0; 100];  | 
1282  |  |     /// let input = b"Hello world";  | 
1283  |  |     /// let output = &mut buffer[0 .. BASE64.encode_len(input.len())];  | 
1284  |  |     /// BASE64.encode_mut(input, output);  | 
1285  |  |     /// assert_eq!(output, b"SGVsbG8gd29ybGQ=");  | 
1286  |  |     /// ```  | 
1287  |  |     ///  | 
1288  |  |     /// [`encode_len`]: struct.Encoding.html#method.encode_len  | 
1289  |  |     #[allow(clippy::cognitive_complexity)]  | 
1290  | 0  |     pub fn encode_mut(&self, input: &[u8], output: &mut [u8]) { | 
1291  | 0  |         assert_eq!(output.len(), self.encode_len(input.len()));  | 
1292  | 0  |         dispatch! { | 
1293  | 0  |             let bit: usize = self.bit();  | 
1294  | 0  |             let msb: bool = self.msb();  | 
1295  | 0  |             let pad: Option<u8> = self.pad();  | 
1296  | 0  |             let wrap: Option<(usize, &[u8])> = self.wrap();  | 
1297  | 0  |             encode_wrap_mut(bit, msb, self.sym(), pad, wrap, input, output)  | 
1298  |  |         }  | 
1299  | 0  |     }  | 
1300  |  |  | 
1301  |  |     /// Encodes `input` in `output` and returns it as a `&str`  | 
1302  |  |     ///  | 
1303  |  |     /// It is guaranteed that `output` and the return value only differ by their type. They both  | 
1304  |  |     /// point to the same range of memory (pointer and length).  | 
1305  |  |     ///  | 
1306  |  |     /// # Panics  | 
1307  |  |     ///  | 
1308  |  |     /// Panics if the `output` length does not match the result of [`encode_len`] for the `input`  | 
1309  |  |     /// length.  | 
1310  |  |     ///  | 
1311  |  |     /// # Examples  | 
1312  |  |     ///  | 
1313  |  |     /// ```rust  | 
1314  |  |     /// use data_encoding::BASE64;  | 
1315  |  |     /// # let mut buffer = vec![0; 100];  | 
1316  |  |     /// let input = b"Hello world";  | 
1317  |  |     /// let output = &mut buffer[0 .. BASE64.encode_len(input.len())];  | 
1318  |  |     /// assert_eq!(BASE64.encode_mut_str(input, output), "SGVsbG8gd29ybGQ=");  | 
1319  |  |     /// ```  | 
1320  |  |     ///  | 
1321  |  |     /// [`encode_len`]: struct.Encoding.html#method.encode_len  | 
1322  | 0  |     pub fn encode_mut_str<'a>(&self, input: &[u8], output: &'a mut [u8]) -> &'a str { | 
1323  | 0  |         self.encode_mut(input, output);  | 
1324  | 0  |         safety_assert!(output.is_ascii());  | 
1325  |  |         // SAFETY: Ensured by correctness guarantees of encode_mut (and asserted above).  | 
1326  | 0  |         unsafe { core::str::from_utf8_unchecked(output) } | 
1327  | 0  |     }  | 
1328  |  |  | 
1329  |  |     /// Appends the encoding of `input` to `output`  | 
1330  |  |     ///  | 
1331  |  |     /// # Examples  | 
1332  |  |     ///  | 
1333  |  |     /// ```rust  | 
1334  |  |     /// use data_encoding::BASE64;  | 
1335  |  |     /// # let mut buffer = vec![0; 100];  | 
1336  |  |     /// let input = b"Hello world";  | 
1337  |  |     /// let mut output = "Result: ".to_string();  | 
1338  |  |     /// BASE64.encode_append(input, &mut output);  | 
1339  |  |     /// assert_eq!(output, "Result: SGVsbG8gd29ybGQ=");  | 
1340  |  |     /// ```  | 
1341  |  |     #[cfg(feature = "alloc")]  | 
1342  | 0  |     pub fn encode_append(&self, input: &[u8], output: &mut String) { | 
1343  |  |         // SAFETY: Ensured by correctness guarantees of encode_mut (and asserted below).  | 
1344  | 0  |         let output = unsafe { output.as_mut_vec() }; | 
1345  | 0  |         let output_len = output.len();  | 
1346  | 0  |         output.resize(output_len + self.encode_len(input.len()), 0u8);  | 
1347  | 0  |         self.encode_mut(input, &mut output[output_len ..]);  | 
1348  | 0  |         safety_assert!(output[output_len ..].is_ascii());  | 
1349  | 0  |     }  | 
1350  |  |  | 
1351  |  |     /// Returns an object to encode a fragmented input and append it to `output`  | 
1352  |  |     ///  | 
1353  |  |     /// See the documentation of [`Encoder`] for more details and examples.  | 
1354  |  |     #[cfg(feature = "alloc")]  | 
1355  | 0  |     pub fn new_encoder<'a>(&'a self, output: &'a mut String) -> Encoder<'a> { | 
1356  | 0  |         Encoder::new(self, output)  | 
1357  | 0  |     }  | 
1358  |  |  | 
1359  |  |     /// Writes the encoding of `input` to `output`  | 
1360  |  |     ///  | 
1361  |  |     /// This allocates a buffer of 1024 bytes on the stack. If you want to control the buffer size  | 
1362  |  |     /// and location, use [`Encoding::encode_write_buffer()`] instead.  | 
1363  |  |     ///  | 
1364  |  |     /// # Errors  | 
1365  |  |     ///  | 
1366  |  |     /// Returns an error when writing to the output fails.  | 
1367  | 0  |     pub fn encode_write(  | 
1368  | 0  |         &self, input: &[u8], output: &mut impl core::fmt::Write,  | 
1369  | 0  |     ) -> core::fmt::Result { | 
1370  | 0  |         self.encode_write_buffer(input, output, &mut [0; 1024])  | 
1371  | 0  |     }  | 
1372  |  |  | 
1373  |  |     /// Writes the encoding of `input` to `output` using a temporary `buffer`  | 
1374  |  |     ///  | 
1375  |  |     /// # Panics  | 
1376  |  |     ///  | 
1377  |  |     /// Panics if the buffer is shorter than 510 bytes.  | 
1378  |  |     ///  | 
1379  |  |     /// # Errors  | 
1380  |  |     ///  | 
1381  |  |     /// Returns an error when writing to the output fails.  | 
1382  | 0  |     pub fn encode_write_buffer(  | 
1383  | 0  |         &self, input: &[u8], output: &mut impl core::fmt::Write, buffer: &mut [u8],  | 
1384  | 0  |     ) -> core::fmt::Result { | 
1385  | 0  |         assert!(510 <= buffer.len());  | 
1386  | 0  |         let (enc, dec) = self.block_len();  | 
1387  | 0  |         for input in input.chunks(buffer.len() / dec * enc) { | 
1388  | 0  |             let buffer = &mut buffer[.. self.encode_len(input.len())];  | 
1389  | 0  |             self.encode_mut(input, buffer);  | 
1390  | 0  |             safety_assert!(buffer.is_ascii());  | 
1391  |  |             // SAFETY: Ensured by correctness guarantees of encode_mut (and asserted above).  | 
1392  | 0  |             output.write_str(unsafe { core::str::from_utf8_unchecked(buffer) })?; | 
1393  |  |         }  | 
1394  | 0  |         Ok(())  | 
1395  | 0  |     }  | 
1396  |  |  | 
1397  |  |     /// Returns an object to display the encoding of `input`  | 
1398  |  |     ///  | 
1399  |  |     /// # Examples  | 
1400  |  |     ///  | 
1401  |  |     /// ```rust  | 
1402  |  |     /// use data_encoding::BASE64;  | 
1403  |  |     /// assert_eq!(  | 
1404  |  |     ///     format!("Payload: {}", BASE64.encode_display(b"Hello world")), | 
1405  |  |     ///     "Payload: SGVsbG8gd29ybGQ=",  | 
1406  |  |     /// );  | 
1407  |  |     /// ```  | 
1408  |  |     #[must_use]  | 
1409  | 0  |     pub fn encode_display<'a>(&'a self, input: &'a [u8]) -> Display<'a> { | 
1410  | 0  |         Display { encoding: self, input } | 
1411  | 0  |     }  | 
1412  |  |  | 
1413  |  |     /// Returns encoded `input`  | 
1414  |  |     ///  | 
1415  |  |     /// # Examples  | 
1416  |  |     ///  | 
1417  |  |     /// ```rust  | 
1418  |  |     /// use data_encoding::BASE64;  | 
1419  |  |     /// assert_eq!(BASE64.encode(b"Hello world"), "SGVsbG8gd29ybGQ=");  | 
1420  |  |     /// ```  | 
1421  |  |     #[cfg(feature = "alloc")]  | 
1422  |  |     #[must_use]  | 
1423  | 0  |     pub fn encode(&self, input: &[u8]) -> String { | 
1424  | 0  |         let mut output = vec![0u8; self.encode_len(input.len())];  | 
1425  | 0  |         self.encode_mut(input, &mut output);  | 
1426  | 0  |         safety_assert!(output.is_ascii());  | 
1427  |  |         // SAFETY: Ensured by correctness guarantees of encode_mut (and asserted above).  | 
1428  | 0  |         unsafe { String::from_utf8_unchecked(output) } | 
1429  | 0  |     }  | 
1430  |  |  | 
1431  |  |     /// Returns the maximum decoded length of an input of length `len`  | 
1432  |  |     ///  | 
1433  |  |     /// See [`decode_mut`] for when to use it. In particular, the actual decoded length might be  | 
1434  |  |     /// smaller if the actual input contains padding or ignored characters.  | 
1435  |  |     ///  | 
1436  |  |     /// # Errors  | 
1437  |  |     ///  | 
1438  |  |     /// Returns an error if `len` is invalid. The error kind is [`Length`] and the [position] is the  | 
1439  |  |     /// greatest valid input length.  | 
1440  |  |     ///  | 
1441  |  |     /// [`decode_mut`]: struct.Encoding.html#method.decode_mut  | 
1442  |  |     /// [`Length`]: enum.DecodeKind.html#variant.Length  | 
1443  |  |     /// [position]: struct.DecodeError.html#structfield.position  | 
1444  | 0  |     pub fn decode_len(&self, len: usize) -> Result<usize, DecodeError> { | 
1445  | 0  |         let (ilen, olen) = dispatch! { | 
1446  | 0  |             let bit: usize = self.bit();  | 
1447  | 0  |             let pad: bool = self.pad().is_some();  | 
1448  | 0  |             decode_wrap_len(bit, pad, len)  | 
1449  |  |         };  | 
1450  | 0  |         check!(  | 
1451  | 0  |             DecodeError { position: ilen, kind: DecodeKind::Length }, | 
1452  | 0  |             self.has_ignore() || len == ilen  | 
1453  |  |         );  | 
1454  | 0  |         Ok(olen)  | 
1455  | 0  |     }  | 
1456  |  |  | 
1457  |  |     /// Decodes `input` in `output`  | 
1458  |  |     ///  | 
1459  |  |     /// Returns the length of the decoded output. This length may be smaller than the output length  | 
1460  |  |     /// if the input contained padding or ignored characters. The output bytes after the returned  | 
1461  |  |     /// length are not initialized and should not be read.  | 
1462  |  |     ///  | 
1463  |  |     /// # Panics  | 
1464  |  |     ///  | 
1465  |  |     /// Panics if the `output` length does not match the result of [`decode_len`] for the `input`  | 
1466  |  |     /// length. Also panics if `decode_len` fails for the `input` length.  | 
1467  |  |     ///  | 
1468  |  |     /// # Errors  | 
1469  |  |     ///  | 
1470  |  |     /// Returns an error if `input` is invalid. See [`decode`] for more details. The are two  | 
1471  |  |     /// differences though:  | 
1472  |  |     ///  | 
1473  |  |     /// - [`Length`] may be returned only if the encoding allows ignored characters, because  | 
1474  |  |     ///   otherwise this is already checked by [`decode_len`].  | 
1475  |  |     /// - The [`read`] first bytes of the input have been successfully decoded to the [`written`]  | 
1476  |  |     ///   first bytes of the output.  | 
1477  |  |     ///  | 
1478  |  |     /// # Examples  | 
1479  |  |     ///  | 
1480  |  |     /// ```rust  | 
1481  |  |     /// use data_encoding::BASE64;  | 
1482  |  |     /// # let mut buffer = vec![0; 100];  | 
1483  |  |     /// let input = b"SGVsbA==byB3b3JsZA==";  | 
1484  |  |     /// let output = &mut buffer[0 .. BASE64.decode_len(input.len()).unwrap()];  | 
1485  |  |     /// let len = BASE64.decode_mut(input, output).unwrap();  | 
1486  |  |     /// assert_eq!(&output[0 .. len], b"Hello world");  | 
1487  |  |     /// ```  | 
1488  |  |     ///  | 
1489  |  |     /// [`decode_len`]: struct.Encoding.html#method.decode_len  | 
1490  |  |     /// [`decode`]: struct.Encoding.html#method.decode  | 
1491  |  |     /// [`Length`]: enum.DecodeKind.html#variant.Length  | 
1492  |  |     /// [`read`]: struct.DecodePartial.html#structfield.read  | 
1493  |  |     /// [`written`]: struct.DecodePartial.html#structfield.written  | 
1494  |  |     #[allow(clippy::cognitive_complexity)]  | 
1495  | 0  |     pub fn decode_mut(&self, input: &[u8], output: &mut [u8]) -> Result<usize, DecodePartial> { | 
1496  | 0  |         assert_eq!(Ok(output.len()), self.decode_len(input.len()));  | 
1497  | 0  |         dispatch! { | 
1498  | 0  |             let bit: usize = self.bit();  | 
1499  | 0  |             let msb: bool = self.msb();  | 
1500  | 0  |             let pad: bool = self.pad().is_some();  | 
1501  | 0  |             let has_ignore: bool = self.has_ignore();  | 
1502  | 0  |             decode_wrap_mut(bit, msb, self.ctb(), self.val(), pad, has_ignore,  | 
1503  | 0  |                             input, output)  | 
1504  |  |         }  | 
1505  | 0  |     }  | 
1506  |  |  | 
1507  |  |     /// Returns decoded `input`  | 
1508  |  |     ///  | 
1509  |  |     /// # Errors  | 
1510  |  |     ///  | 
1511  |  |     /// Returns an error if `input` is invalid. The error kind can be:  | 
1512  |  |     ///  | 
1513  |  |     /// - [`Length`] if the input length is invalid. The [position] is the greatest valid input  | 
1514  |  |     ///   length.  | 
1515  |  |     /// - [`Symbol`] if the input contains an invalid character. The [position] is the first invalid  | 
1516  |  |     ///   character.  | 
1517  |  |     /// - [`Trailing`] if the input has non-zero trailing bits. This is only possible if the  | 
1518  |  |     ///   encoding checks trailing bits. The [position] is the first character containing non-zero  | 
1519  |  |     ///   trailing bits.  | 
1520  |  |     /// - [`Padding`] if the input has an invalid padding length. This is only possible if the  | 
1521  |  |     ///   encoding uses padding. The [position] is the first padding character of the first padding  | 
1522  |  |     ///   of invalid length.  | 
1523  |  |     ///  | 
1524  |  |     /// # Examples  | 
1525  |  |     ///  | 
1526  |  |     /// ```rust  | 
1527  |  |     /// use data_encoding::BASE64;  | 
1528  |  |     /// assert_eq!(BASE64.decode(b"SGVsbA==byB3b3JsZA==").unwrap(), b"Hello world");  | 
1529  |  |     /// ```  | 
1530  |  |     ///  | 
1531  |  |     /// [`Length`]: enum.DecodeKind.html#variant.Length  | 
1532  |  |     /// [`Symbol`]: enum.DecodeKind.html#variant.Symbol  | 
1533  |  |     /// [`Trailing`]: enum.DecodeKind.html#variant.Trailing  | 
1534  |  |     /// [`Padding`]: enum.DecodeKind.html#variant.Padding  | 
1535  |  |     /// [position]: struct.DecodeError.html#structfield.position  | 
1536  |  |     #[cfg(feature = "alloc")]  | 
1537  | 0  |     pub fn decode(&self, input: &[u8]) -> Result<Vec<u8>, DecodeError> { | 
1538  | 0  |         let mut output = vec![0u8; self.decode_len(input.len())?];  | 
1539  | 0  |         let len = self.decode_mut(input, &mut output).map_err(|partial| partial.error)?;  | 
1540  | 0  |         output.truncate(len);  | 
1541  | 0  |         Ok(output)  | 
1542  | 0  |     }  | 
1543  |  |  | 
1544  |  |     /// Returns the bit-width  | 
1545  |  |     #[must_use]  | 
1546  | 0  |     pub fn bit_width(&self) -> usize { | 
1547  | 0  |         self.bit()  | 
1548  | 0  |     }  | 
1549  |  |  | 
1550  |  |     /// Returns whether the encoding is canonical  | 
1551  |  |     ///  | 
1552  |  |     /// An encoding is not canonical if one of the following conditions holds:  | 
1553  |  |     ///  | 
1554  |  |     /// - trailing bits are not checked  | 
1555  |  |     /// - padding is used  | 
1556  |  |     /// - characters are ignored  | 
1557  |  |     /// - characters are translated  | 
1558  |  |     #[must_use]  | 
1559  | 0  |     pub fn is_canonical(&self) -> bool { | 
1560  | 0  |         if !self.ctb() { | 
1561  | 0  |             return false;  | 
1562  | 0  |         }  | 
1563  | 0  |         let bit = self.bit();  | 
1564  | 0  |         let sym = self.sym();  | 
1565  | 0  |         let val = self.val();  | 
1566  | 0  |         for i in 0 .. 256 { | 
1567  | 0  |             if val[i] == INVALID { | 
1568  | 0  |                 continue;  | 
1569  | 0  |             }  | 
1570  | 0  |             if val[i] >= 1 << bit { | 
1571  | 0  |                 return false;  | 
1572  | 0  |             }  | 
1573  | 0  |             if sym[val[i] as usize] as usize != i { | 
1574  | 0  |                 return false;  | 
1575  | 0  |             }  | 
1576  |  |         }  | 
1577  | 0  |         true  | 
1578  | 0  |     }  | 
1579  |  |  | 
1580  |  |     /// Returns the encoding specification  | 
1581  |  |     #[allow(clippy::missing_panics_doc)] // no panic  | 
1582  |  |     #[cfg(feature = "alloc")]  | 
1583  |  |     #[must_use]  | 
1584  | 0  |     pub fn specification(&self) -> Specification { | 
1585  | 0  |         let mut specification = Specification::new();  | 
1586  | 0  |         specification  | 
1587  | 0  |             .symbols  | 
1588  | 0  |             .push_str(core::str::from_utf8(&self.sym()[0 .. 1 << self.bit()]).unwrap());  | 
1589  |  |         specification.bit_order =  | 
1590  | 0  |             if self.msb() { MostSignificantFirst } else { LeastSignificantFirst }; | 
1591  | 0  |         specification.check_trailing_bits = self.ctb();  | 
1592  | 0  |         if let Some(pad) = self.pad() { | 
1593  | 0  |             specification.padding = Some(pad as char);  | 
1594  | 0  |         }  | 
1595  | 0  |         for i in 0 .. 128u8 { | 
1596  | 0  |             if self.val()[i as usize] != IGNORE { | 
1597  | 0  |                 continue;  | 
1598  | 0  |             }  | 
1599  | 0  |             specification.ignore.push(i as char);  | 
1600  |  |         }  | 
1601  | 0  |         if let Some((col, end)) = self.wrap() { | 
1602  | 0  |             specification.wrap.width = col;  | 
1603  | 0  |             specification.wrap.separator = core::str::from_utf8(end).unwrap().to_owned();  | 
1604  | 0  |         }  | 
1605  | 0  |         for i in 0 .. 128u8 { | 
1606  | 0  |             let canonical = if self.val()[i as usize] < 1 << self.bit() { | 
1607  | 0  |                 self.sym()[self.val()[i as usize] as usize]  | 
1608  | 0  |             } else if self.val()[i as usize] == PADDING { | 
1609  | 0  |                 self.pad().unwrap()  | 
1610  |  |             } else { | 
1611  | 0  |                 continue;  | 
1612  |  |             };  | 
1613  | 0  |             if i == canonical { | 
1614  | 0  |                 continue;  | 
1615  | 0  |             }  | 
1616  | 0  |             specification.translate.from.push(i as char);  | 
1617  | 0  |             specification.translate.to.push(canonical as char);  | 
1618  |  |         }  | 
1619  | 0  |         specification  | 
1620  | 0  |     }  | 
1621  |  |  | 
1622  |  |     #[doc(hidden)]  | 
1623  |  |     #[must_use]  | 
1624  | 0  |     pub const fn internal_new(implementation: &'static [u8]) -> Encoding { | 
1625  |  |         #[cfg(feature = "alloc")]  | 
1626  | 0  |         let encoding = Encoding(Cow::Borrowed(implementation));  | 
1627  |  |         #[cfg(not(feature = "alloc"))]  | 
1628  |  |         let encoding = Encoding(implementation);  | 
1629  | 0  |         encoding  | 
1630  | 0  |     }  | 
1631  |  |  | 
1632  |  |     #[doc(hidden)]  | 
1633  |  |     #[must_use]  | 
1634  | 0  |     pub fn internal_implementation(&self) -> &[u8] { | 
1635  | 0  |         &self.0  | 
1636  | 0  |     }  | 
1637  |  | }  | 
1638  |  |  | 
1639  |  | /// Encodes fragmented input to an output  | 
1640  |  | ///  | 
1641  |  | /// It is equivalent to use an [`Encoder`] with multiple calls to [`Encoder::append()`] than to  | 
1642  |  | /// first concatenate all the input and then use [`Encoding::encode_append()`]. In particular, this  | 
1643  |  | /// function will not introduce padding or wrapping between inputs.  | 
1644  |  | ///  | 
1645  |  | /// # Examples  | 
1646  |  | ///  | 
1647  |  | /// ```rust  | 
1648  |  | /// // This is a bit inconvenient but we can't take a long-term reference to data_encoding::BASE64  | 
1649  |  | /// // because it's a constant. We need to use a static which has an address instead. This will be  | 
1650  |  | /// // fixed in version 3 of the library.  | 
1651  |  | /// static BASE64: data_encoding::Encoding = data_encoding::BASE64;  | 
1652  |  | /// let mut output = String::new();  | 
1653  |  | /// let mut encoder = BASE64.new_encoder(&mut output);  | 
1654  |  | /// encoder.append(b"hello");  | 
1655  |  | /// encoder.append(b"world");  | 
1656  |  | /// encoder.finalize();  | 
1657  |  | /// assert_eq!(output, BASE64.encode(b"helloworld"));  | 
1658  |  | /// ```  | 
1659  |  | #[derive(Debug)]  | 
1660  |  | #[cfg(feature = "alloc")]  | 
1661  |  | pub struct Encoder<'a> { | 
1662  |  |     encoding: &'a Encoding,  | 
1663  |  |     output: &'a mut String,  | 
1664  |  |     buffer: [u8; 255],  | 
1665  |  |     length: u8,  | 
1666  |  | }  | 
1667  |  |  | 
1668  |  | #[cfg(feature = "alloc")]  | 
1669  |  | impl Drop for Encoder<'_> { | 
1670  | 0  |     fn drop(&mut self) { | 
1671  | 0  |         self.encoding.encode_append(&self.buffer[.. self.length as usize], self.output);  | 
1672  | 0  |     }  | 
1673  |  | }  | 
1674  |  |  | 
1675  |  | #[cfg(feature = "alloc")]  | 
1676  |  | impl<'a> Encoder<'a> { | 
1677  | 0  |     fn new(encoding: &'a Encoding, output: &'a mut String) -> Self { | 
1678  | 0  |         Encoder { encoding, output, buffer: [0; 255], length: 0 } | 
1679  | 0  |     }  | 
1680  |  |  | 
1681  |  |     /// Encodes the provided input fragment and appends the result to the output  | 
1682  | 0  |     pub fn append(&mut self, mut input: &[u8]) { | 
1683  |  |         #[allow(clippy::cast_possible_truncation)] // no truncation  | 
1684  | 0  |         let max = self.encoding.block_len().0 as u8;  | 
1685  | 0  |         if self.length != 0 { | 
1686  | 0  |             let len = self.length;  | 
1687  |  |             #[allow(clippy::cast_possible_truncation)] // no truncation  | 
1688  | 0  |             let add = core::cmp::min((max - len) as usize, input.len()) as u8;  | 
1689  | 0  |             self.buffer[len as usize ..][.. add as usize].copy_from_slice(&input[.. add as usize]);  | 
1690  | 0  |             self.length += add;  | 
1691  | 0  |             input = &input[add as usize ..];  | 
1692  | 0  |             if self.length != max { | 
1693  | 0  |                 debug_assert!(self.length < max);  | 
1694  | 0  |                 debug_assert!(input.is_empty());  | 
1695  | 0  |                 return;  | 
1696  | 0  |             }  | 
1697  | 0  |             self.encoding.encode_append(&self.buffer[.. max as usize], self.output);  | 
1698  | 0  |             self.length = 0;  | 
1699  | 0  |         }  | 
1700  | 0  |         let len = floor(input.len(), max as usize);  | 
1701  | 0  |         self.encoding.encode_append(&input[.. len], self.output);  | 
1702  | 0  |         input = &input[len ..];  | 
1703  |  |         #[allow(clippy::cast_possible_truncation)] // no truncation  | 
1704  | 0  |         let len = input.len() as u8;  | 
1705  | 0  |         self.buffer[.. len as usize].copy_from_slice(input);  | 
1706  | 0  |         self.length = len;  | 
1707  | 0  |     }  | 
1708  |  |  | 
1709  |  |     /// Makes sure all inputs have been encoded and appended to the output  | 
1710  |  |     ///  | 
1711  |  |     /// This is equivalent to dropping the encoder and required for correctness, otherwise some  | 
1712  |  |     /// encoded data may be missing at the end.  | 
1713  | 0  |     pub fn finalize(self) {} | 
1714  |  | }  | 
1715  |  |  | 
1716  |  | /// Wraps an encoding and input for display purposes.  | 
1717  |  | #[derive(Debug)]  | 
1718  |  | pub struct Display<'a> { | 
1719  |  |     encoding: &'a Encoding,  | 
1720  |  |     input: &'a [u8],  | 
1721  |  | }  | 
1722  |  |  | 
1723  |  | impl core::fmt::Display for Display<'_> { | 
1724  | 0  |     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 
1725  | 0  |         self.encoding.encode_write(self.input, f)  | 
1726  | 0  |     }  | 
1727  |  | }  | 
1728  |  |  | 
1729  |  | #[derive(Debug, Copy, Clone)]  | 
1730  |  | #[cfg(feature = "alloc")]  | 
1731  |  | enum SpecificationErrorImpl { | 
1732  |  |     BadSize,  | 
1733  |  |     NotAscii,  | 
1734  |  |     Duplicate(u8),  | 
1735  |  |     ExtraPadding,  | 
1736  |  |     WrapLength,  | 
1737  |  |     WrapWidth(u8),  | 
1738  |  |     FromTo,  | 
1739  |  |     Undefined(u8),  | 
1740  |  | }  | 
1741  |  | #[cfg(feature = "alloc")]  | 
1742  |  | use crate::SpecificationErrorImpl::*;  | 
1743  |  |  | 
1744  |  | /// Specification error  | 
1745  |  | #[derive(Debug, Copy, Clone)]  | 
1746  |  | #[cfg(feature = "alloc")]  | 
1747  |  | pub struct SpecificationError(SpecificationErrorImpl);  | 
1748  |  |  | 
1749  |  | #[cfg(feature = "alloc")]  | 
1750  |  | impl core::fmt::Display for SpecificationError { | 
1751  | 0  |     fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 
1752  | 0  |         match self.0 { | 
1753  | 0  |             BadSize => write!(f, "invalid number of symbols"),  | 
1754  | 0  |             NotAscii => write!(f, "non-ascii character"),  | 
1755  | 0  |             Duplicate(c) => write!(f, "{:?} has conflicting definitions", c as char), | 
1756  | 0  |             ExtraPadding => write!(f, "unnecessary padding"),  | 
1757  | 0  |             WrapLength => write!(f, "invalid wrap width or separator length"),  | 
1758  | 0  |             WrapWidth(x) => write!(f, "wrap width not a multiple of {}", x), | 
1759  | 0  |             FromTo => write!(f, "translate from/to length mismatch"),  | 
1760  | 0  |             Undefined(c) => write!(f, "{:?} is undefined", c as char), | 
1761  |  |         }  | 
1762  | 0  |     }  | 
1763  |  | }  | 
1764  |  |  | 
1765  |  | #[cfg(feature = "std")]  | 
1766  |  | impl std::error::Error for SpecificationError { | 
1767  | 0  |     fn description(&self) -> &str { | 
1768  | 0  |         match self.0 { | 
1769  | 0  |             BadSize => "invalid number of symbols",  | 
1770  | 0  |             NotAscii => "non-ascii character",  | 
1771  | 0  |             Duplicate(_) => "conflicting definitions",  | 
1772  | 0  |             ExtraPadding => "unnecessary padding",  | 
1773  | 0  |             WrapLength => "invalid wrap width or separator length",  | 
1774  | 0  |             WrapWidth(_) => "wrap width not a multiple",  | 
1775  | 0  |             FromTo => "translate from/to length mismatch",  | 
1776  | 0  |             Undefined(_) => "undefined character",  | 
1777  |  |         }  | 
1778  | 0  |     }  | 
1779  |  | }  | 
1780  |  |  | 
1781  |  | #[cfg(feature = "alloc")]  | 
1782  |  | impl Specification { | 
1783  |  |     /// Returns a default specification  | 
1784  |  |     #[must_use]  | 
1785  | 0  |     pub fn new() -> Specification { | 
1786  | 0  |         Specification { | 
1787  | 0  |             symbols: String::new(),  | 
1788  | 0  |             bit_order: MostSignificantFirst,  | 
1789  | 0  |             check_trailing_bits: true,  | 
1790  | 0  |             padding: None,  | 
1791  | 0  |             ignore: String::new(),  | 
1792  | 0  |             wrap: Wrap { width: 0, separator: String::new() }, | 
1793  | 0  |             translate: Translate { from: String::new(), to: String::new() }, | 
1794  | 0  |         }  | 
1795  | 0  |     }  | 
1796  |  |  | 
1797  |  |     /// Returns the specified encoding  | 
1798  |  |     ///  | 
1799  |  |     /// # Errors  | 
1800  |  |     ///  | 
1801  |  |     /// Returns an error if the specification is invalid.  | 
1802  | 0  |     pub fn encoding(&self) -> Result<Encoding, SpecificationError> { | 
1803  | 0  |         let symbols = self.symbols.as_bytes();  | 
1804  | 0  |         let bit: u8 = match symbols.len() { | 
1805  | 0  |             2 => 1,  | 
1806  | 0  |             4 => 2,  | 
1807  | 0  |             8 => 3,  | 
1808  | 0  |             16 => 4,  | 
1809  | 0  |             32 => 5,  | 
1810  | 0  |             64 => 6,  | 
1811  | 0  |             _ => return Err(SpecificationError(BadSize)),  | 
1812  |  |         };  | 
1813  | 0  |         let mut values = [INVALID; 128];  | 
1814  | 0  |         let set = |v: &mut [u8; 128], i: u8, x: u8| { | 
1815  | 0  |             check!(SpecificationError(NotAscii), i < 128);  | 
1816  | 0  |             if v[i as usize] == x { | 
1817  | 0  |                 return Ok(());  | 
1818  | 0  |             }  | 
1819  | 0  |             check!(SpecificationError(Duplicate(i)), v[i as usize] == INVALID);  | 
1820  | 0  |             v[i as usize] = x;  | 
1821  | 0  |             Ok(())  | 
1822  | 0  |         };  | 
1823  | 0  |         for (v, symbols) in symbols.iter().enumerate() { | 
1824  |  |             #[allow(clippy::cast_possible_truncation)] // no truncation  | 
1825  | 0  |             set(&mut values, *symbols, v as u8)?;  | 
1826  |  |         }  | 
1827  | 0  |         let msb = self.bit_order == MostSignificantFirst;  | 
1828  | 0  |         let ctb = self.check_trailing_bits || 8 % bit == 0;  | 
1829  | 0  |         let pad = match self.padding { | 
1830  | 0  |             None => None,  | 
1831  | 0  |             Some(pad) => { | 
1832  | 0  |                 check!(SpecificationError(ExtraPadding), 8 % bit != 0);  | 
1833  | 0  |                 check!(SpecificationError(NotAscii), pad.len_utf8() == 1);  | 
1834  | 0  |                 set(&mut values, pad as u8, PADDING)?;  | 
1835  | 0  |                 Some(pad as u8)  | 
1836  |  |             }  | 
1837  |  |         };  | 
1838  | 0  |         for i in self.ignore.bytes() { | 
1839  | 0  |             set(&mut values, i, IGNORE)?;  | 
1840  |  |         }  | 
1841  | 0  |         let wrap = if self.wrap.separator.is_empty() || self.wrap.width == 0 { | 
1842  | 0  |             None  | 
1843  |  |         } else { | 
1844  | 0  |             let col = self.wrap.width;  | 
1845  | 0  |             let end = self.wrap.separator.as_bytes();  | 
1846  | 0  |             check!(SpecificationError(WrapLength), col < 256 && end.len() < 256);  | 
1847  |  |             #[allow(clippy::cast_possible_truncation)] // no truncation  | 
1848  | 0  |             let col = col as u8;  | 
1849  |  |             #[allow(clippy::cast_possible_truncation)] // no truncation  | 
1850  | 0  |             let dec = dec(bit as usize) as u8;  | 
1851  | 0  |             check!(SpecificationError(WrapWidth(dec)), col % dec == 0);  | 
1852  | 0  |             for &i in end { | 
1853  | 0  |                 set(&mut values, i, IGNORE)?;  | 
1854  |  |             }  | 
1855  | 0  |             Some((col, end))  | 
1856  |  |         };  | 
1857  | 0  |         let from = self.translate.from.as_bytes();  | 
1858  | 0  |         let to = self.translate.to.as_bytes();  | 
1859  | 0  |         check!(SpecificationError(FromTo), from.len() == to.len());  | 
1860  | 0  |         for i in 0 .. from.len() { | 
1861  | 0  |             check!(SpecificationError(NotAscii), to[i] < 128);  | 
1862  | 0  |             let v = values[to[i] as usize];  | 
1863  | 0  |             check!(SpecificationError(Undefined(to[i])), v != INVALID);  | 
1864  | 0  |             set(&mut values, from[i], v)?;  | 
1865  |  |         }  | 
1866  | 0  |         let mut encoding = Vec::new();  | 
1867  | 0  |         for _ in 0 .. 256 / symbols.len() { | 
1868  | 0  |             encoding.extend_from_slice(symbols);  | 
1869  | 0  |         }  | 
1870  | 0  |         encoding.extend_from_slice(&values);  | 
1871  | 0  |         encoding.extend_from_slice(&[INVALID; 128]);  | 
1872  | 0  |         match pad { | 
1873  | 0  |             None => encoding.push(INVALID),  | 
1874  | 0  |             Some(pad) => encoding.push(pad),  | 
1875  |  |         }  | 
1876  | 0  |         encoding.push(bit);  | 
1877  | 0  |         if msb { | 
1878  | 0  |             encoding[513] |= 0x08;  | 
1879  | 0  |         }  | 
1880  | 0  |         if ctb { | 
1881  | 0  |             encoding[513] |= 0x10;  | 
1882  | 0  |         }  | 
1883  | 0  |         if let Some((col, end)) = wrap { | 
1884  | 0  |             encoding.push(col);  | 
1885  | 0  |             encoding.extend_from_slice(end);  | 
1886  | 0  |         } else if values.contains(&IGNORE) { | 
1887  | 0  |             encoding.push(0);  | 
1888  | 0  |         }  | 
1889  | 0  |         Ok(Encoding(Cow::Owned(encoding)))  | 
1890  | 0  |     }  | 
1891  |  | }  | 
1892  |  |  | 
1893  |  | /// Lowercase hexadecimal encoding  | 
1894  |  | ///  | 
1895  |  | /// This encoding is a static version of:  | 
1896  |  | ///  | 
1897  |  | /// ```rust  | 
1898  |  | /// # use data_encoding::{Specification, HEXLOWER}; | 
1899  |  | /// let mut spec = Specification::new();  | 
1900  |  | /// spec.symbols.push_str("0123456789abcdef"); | 
1901  |  | /// assert_eq!(HEXLOWER, spec.encoding().unwrap());  | 
1902  |  | /// ```  | 
1903  |  | ///  | 
1904  |  | /// # Examples  | 
1905  |  | ///  | 
1906  |  | /// ```rust  | 
1907  |  | /// use data_encoding::HEXLOWER;  | 
1908  |  | /// let deadbeef = vec![0xde, 0xad, 0xbe, 0xef];  | 
1909  |  | /// assert_eq!(HEXLOWER.decode(b"deadbeef").unwrap(), deadbeef);  | 
1910  |  | /// assert_eq!(HEXLOWER.encode(&deadbeef), "deadbeef");  | 
1911  |  | /// ```  | 
1912  |  | pub const HEXLOWER: Encoding = Encoding::internal_new(HEXLOWER_IMPL);  | 
1913  |  | const HEXLOWER_IMPL: &[u8] = &[  | 
1914  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54,  | 
1915  |  |     55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,  | 
1916  |  |     101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,  | 
1917  |  |     52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,  | 
1918  |  |     98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,  | 
1919  |  |     49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,  | 
1920  |  |     56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,  | 
1921  |  |     101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,  | 
1922  |  |     52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,  | 
1923  |  |     98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,  | 
1924  |  |     49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,  | 
1925  |  |     56, 57, 97, 98, 99, 100, 101, 102, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1926  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1927  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 1, 2,  | 
1928  |  |     3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1929  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1930  |  |     128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1931  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1932  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1933  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1934  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1935  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1936  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1937  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1938  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,  | 
1939  |  | ];  | 
1940  |  |  | 
1941  |  | /// Lowercase hexadecimal encoding with case-insensitive decoding  | 
1942  |  | ///  | 
1943  |  | /// This encoding is a static version of:  | 
1944  |  | ///  | 
1945  |  | /// ```rust  | 
1946  |  | /// # use data_encoding::{Specification, HEXLOWER_PERMISSIVE}; | 
1947  |  | /// let mut spec = Specification::new();  | 
1948  |  | /// spec.symbols.push_str("0123456789abcdef"); | 
1949  |  | /// spec.translate.from.push_str("ABCDEF"); | 
1950  |  | /// spec.translate.to.push_str("abcdef"); | 
1951  |  | /// assert_eq!(HEXLOWER_PERMISSIVE, spec.encoding().unwrap());  | 
1952  |  | /// ```  | 
1953  |  | ///  | 
1954  |  | /// # Examples  | 
1955  |  | ///  | 
1956  |  | /// ```rust  | 
1957  |  | /// use data_encoding::HEXLOWER_PERMISSIVE;  | 
1958  |  | /// let deadbeef = vec![0xde, 0xad, 0xbe, 0xef];  | 
1959  |  | /// assert_eq!(HEXLOWER_PERMISSIVE.decode(b"DeadBeef").unwrap(), deadbeef);  | 
1960  |  | /// assert_eq!(HEXLOWER_PERMISSIVE.encode(&deadbeef), "deadbeef");  | 
1961  |  | /// ```  | 
1962  |  | ///  | 
1963  |  | /// You can also define a shorter name:  | 
1964  |  | ///  | 
1965  |  | /// ```rust  | 
1966  |  | /// use data_encoding::{Encoding, HEXLOWER_PERMISSIVE}; | 
1967  |  | /// const HEX: Encoding = HEXLOWER_PERMISSIVE;  | 
1968  |  | /// ```  | 
1969  |  | pub const HEXLOWER_PERMISSIVE: Encoding = Encoding::internal_new(HEXLOWER_PERMISSIVE_IMPL);  | 
1970  |  | const HEXLOWER_PERMISSIVE_IMPL: &[u8] = &[  | 
1971  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54,  | 
1972  |  |     55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,  | 
1973  |  |     101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,  | 
1974  |  |     52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,  | 
1975  |  |     98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,  | 
1976  |  |     49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,  | 
1977  |  |     56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100,  | 
1978  |  |     101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51,  | 
1979  |  |     52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97,  | 
1980  |  |     98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48,  | 
1981  |  |     49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 48, 49, 50, 51, 52, 53, 54, 55,  | 
1982  |  |     56, 57, 97, 98, 99, 100, 101, 102, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1983  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1984  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 1, 2,  | 
1985  |  |     3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128,  | 
1986  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1987  |  |     128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1988  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1989  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1990  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1994  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
1995  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 28,  | 
1996  |  | ];  | 
1997  |  |  | 
1998  |  | /// Uppercase hexadecimal encoding  | 
1999  |  | ///  | 
2000  |  | /// This encoding is a static version of:  | 
2001  |  | ///  | 
2002  |  | /// ```rust  | 
2003  |  | /// # use data_encoding::{Specification, HEXUPPER}; | 
2004  |  | /// let mut spec = Specification::new();  | 
2005  |  | /// spec.symbols.push_str("0123456789ABCDEF"); | 
2006  |  | /// assert_eq!(HEXUPPER, spec.encoding().unwrap());  | 
2007  |  | /// ```  | 
2008  |  | ///  | 
2009  |  | /// It is compliant with [RFC4648] and known as "base16" or "hex".  | 
2010  |  | ///  | 
2011  |  | /// # Examples  | 
2012  |  | ///  | 
2013  |  | /// ```rust  | 
2014  |  | /// use data_encoding::HEXUPPER;  | 
2015  |  | /// let deadbeef = vec![0xde, 0xad, 0xbe, 0xef];  | 
2016  |  | /// assert_eq!(HEXUPPER.decode(b"DEADBEEF").unwrap(), deadbeef);  | 
2017  |  | /// assert_eq!(HEXUPPER.encode(&deadbeef), "DEADBEEF");  | 
2018  |  | /// ```  | 
2019  |  | ///  | 
2020  |  | /// [RFC4648]: https://tools.ietf.org/html/rfc4648#section-8  | 
2021  |  | pub const HEXUPPER: Encoding = Encoding::internal_new(HEXUPPER_IMPL);  | 
2022  |  | const HEXUPPER_IMPL: &[u8] = &[  | 
2023  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2024  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2025  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2026  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2027  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2028  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2029  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2030  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2031  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2032  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2033  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 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, 128, 128, 128, 128, 10, 11,  | 
2037  |  |     12, 13, 14, 15, 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, 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, 128, 128, 128, 128, 28,  | 
2047  |  | ];  | 
2048  |  |  | 
2049  |  | /// Uppercase hexadecimal encoding with case-insensitive decoding  | 
2050  |  | ///  | 
2051  |  | /// This encoding is a static version of:  | 
2052  |  | ///  | 
2053  |  | /// ```rust  | 
2054  |  | /// # use data_encoding::{Specification, HEXUPPER_PERMISSIVE}; | 
2055  |  | /// let mut spec = Specification::new();  | 
2056  |  | /// spec.symbols.push_str("0123456789ABCDEF"); | 
2057  |  | /// spec.translate.from.push_str("abcdef"); | 
2058  |  | /// spec.translate.to.push_str("ABCDEF"); | 
2059  |  | /// assert_eq!(HEXUPPER_PERMISSIVE, spec.encoding().unwrap());  | 
2060  |  | /// ```  | 
2061  |  | ///  | 
2062  |  | /// # Examples  | 
2063  |  | ///  | 
2064  |  | /// ```rust  | 
2065  |  | /// use data_encoding::HEXUPPER_PERMISSIVE;  | 
2066  |  | /// let deadbeef = vec![0xde, 0xad, 0xbe, 0xef];  | 
2067  |  | /// assert_eq!(HEXUPPER_PERMISSIVE.decode(b"DeadBeef").unwrap(), deadbeef);  | 
2068  |  | /// assert_eq!(HEXUPPER_PERMISSIVE.encode(&deadbeef), "DEADBEEF");  | 
2069  |  | /// ```  | 
2070  |  | pub const HEXUPPER_PERMISSIVE: Encoding = Encoding::internal_new(HEXUPPER_PERMISSIVE_IMPL);  | 
2071  |  | const HEXUPPER_PERMISSIVE_IMPL: &[u8] = &[  | 
2072  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2073  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2074  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2075  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2076  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2077  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2078  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2079  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2080  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2081  |  |     56, 57, 65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2082  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 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, 128, 128, 128, 128,  | 
2085  |  |     128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,  | 
2086  |  |     12, 13, 14, 15, 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, 10, 11, 12, 13, 14, 15, 128, 128, 128, 128,  | 
2088  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 128, 128, 128, 128, 128, 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, 28,  | 
2096  |  | ];  | 
2097  |  |  | 
2098  |  | /// Padded base32 encoding  | 
2099  |  | ///  | 
2100  |  | /// This encoding is a static version of:  | 
2101  |  | ///  | 
2102  |  | /// ```rust  | 
2103  |  | /// # use data_encoding::{Specification, BASE32}; | 
2104  |  | /// let mut spec = Specification::new();  | 
2105  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); | 
2106  |  | /// spec.padding = Some('='); | 
2107  |  | /// assert_eq!(BASE32, spec.encoding().unwrap());  | 
2108  |  | /// ```  | 
2109  |  | ///  | 
2110  |  | /// It conforms to [RFC4648].  | 
2111  |  | ///  | 
2112  |  | /// [RFC4648]: https://tools.ietf.org/html/rfc4648#section-6  | 
2113  |  | pub const BASE32: Encoding = Encoding::internal_new(BASE32_IMPL);  | 
2114  |  | const BASE32_IMPL: &[u8] = &[  | 
2115  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2116  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2117  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2118  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2119  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2120  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2121  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2122  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2123  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2124  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2125  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,  | 
2126  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2127  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2128  |  |     128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 130, 128, 128,  | 
2129  |  |     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,  | 
2130  |  |     25, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2135  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2136  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 61, 29,  | 
2139  |  | ];  | 
2140  |  |  | 
2141  |  | /// Unpadded base32 encoding  | 
2142  |  | ///  | 
2143  |  | /// This encoding is a static version of:  | 
2144  |  | ///  | 
2145  |  | /// ```rust  | 
2146  |  | /// # use data_encoding::{Specification, BASE32_NOPAD}; | 
2147  |  | /// let mut spec = Specification::new();  | 
2148  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); | 
2149  |  | /// assert_eq!(BASE32_NOPAD, spec.encoding().unwrap());  | 
2150  |  | /// ```  | 
2151  |  | pub const BASE32_NOPAD: Encoding = Encoding::internal_new(BASE32_NOPAD_IMPL);  | 
2152  |  | const BASE32_NOPAD_IMPL: &[u8] = &[  | 
2153  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2154  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2155  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2156  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2157  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2158  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2159  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2160  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2161  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2162  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2163  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,  | 
2164  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2165  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2166  |  |     128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2167  |  |     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,  | 
2168  |  |     25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2172  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2173  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2174  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 29,  | 
2177  |  | ];  | 
2178  |  |  | 
2179  |  | /// Unpadded base32 encoding with case-insensitive decoding  | 
2180  |  | ///  | 
2181  |  | /// This encoding is a static version of:  | 
2182  |  | ///  | 
2183  |  | /// ```rust  | 
2184  |  | /// # use data_encoding::{Specification, BASE32_NOPAD_NOCASE}; | 
2185  |  | /// let mut spec = Specification::new();  | 
2186  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); | 
2187  |  | /// spec.translate.from.push_str("abcdefghijklmnopqrstuvwxyz"); | 
2188  |  | /// spec.translate.to.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); | 
2189  |  | /// assert_eq!(BASE32_NOPAD_NOCASE, spec.encoding().unwrap());  | 
2190  |  | /// ```  | 
2191  |  | pub const BASE32_NOPAD_NOCASE: Encoding = Encoding::internal_new(BASE32_NOPAD_NOCASE_IMPL);  | 
2192  |  | const BASE32_NOPAD_NOCASE_IMPL: &[u8] = &[  | 
2193  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2194  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2195  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2196  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2197  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2198  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2199  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2200  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
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, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2203  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,  | 
2204  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2205  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2206  |  |     128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2207  |  |     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,  | 
2208  |  |     25, 128, 128, 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,  | 
2209  |  |     18, 19, 20, 21, 22, 23, 24, 25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2210  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2211  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2212  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2216  |  |     128, 128, 128, 128, 128, 128, 128, 128, 29,  | 
2217  |  | ];  | 
2218  |  |  | 
2219  |  | /// Unpadded base32 encoding with visual error correction during decoding  | 
2220  |  | ///  | 
2221  |  | /// This encoding is a static version of:  | 
2222  |  | ///  | 
2223  |  | /// ```rust  | 
2224  |  | /// # use data_encoding::{Specification, BASE32_NOPAD_VISUAL}; | 
2225  |  | /// let mut spec = Specification::new();  | 
2226  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); | 
2227  |  | /// spec.translate.from.push_str("01l8"); | 
2228  |  | /// spec.translate.to.push_str("OIIB"); | 
2229  |  | /// assert_eq!(BASE32_NOPAD_VISUAL, spec.encoding().unwrap());  | 
2230  |  | /// ```  | 
2231  |  | pub const BASE32_NOPAD_VISUAL: Encoding = Encoding::internal_new(BASE32_NOPAD_VISUAL_IMPL);  | 
2232  |  | const BASE32_NOPAD_VISUAL_IMPL: &[u8] = &[  | 
2233  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2234  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2235  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2236  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2237  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2238  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2239  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,  | 
2240  |  |     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,  | 
2241  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2242  |  |     89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,  | 
2243  |  |     81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,  | 
2244  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2245  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2246  |  |     128, 128, 128, 128, 14, 8, 26, 27, 28, 29, 30, 31, 1, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2247  |  |     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, 25,  | 
2248  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 8, 128,  | 
2249  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2250  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2251  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2255  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2256  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,  | 
2257  |  | ];  | 
2258  |  |  | 
2259  |  | /// Padded base32hex encoding  | 
2260  |  | ///  | 
2261  |  | /// This encoding is a static version of:  | 
2262  |  | ///  | 
2263  |  | /// ```rust  | 
2264  |  | /// # use data_encoding::{Specification, BASE32HEX}; | 
2265  |  | /// let mut spec = Specification::new();  | 
2266  |  | /// spec.symbols.push_str("0123456789ABCDEFGHIJKLMNOPQRSTUV"); | 
2267  |  | /// spec.padding = Some('='); | 
2268  |  | /// assert_eq!(BASE32HEX, spec.encoding().unwrap());  | 
2269  |  | /// ```  | 
2270  |  | ///  | 
2271  |  | /// It conforms to [RFC4648].  | 
2272  |  | ///  | 
2273  |  | /// [RFC4648]: https://tools.ietf.org/html/rfc4648#section-7  | 
2274  |  | pub const BASE32HEX: Encoding = Encoding::internal_new(BASE32HEX_IMPL);  | 
2275  |  | const BASE32HEX_IMPL: &[u8] = &[  | 
2276  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,  | 
2277  |  |     79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2278  |  |     71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2279  |  |     56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,  | 
2280  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,  | 
2281  |  |     79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2282  |  |     71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2283  |  |     56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,  | 
2284  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,  | 
2285  |  |     79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2286  |  |     71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 128, 128, 128, 128, 128, 128,  | 
2287  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2288  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2289  |  |     128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 130, 128, 128, 128, 10, 11,  | 
2290  |  |     12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128,  | 
2291  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2292  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2293  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2294  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2295  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2296  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2297  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2298  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2299  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 29,  | 
2300  |  | ];  | 
2301  |  |  | 
2302  |  | /// Unpadded base32hex encoding  | 
2303  |  | ///  | 
2304  |  | /// This encoding is a static version of:  | 
2305  |  | ///  | 
2306  |  | /// ```rust  | 
2307  |  | /// # use data_encoding::{Specification, BASE32HEX_NOPAD}; | 
2308  |  | /// let mut spec = Specification::new();  | 
2309  |  | /// spec.symbols.push_str("0123456789ABCDEFGHIJKLMNOPQRSTUV"); | 
2310  |  | /// assert_eq!(BASE32HEX_NOPAD, spec.encoding().unwrap());  | 
2311  |  | /// ```  | 
2312  |  | pub const BASE32HEX_NOPAD: Encoding = Encoding::internal_new(BASE32HEX_NOPAD_IMPL);  | 
2313  |  | const BASE32HEX_NOPAD_IMPL: &[u8] = &[  | 
2314  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,  | 
2315  |  |     79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2316  |  |     71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2317  |  |     56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,  | 
2318  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,  | 
2319  |  |     79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2320  |  |     71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55,  | 
2321  |  |     56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,  | 
2322  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,  | 
2323  |  |     79, 80, 81, 82, 83, 84, 85, 86, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,  | 
2324  |  |     71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 128, 128, 128, 128, 128, 128,  | 
2325  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2326  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2327  |  |     128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11,  | 
2328  |  |     12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128,  | 
2329  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2330  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2331  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2332  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2333  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2334  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2335  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2336  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2337  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,  | 
2338  |  | ];  | 
2339  |  |  | 
2340  |  | /// DNSSEC base32 encoding  | 
2341  |  | ///  | 
2342  |  | /// This encoding is a static version of:  | 
2343  |  | ///  | 
2344  |  | /// ```rust  | 
2345  |  | /// # use data_encoding::{Specification, BASE32_DNSSEC}; | 
2346  |  | /// let mut spec = Specification::new();  | 
2347  |  | /// spec.symbols.push_str("0123456789abcdefghijklmnopqrstuv"); | 
2348  |  | /// spec.translate.from.push_str("ABCDEFGHIJKLMNOPQRSTUV"); | 
2349  |  | /// spec.translate.to.push_str("abcdefghijklmnopqrstuv"); | 
2350  |  | /// assert_eq!(BASE32_DNSSEC, spec.encoding().unwrap());  | 
2351  |  | /// ```  | 
2352  |  | ///  | 
2353  |  | /// It conforms to [RFC5155]:  | 
2354  |  | ///  | 
2355  |  | /// - It uses a base32 extended hex alphabet.  | 
2356  |  | /// - It is case-insensitive when decoding and uses lowercase when encoding.  | 
2357  |  | /// - It does not use padding.  | 
2358  |  | ///  | 
2359  |  | /// [RFC5155]: https://tools.ietf.org/html/rfc5155  | 
2360  |  | pub const BASE32_DNSSEC: Encoding = Encoding::internal_new(BASE32_DNSSEC_IMPL);  | 
2361  |  | const BASE32_DNSSEC_IMPL: &[u8] = &[  | 
2362  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,  | 
2363  |  |     108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,  | 
2364  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2365  |  |     116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104,  | 
2366  |  |     105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53,  | 
2367  |  |     54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,  | 
2368  |  |     113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101,  | 
2369  |  |     102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49,  | 
2370  |  |     50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,  | 
2371  |  |     110, 111, 112, 113, 114, 115, 116, 117, 118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98,  | 
2372  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2373  |  |     118, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,  | 
2374  |  |     107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 128, 128, 128, 128, 128, 128, 128,  | 
2375  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2376  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2377  |  |     128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 13,  | 
2378  |  |     14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128,  | 
2379  |  |     128, 128, 128, 128, 128, 128, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,  | 
2380  |  |     26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2381  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 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, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2385  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2386  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2387  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,  | 
2388  |  | ];  | 
2389  |  |  | 
2390  |  | #[allow(clippy::doc_markdown)]  | 
2391  |  | /// DNSCurve base32 encoding  | 
2392  |  | ///  | 
2393  |  | /// This encoding is a static version of:  | 
2394  |  | ///  | 
2395  |  | /// ```rust  | 
2396  |  | /// # use data_encoding::{BitOrder, Specification, BASE32_DNSCURVE}; | 
2397  |  | /// let mut spec = Specification::new();  | 
2398  |  | /// spec.symbols.push_str("0123456789bcdfghjklmnpqrstuvwxyz"); | 
2399  |  | /// spec.bit_order = BitOrder::LeastSignificantFirst;  | 
2400  |  | /// spec.translate.from.push_str("BCDFGHJKLMNPQRSTUVWXYZ"); | 
2401  |  | /// spec.translate.to.push_str("bcdfghjklmnpqrstuvwxyz"); | 
2402  |  | /// assert_eq!(BASE32_DNSCURVE, spec.encoding().unwrap());  | 
2403  |  | /// ```  | 
2404  |  | ///  | 
2405  |  | /// It conforms to [DNSCurve].  | 
2406  |  | ///  | 
2407  |  | /// [DNSCurve]: https://dnscurve.org/in-implement.html  | 
2408  |  | pub const BASE32_DNSCURVE: Encoding = Encoding::internal_new(BASE32_DNSCURVE_IMPL);  | 
2409  |  | const BASE32_DNSCURVE_IMPL: &[u8] = &[  | 
2410  |  |     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110,  | 
2411  |  |     112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,  | 
2412  |  |     98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119,  | 
2413  |  |     120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107,  | 
2414  |  |     108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53,  | 
2415  |  |     54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116,  | 
2416  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103,  | 
2417  |  |     104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49,  | 
2418  |  |     50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113,  | 
2419  |  |     114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99,  | 
2420  |  |     100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,  | 
2421  |  |     122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 98, 99, 100, 102, 103, 104, 106, 107, 108, 109,  | 
2422  |  |     110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 128, 128, 128, 128, 128, 128, 128,  | 
2423  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2424  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2425  |  |     128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 128, 128, 128, 128, 128, 128, 128, 10, 11,  | 
2426  |  |     12, 128, 13, 14, 15, 128, 16, 17, 18, 19, 20, 128, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,  | 
2427  |  |     128, 128, 128, 128, 128, 128, 128, 10, 11, 12, 128, 13, 14, 15, 128, 16, 17, 18, 19, 20, 128,  | 
2428  |  |     21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2429  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2430  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2431  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2432  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2433  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2434  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2435  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 21,  | 
2436  |  | ];  | 
2437  |  |  | 
2438  |  | /// Padded base64 encoding  | 
2439  |  | ///  | 
2440  |  | /// This encoding is a static version of:  | 
2441  |  | ///  | 
2442  |  | /// ```rust  | 
2443  |  | /// # use data_encoding::{Specification, BASE64}; | 
2444  |  | /// let mut spec = Specification::new();  | 
2445  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); | 
2446  |  | /// spec.padding = Some('='); | 
2447  |  | /// assert_eq!(BASE64, spec.encoding().unwrap());  | 
2448  |  | /// ```  | 
2449  |  | ///  | 
2450  |  | /// It conforms to [RFC4648].  | 
2451  |  | ///  | 
2452  |  | /// [RFC4648]: https://tools.ietf.org/html/rfc4648#section-4  | 
2453  |  | pub const BASE64: Encoding = Encoding::internal_new(BASE64_IMPL);  | 
2454  |  | const BASE64_IMPL: &[u8] = &[  | 
2455  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2456  |  |     89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,  | 
2457  |  |     115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,  | 
2458  |  |     67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,  | 
2459  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2460  |  |     116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,  | 
2461  |  |     68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,  | 
2462  |  |     98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,  | 
2463  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,  | 
2464  |  |     69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,  | 
2465  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2466  |  |     118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,  | 
2467  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2468  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2469  |  |     128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,  | 
2470  |  |     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,  | 
2471  |  |     24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,  | 
2472  |  |     40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2473  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2474  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2475  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2476  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2477  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2478  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2479  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30,  | 
2480  |  | ];  | 
2481  |  |  | 
2482  |  | /// Unpadded base64 encoding  | 
2483  |  | ///  | 
2484  |  | /// This encoding is a static version of:  | 
2485  |  | ///  | 
2486  |  | /// ```rust  | 
2487  |  | /// # use data_encoding::{Specification, BASE64_NOPAD}; | 
2488  |  | /// let mut spec = Specification::new();  | 
2489  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); | 
2490  |  | /// assert_eq!(BASE64_NOPAD, spec.encoding().unwrap());  | 
2491  |  | /// ```  | 
2492  |  | pub const BASE64_NOPAD: Encoding = Encoding::internal_new(BASE64_NOPAD_IMPL);  | 
2493  |  | const BASE64_NOPAD_IMPL: &[u8] = &[  | 
2494  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2495  |  |     89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,  | 
2496  |  |     115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,  | 
2497  |  |     67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,  | 
2498  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2499  |  |     116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,  | 
2500  |  |     68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,  | 
2501  |  |     98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,  | 
2502  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,  | 
2503  |  |     69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,  | 
2504  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2505  |  |     118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,  | 
2506  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2507  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2508  |  |     128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 128, 128,  | 
2509  |  |     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,  | 
2510  |  |     24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,  | 
2511  |  |     40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2512  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2513  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2514  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2515  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2516  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2517  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2518  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 30,  | 
2519  |  | ];  | 
2520  |  |  | 
2521  |  | /// MIME base64 encoding  | 
2522  |  | ///  | 
2523  |  | /// This encoding is a static version of:  | 
2524  |  | ///  | 
2525  |  | /// ```rust  | 
2526  |  | /// # use data_encoding::{Specification, BASE64_MIME}; | 
2527  |  | /// let mut spec = Specification::new();  | 
2528  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); | 
2529  |  | /// spec.padding = Some('='); | 
2530  |  | /// spec.wrap.width = 76;  | 
2531  |  | /// spec.wrap.separator.push_str("\r\n"); | 
2532  |  | /// assert_eq!(BASE64_MIME, spec.encoding().unwrap());  | 
2533  |  | /// ```  | 
2534  |  | ///  | 
2535  |  | /// It does not exactly conform to [RFC2045] because it does not print the header  | 
2536  |  | /// and does not ignore all characters.  | 
2537  |  | ///  | 
2538  |  | /// [RFC2045]: https://tools.ietf.org/html/rfc2045  | 
2539  |  | pub const BASE64_MIME: Encoding = Encoding::internal_new(BASE64_MIME_IMPL);  | 
2540  |  | const BASE64_MIME_IMPL: &[u8] = &[  | 
2541  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2542  |  |     89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,  | 
2543  |  |     115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,  | 
2544  |  |     67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,  | 
2545  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2546  |  |     116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,  | 
2547  |  |     68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,  | 
2548  |  |     98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,  | 
2549  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,  | 
2550  |  |     69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,  | 
2551  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2552  |  |     118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,  | 
2553  |  |     128, 128, 128, 128, 128, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2554  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2555  |  |     128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,  | 
2556  |  |     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,  | 
2557  |  |     24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,  | 
2558  |  |     40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2559  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2560  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2561  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2562  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2563  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2564  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2565  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30, 76, 13, 10,  | 
2566  |  | ];  | 
2567  |  |  | 
2568  |  | /// MIME base64 encoding without trailing bits check  | 
2569  |  | ///  | 
2570  |  | /// This encoding is a static version of:  | 
2571  |  | ///  | 
2572  |  | /// ```rust  | 
2573  |  | /// # use data_encoding::{Specification, BASE64_MIME_PERMISSIVE}; | 
2574  |  | /// let mut spec = Specification::new();  | 
2575  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); | 
2576  |  | /// spec.padding = Some('='); | 
2577  |  | /// spec.wrap.width = 76;  | 
2578  |  | /// spec.wrap.separator.push_str("\r\n"); | 
2579  |  | /// spec.check_trailing_bits = false;  | 
2580  |  | /// assert_eq!(BASE64_MIME_PERMISSIVE, spec.encoding().unwrap());  | 
2581  |  | /// ```  | 
2582  |  | ///  | 
2583  |  | /// It does not exactly conform to [RFC2045] because it does not print the header  | 
2584  |  | /// and does not ignore all characters.  | 
2585  |  | ///  | 
2586  |  | /// [RFC2045]: https://tools.ietf.org/html/rfc2045  | 
2587  |  | pub const BASE64_MIME_PERMISSIVE: Encoding = Encoding::internal_new(BASE64_MIME_PERMISSIVE_IMPL);  | 
2588  |  | const BASE64_MIME_PERMISSIVE_IMPL: &[u8] = &[  | 
2589  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2590  |  |     89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,  | 
2591  |  |     115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66,  | 
2592  |  |     67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,  | 
2593  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2594  |  |     116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67,  | 
2595  |  |     68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,  | 
2596  |  |     98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,  | 
2597  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 65, 66, 67, 68,  | 
2598  |  |     69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,  | 
2599  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2600  |  |     118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, 128, 128, 128, 128,  | 
2601  |  |     128, 128, 128, 128, 128, 128, 129, 128, 128, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2602  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2603  |  |     128, 62, 128, 128, 128, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,  | 
2604  |  |     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,  | 
2605  |  |     24, 25, 128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,  | 
2606  |  |     40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2607  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2608  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2609  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2610  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2611  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2612  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2613  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 14, 76, 13, 10,  | 
2614  |  | ];  | 
2615  |  |  | 
2616  |  | /// Padded base64url encoding  | 
2617  |  | ///  | 
2618  |  | /// This encoding is a static version of:  | 
2619  |  | ///  | 
2620  |  | /// ```rust  | 
2621  |  | /// # use data_encoding::{Specification, BASE64URL}; | 
2622  |  | /// let mut spec = Specification::new();  | 
2623  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"); | 
2624  |  | /// spec.padding = Some('='); | 
2625  |  | /// assert_eq!(BASE64URL, spec.encoding().unwrap());  | 
2626  |  | /// ```  | 
2627  |  | ///  | 
2628  |  | /// It conforms to [RFC4648].  | 
2629  |  | ///  | 
2630  |  | /// [RFC4648]: https://tools.ietf.org/html/rfc4648#section-5  | 
2631  |  | pub const BASE64URL: Encoding = Encoding::internal_new(BASE64URL_IMPL);  | 
2632  |  | const BASE64URL_IMPL: &[u8] = &[  | 
2633  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2634  |  |     89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,  | 
2635  |  |     115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66,  | 
2636  |  |     67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,  | 
2637  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2638  |  |     116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67,  | 
2639  |  |     68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,  | 
2640  |  |     98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,  | 
2641  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67, 68,  | 
2642  |  |     69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,  | 
2643  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2644  |  |     118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 128, 128, 128, 128,  | 
2645  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2646  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2647  |  |     128, 128, 128, 62, 128, 128, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 130, 128,  | 
2648  |  |     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,  | 
2649  |  |     24, 25, 128, 128, 128, 128, 63, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,  | 
2650  |  |     40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2651  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2652  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2653  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2654  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2655  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2656  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2657  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 61, 30,  | 
2658  |  | ];  | 
2659  |  |  | 
2660  |  | /// Unpadded base64url encoding  | 
2661  |  | ///  | 
2662  |  | /// This encoding is a static version of:  | 
2663  |  | ///  | 
2664  |  | /// ```rust  | 
2665  |  | /// # use data_encoding::{Specification, BASE64URL_NOPAD}; | 
2666  |  | /// let mut spec = Specification::new();  | 
2667  |  | /// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"); | 
2668  |  | /// assert_eq!(BASE64URL_NOPAD, spec.encoding().unwrap());  | 
2669  |  | /// ```  | 
2670  |  | pub const BASE64URL_NOPAD: Encoding = Encoding::internal_new(BASE64URL_NOPAD_IMPL);  | 
2671  |  | const BASE64URL_NOPAD_IMPL: &[u8] = &[  | 
2672  |  |     65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,  | 
2673  |  |     89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,  | 
2674  |  |     115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66,  | 
2675  |  |     67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,  | 
2676  |  |     97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  | 
2677  |  |     116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67,  | 
2678  |  |     68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97,  | 
2679  |  |     98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,  | 
2680  |  |     117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 65, 66, 67, 68,  | 
2681  |  |     69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98,  | 
2682  |  |     99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,  | 
2683  |  |     118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, 128, 128, 128, 128,  | 
2684  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2685  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2686  |  |     128, 128, 128, 62, 128, 128, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 128, 128,  | 
2687  |  |     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,  | 
2688  |  |     24, 25, 128, 128, 128, 128, 63, 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,  | 
2689  |  |     40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2690  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2691  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2692  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2693  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2694  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2695  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,  | 
2696  |  |     128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 30,  | 
2697  |  | ];  |