uuid_extra/
error.rs

1use derive_more::{Display, From};
2use uuid::Uuid;
3
4pub type Result<T> = core::result::Result<T, Error>;
5
6#[derive(Debug, Display, From)]
7#[display("{self:?}")]
8pub enum Error {
9	#[from(String, &String, &str)]
10	Custom(String),
11
12	FailToDecode16U8 {
13		context: &'static str,
14		actual_length: usize,
15	},
16
17	FailExtractTimeNoUuidV7(Uuid),
18
19	// -- Externals
20	#[from]
21	Io(std::io::Error), // as example
22}
23
24// region:    --- Custom
25
26impl Error {
27	pub fn custom_from_err(err: impl std::error::Error) -> Self {
28		Self::Custom(err.to_string())
29	}
30
31	pub fn custom(val: impl Into<String>) -> Self {
32		Self::Custom(val.into())
33	}
34}
35
36// endregion: --- Custom
37
38// region:    --- Error Boilerplate
39
40impl std::error::Error for Error {}
41
42// endregion: --- Error Boilerplate