aranya_policy_text/
error.rs

1use core::num::NonZeroUsize;
2
3/// Not a valid `Text` value.
4#[derive(Clone, Debug, thiserror::Error)]
5#[error(transparent)]
6pub struct InvalidText(pub(crate) InvalidTextRepr);
7
8#[derive(Clone, Debug, thiserror::Error)]
9pub(crate) enum InvalidTextRepr {
10    /// Text contained nul byte.
11    #[error("text contained nul byte at index {index}")]
12    ContainsNul {
13        /// Index of first nul byte.
14        index: usize,
15    },
16}
17
18/// Not a valid `Identifier` value.
19#[derive(Clone, Debug, thiserror::Error)]
20#[error(transparent)]
21pub struct InvalidIdentifier(pub(crate) InvalidIdentifierRepr);
22
23#[derive(Clone, Debug, thiserror::Error)]
24pub(crate) enum InvalidIdentifierRepr {
25    /// Identifier must start with alphabetic character.
26    #[error("identifier must not be empty")]
27    NotEmpty,
28    /// Identifier must start with alphabetic character.
29    #[error("identifier must start with alphabetic character")]
30    InitialNotAlphabetic,
31    /// Identifier contained invalid character.
32    #[error("identifier contained invalid character at index {index}")]
33    TrailingNotValid {
34        /// Index of first invalid character.
35        index: NonZeroUsize,
36    },
37}