relaygate_destination/error.rs
1use thiserror::Error;
2
3/// A destination failed canonical validation.
4///
5/// Invalid input is deliberately omitted so it cannot inject log content.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
7pub enum DestinationError {
8 /// The value does not have the exact `namespace/name` form.
9 #[error("destination must be namespace/name")]
10 InvalidDestination,
11 /// The namespace contains a dot and therefore more than one label.
12 #[error("namespace must contain exactly one label")]
13 InvalidNamespace,
14 /// The complete destination name exceeds [`crate::MAX_DESTINATION_NAME_BYTES`].
15 #[error("destination exceeds the byte limit")]
16 DestinationNameLength,
17 /// A label is empty or exceeds [`crate::MAX_LABEL_BYTES`].
18 #[error("labels must contain 1..=63 bytes")]
19 LabelLength,
20 /// A label starts or ends with a character not permitted at its boundary.
21 #[error("labels must start and end with a lowercase ASCII letter or digit")]
22 LabelBoundary,
23 /// A label contains a character outside the canonical lowercase ASCII set.
24 #[error("labels may contain only lowercase ASCII letters, digits and hyphens")]
25 LabelCharacter,
26}