pub enum SnowflakeError {
InvalidBitLayout {
t: u8,
m: u8,
n: u8,
s: u8,
total: u8,
},
MachineIdOutOfRange {
given: i64,
max: i64,
},
NodeIdOutOfRange {
given: i64,
max: i64,
},
AlreadyInitialized,
NodeIdExhausted {
max: i64,
},
ClockMovedBackwards,
ClockBeforeEpoch,
}Expand description
All errors that the snowflake crate can produce.
Variants§
InvalidBitLayout
The bit widths of all four fields do not sum to 63.
An i64 has one sign bit, so the remaining 63 bits must be fully
allocated to avoid negative IDs or wasted space.
MachineIdOutOfRange
A machine_id was provided that exceeds the layout’s maximum.
NodeIdOutOfRange
A node_id was provided that exceeds the layout’s maximum.
AlreadyInitialized
The global generator has already been initialized.
init / init_with_epoch can
only be called once per process. Re-initialization is rejected because
existing thread-local generators would keep using the old configuration,
leading to inconsistent ID layouts. To change the configuration, restart
the process so that all thread-local state is cleared.
NodeIdExhausted
More threads have called next_id than the layout’s
node_id_bits can accommodate.
With the default 5 node_id_bits, at most 32 threads (node IDs 0..=31)
can generate IDs. If your application needs more threads, increase
node_id_bits (and reduce machine_id_bits or timestamp_bits to
compensate) when calling init.
ClockMovedBackwards
The system clock moved backwards, which would break ID monotonicity.
ClockBeforeEpoch
The system clock is not available (e.g. time before epoch).
Trait Implementations§
Source§impl Clone for SnowflakeError
impl Clone for SnowflakeError
Source§fn clone(&self) -> SnowflakeError
fn clone(&self) -> SnowflakeError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SnowflakeError
impl Debug for SnowflakeError
Source§impl Display for SnowflakeError
impl Display for SnowflakeError
Source§impl Error for SnowflakeError
impl Error for SnowflakeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()