| 1 | // Copyright 2024 Brian Smith. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | |
| 15 | pub struct InputTooLongError<T = usize> { |
| 16 | /// Note that this might not actually be the (exact) length of the input, |
| 17 | /// and its units might be lost. For example, it could be any of the |
| 18 | /// following: |
| 19 | /// |
| 20 | /// * The length in bytes of the entire input. |
| 21 | /// * The length in bytes of some *part* of the input. |
| 22 | /// * A bit length. |
| 23 | /// * A length in terms of "blocks" or other grouping of input values. |
| 24 | /// * Some intermediate quantity that was used when checking the input |
| 25 | /// length. |
| 26 | /// * Some arbitrary value. |
| 27 | #[allow (dead_code)] |
| 28 | imprecise_input_length: T, |
| 29 | } |
| 30 | |
| 31 | impl<T> InputTooLongError<T> { |
| 32 | #[cold ] |
| 33 | #[inline (never)] |
| 34 | pub(crate) fn new(imprecise_input_length: T) -> Self { |
| 35 | Self { |
| 36 | imprecise_input_length, |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |