1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2026 GlobUid Contributors
// SPDX-License-Identifier: Apache-2.0
//! GlobUid - A globally unique ID generator with pluggable algorithms and transport layer.
//!
//! # Features
//!
//! - Multiple ID algorithms: Snowflake, ULID, NanoID
//! - Distributed support with worker IDs (Snowflake)
//! - Pluggable storage backends (memory, file, or custom)
//! - Optional HTTP/gRPC transport layer
//!
//! # Algorithms
//!
//! | Algorithm | Output | Length | Sortable | Use Case |
//! |-----------|--------|--------|----------|----------|
//! | Snowflake | u64 | 64-bit | Time-sortable | Distributed systems |
//! | ULID | String | 26 chars | Lex-sortable | URLs, databases |
//! | NanoID | String | 21 chars | No | URLs, short identifiers |
//!
//! # Quick Start (Library)
//!
//! ```rust,no_run
//! use globuid::{Snowflake, SnowflakeConfig, MemoryStorage, IdGenerator};
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() {
//! // Snowflake (64-bit, distributed)
//! let config = SnowflakeConfig::default();
//! let storage = Arc::new(MemoryStorage::new());
//! let generator = Snowflake::new(config, storage).await.unwrap();
//! let id = generator.generate().await.unwrap();
//! println!("Snowflake ID: {}", id);
//!
//! // ULID (128-bit, lexicographically sortable)
//! let ulid = globuid::Ulid::with_default();
//! let id = ulid.generate().await.unwrap();
//! println!("ULID: {}", id);
//!
//! // NanoID (short URL-friendly)
//! let nanoid = globuid::NanoId::with_default();
//! let id = nanoid.generate().await.unwrap();
//! println!("NanoID: {}", id);
//! }
//! ```
//!
//! # Transport Layers (optional features)
//!
//! - `http`: Enable HTTP REST API server
//! - `grpc`: Enable gRPC server
//! - `full`: Enable all transport layers
// Re-exports for convenience
pub use ;
pub use ;
// Backward compatibility aliases
pub type Generator<S> = ;
pub type GeneratorConfig = SnowflakeConfig;
pub type GeneratorError = SnowflakeError;
pub type DefaultGenerator = ;