All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
no_std + alloc compilation, including Serde, and validate it on a bare-metal target with native 64-bit atomics.rust-version requirement; keep development tests and benchmarks on current toolchains.Snowflake::next_ids_into(count, &mut Vec<SnowflakeId>) to reuse caller capacity. Successfully appended IDs remain valid on partial failure; all chunks share the same wait budget.Builder::clock_source callbacks shared by clones and optional std Builder::wait_timeout budgets across a generation call.tracing and metrics features now explicitly enable std. For embedded builds use the core or Serde feature set; applications combining these observability features with set_time_source should migrate to Builder::clock_source.Error enum adds InvalidClockDrift, BeforeEpoch, and (with std) WaitTimeout; downstream exhaustive matches must handle these variants. Existing valid ID layouts and encoding alphabets remain unchanged.files: lcov.info, restoring coverage uploads after the action input schema change.2.1.1 patch release.git-cliff tag matching so changelog automation recognizes both v* and numeric release tags used in this repository.Snowflake::next_ids(count), reserving contiguous sequence ranges per CAS operation while preserving cross-millisecond behavior.SnowflakeId::from_base32, SnowflakeId::from_base58, and SnowflakeId::from_base64 decoding helpers.Snowflake::compose as the inverse of decompose, with component range validation.Default for Snowflake and DecomposedSnowflake::absolute_millis(start_time).2.1.0 release.jiff dependency from 0.2.28 to 0.2.31.Cargo.lock to match the current dependency graph.actions/checkout and actions/cache.Cargo.toml.snowflake_me = "2.0.1".chrono to jiff (jiff 0.2.28).
current_millis() (std path) now uses jiff::Timestamp::now().as_millisecond() instead of chrono’s nanosecond division.std feature now enables dep:jiff + jiff/std (previously chrono).jiff 0.2.28 targets Rust 1.70, still within this crate’s 1.75 MSRV.jiff is now an internal dependency only — no datetime type appears in the public API.to_snowflake_time() helper removed (the start time is now stored as raw milliseconds).MICROS_PER_MILLI constant removed; replaced by the correctly-named NANOS_PER_MILLI (used only by DecomposedSnowflake::nanos_time()).Builder::start_time is unified to start_time(i64) — milliseconds since the Unix epoch — for both std and no_std. Previously the std build accepted a chrono::DateTime<chrono::Utc>. Pass a raw millisecond timestamp instead (e.g. 1_640_995_200_000 for 2022-01-01 UTC).Error::StartTimeAheadOfCurrentTime payload changed from chrono::DateTime<Utc> to i64 (the offending start time in milliseconds).Replace any start_time call that passed a chrono::DateTime<chrono::Utc> with its millisecond value:
// Before (v1.x, std)
// .start_time(chrono::Utc::now())
// After (v2.0)
.start_time(/* millis since epoch, e.g. from your clock or a fixed epoch */)
See docs/chrono-to-jiff-migration.md for the full feasibility analysis and rationale.
missing_docs lint: all public items now have documentation.no_std usage guide.tests/proptest.rs): monotonicity, decompose roundtrip, uniqueness under contention.fuzz/): targets for fuzz_decompose, fuzz_parse_id, fuzz_encodings.tests/loom_test.rs): concurrent next_id and next_ids verification.examples/): basic.rs, builder.rs, concurrent.rs, decompose.rs, serde_example.rs.wasm32-unknown-unknown).-D warnings.cargo-llvm-cov.SharedSnowflake visibility changed from pub to pub(crate).#[must_use] to Snowflake::builder(), Snowflake::decompose(), DecomposedSnowflake::decompose().no_std usage guide, batch generation example, migration guide from v0.6.x, complete feature flags table (std, use-strong-cas).benches/bench.rs): 7 Criterion benchmarks covering single-thread ID generation, concurrent generation, builder finalization, decompose, encoding methods, and CAS strategy comparison.use-strong-cas feature flag: switches CAS from compare_exchange_weak to compare_exchange for environments where spurious CAS failures are undesirable.next_ids(count) batch API: generates multiple unique IDs in a single call, amortizing overhead.no_std support: the crate now works in no_std + alloc environments.
std feature (default-enabled) gates chrono and thiserror/std.src/time.rs: current_millis() uses chrono for std, AtomicI64 for no_std.set_time_source(millis) public API for no_std environments to provide the current time.core:: and alloc:: for no_std compatibility.SharedSnowflake is now #[repr(align(64))] with hot/cold field ordering to prevent false sharing between threads.chrono is now an optional dependency gated behind the std feature.thiserror and base64 use default-features = false for no_std compatibility.Builder fields reordered: hot-path fields grouped separately from cold configuration.ClockDriftStrategy enum with three strategies:
Wait (default) — busy-wait until clock catches up, with optional max_clock_drift_ms limit.Error — return Error::ClockDrift immediately on backward drift.LastTimestamp — reuse last known timestamp, IDs remain unique but timestamps become approximate.clock_drift_strategy() and max_clock_drift_ms() for configuring drift behavior.Error::ClockDrift { last_time, current_time } and Error::ClockDriftExceeded { drift_ms, max_ms }.tracing feature): structured logging at key points — ID generation, clock drift, sequence exhaustion, time overflow, generator initialization.metrics feature): counters and gauges — snowflake_ids_generated_total, snowflake_clock_drift_events_total, snowflake_sequence_exhaustion_total, snowflake_sequence_utilization.full feature flag: enables all optional features (serde, tracing, metrics, ip-fallback) at once.tests/tracing_test.rs) and metrics (tests/metrics_test.rs).SharedSnowflake now includes clock_drift_strategy and max_clock_drift_ms fields.SnowflakeId newtype: Introduced SnowflakeId(u64) wrapper with rich encoding methods (hex, base2, base32, base36, base58, base64).Display, From<u64>, Into<u64>, AsRef<u64>, Deref<Target=u64>, Ord, PartialOrd, FromStr, Hash, Eq.FromStr hex parsing: Supports 0x/0X prefix for hexadecimal input.TryFrom implementations: TryFrom<String>, TryFrom<&str>, TryFrom<i64>.serde feature flag for SnowflakeId (u64 format), SnowflakeIdString (string format), and DecomposedSnowflake.SnowflakeIdString: Wrapper type that serializes SnowflakeId as a decimal string (for JavaScript-safe JSON).DecomposedSnowflake::to_id() method and From<&DecomposedSnowflake> for SnowflakeId.Snowflake::next_id() now returns Result<SnowflakeId, Error> instead of Result<u64, Error>.Snowflake::decompose() now accepts SnowflakeId instead of u64.DecomposedSnowflake::id field type changed from u64 to SnowflakeId.DecomposedSnowflake now delegate to SnowflakeId.Error::ParseIdFailed(String) added for ID parsing failures.base36() method which was incorrectly returning lowercase hex instead of actual base36 encoding.SNOWFLAKE_TIME_UNIT comment (was labeled “Nanosecond”, now correctly documented as microseconds-per-millisecond).Builder.benches/bench.rs.ip-fallback feature.Error::MutexPoisoned variant (leftover from old Mutex-based design).Error::NoPrivateIPv4 to Error::NoPrivateIP since the code also attempts IPv6 fallback.#[must_use] to all Builder and DecomposedSnowflake methods.Display trait implementation for DecomposedSnowflake.hex() method to DecomposedSnowflake for lowercase hex encoding.elapsed_millis() method to replace ambiguous time() method.Default for Builder<'_>.std::hint::spin_loop() in til_next_millis for better CPU behavior during busy-wait.machine_id/data_center_id instead of relying on ip-fallback.Cargo.toml to 0.5.0.README.md and README_CN.md to reflect the new version 0.5.0.snowflake_me to snowflake-me.README.md and README_CN.md to use the new crate name snowflake-me.README.md and README_CN.md to point to snowflake-me.snowflake-me to snowflake_meBuilder now supports setting custom bit lengths for time, sequence,
data_center_id, and machine_id. This allows tailoring the ID structure to specific application requirements.Error::InvalidBitLength to handle incorrect bit length configurations.Error::DataCenterIdFailed for more specific error reporting on builder finalization.decompose() function has been removed. ID parsing is now performed by the associated
function DecomposedSnowflake::decompose(), which requires the bit length configuration used to generate the ID.base58, base64, string) are now methods on the
DecomposedSnowflake struct, rather than being part of a separate module.msb field was removed from DecomposedSnowflake as it was redundant (always 0).SNOWFLAKE_TIME_UNIT) is now consistently 1 millisecond.ip-fallback feature including pnet_datalink dependency.machine_id and data_center_id when the ip-fallback feature is disabled.
Builder’s finalize method now returns an error if machine_id or
data_center_id are not provided and the ip-fallback feature is not enabled.Cargo.toml to 0.3.0.feature/**.
data_center_id field to SharedSnowflake and Builder.data_center_id to DecomposedSnowflake.next_id method to use new machine_id and data_center_id.decompose function to handle new data_center_id.This is the initial version.