1#![allow(clippy::module_name_repetitions)]
2use std::num::TryFromIntError;
3
4use thiserror::Error;
5
6#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
7pub enum UuidConstructionError {
8 #[error(transparent)]
9 IntegerConversion(#[from] TryFromIntError),
10
11 #[error("The timestamp provided is too low.")]
12 TimestampBeforeEpoch,
13
14 #[error("The timestamp provided is too high.")]
15 TimestampOverflow,
16}
17
18#[derive(thiserror::Error, Debug, Clone, Copy, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
19pub enum DurationToTicksError {
20 #[default]
21 #[error("The timestamp provided is too high.")]
22 TimestampOverflow,
23}
24
25impl From<DurationToTicksError> for UuidConstructionError {
26 fn from(_: DurationToTicksError) -> Self {
27 Self::TimestampOverflow
28 }
29}
30
31#[allow(clippy::enum_variant_names)]
32#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
33pub enum UuidParseError {
34 #[error("invalid length")]
35 InvalidLength,
36
37 #[error("invalid character `{ch}` at index {idx}")]
38 InvalidCharacter { ch: char, idx: usize },
39
40 #[error("hyphens are in the wrong position")]
41 InvalidHyphenPlacement,
42
43 #[error("mismatching or misplaced braces")]
44 InvalidBraces,
45}