hashed_permutation/
error.rs

1use thiserror::Error;
2
3/// The different types of errors that can arise from this crate
4#[derive(Debug, Error)]
5// We allow the name repetition because this struct will not make sense outside of the crate
6// otherwise, and this is exported as part of the library.
7#[allow(clippy::module_name_repetitions)]
8pub enum PermutationError {
9    /// This error is invoked when the caller attempts to use an index on the `shuffle` method that
10    /// is larger than the size of the set.
11    ///
12    /// The user can only shuffle indices that are within the set, otherwise the hashing algorithm
13    /// does not work. `shuffle` is the index that the user called, and `max_shuffle` is the size
14    /// of the permutation set (which is also the upper bound for the calling index).
15    #[error("Attempted to shuffle index {shuffle}, but the length of the array is {max_shuffle}")]
16    ShuffleOutOfRange { shuffle: u32, max_shuffle: u32 },
17}
18
19/// A permutation result, which is simply an alias for any type that could return a permutation
20/// error.
21pub type PermutationResult<T> = Result<T, PermutationError>;