1#![no_std]
18#![warn(missing_docs, missing_debug_implementations)]
19
20#[cfg(feature = "std")]
21extern crate std;
22
23extern crate alloc;
24
25mod checksum;
26mod consts;
27mod decoder;
28mod encoder;
29mod generator;
30mod id;
31
32#[cfg(feature = "serde")]
33mod serde;
34
35#[cfg(feature = "uuid")]
36mod uuid_conv;
37
38pub use checksum::{crc16, iso7064_checksum};
39pub use consts::*;
40pub use decoder::decode_crockford32;
41pub use encoder::encode_crockford32;
42pub use generator::Generator;
43pub use id::SigId26;
44
45pub type Result<T> = core::result::Result<T, Error>;
47
48#[derive(Debug, Clone, Copy, PartialEq, Eq)]
50pub enum Error {
51 InvalidLength,
53 InvalidCharacter,
55 ChecksumMismatch,
57 TimestampOverflow,
59 CounterOverflow,
61}
62
63impl core::fmt::Display for Error {
64 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 match self {
66 Self::InvalidLength => write!(f, "Invalid ID length (must be 26 chars)"),
67 Self::InvalidCharacter => write!(f, "Invalid character in ID"),
68 Self::ChecksumMismatch => write!(f, "Checksum verification failed"),
69 Self::TimestampOverflow => write!(f, "Timestamp overflow (max 2^48)"),
70 Self::CounterOverflow => write!(f, "Counter overflow (max 16383)"),
71 }
72 }
73}