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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! # `tagid` - Typed Unique Identifiers for Rust Entities
//!
//! `tagid` provides a robust system for defining and managing typed unique identifiers in Rust.
//! It supports multiple ID generation strategies (CUID, UUID, Snowflake) and integrates with
//! `serde`, `sqlx`, and other frameworks for seamless use in databases and serialization.
//!
//! ## Features
//!
//! - **Typed Identifiers**: Define entity-specific IDs with compile-time safety.
//! - **Multiple ID Generators**:
//! - **CUID** (`cuid` feature) - Compact, collision-resistant IDs.
//! - **ULID** (`ulid` feature) - Universally unique identifiers.
//! - **UUID** (`uuid` feature) - Universally unique identifiers.
//! - **Snowflake** (`snowflake` feature) - Time-based, distributed IDs.
//! - **Entity Labeling**: Labels provide contextual meaning to identifiers.
//! - **Serialization & Database Support**:
//! - [`serde`] integration for JSON and binary serialization.
//! - [`sqlx`] integration for database storage (`sqlx` feature).
//! - **Custom Labeling**: Define custom label formats for entities.
//!
//! ## Installation
//!
//! Add `tagid` to your `Cargo.toml`, enabling the desired features:
//!
//! ```toml
//! [dependencies]
//! tagid = { version = "1.0", features = ["uuid", "sqlx"] }
//! ```
//!
//! ## Usage
//!
//! ### Defining an Entity with a Typed ID
//!
//! ```rust,ignore
//! use tagid::{Entity, Id, Label};
//!
//! #[derive(Label)]
//! struct User;
//!
//! impl Entity for User {
//! type IdGen = tagid::UuidGenerator;
//! }
//!
//! let user_id = User::next_id();
//! println!("User ID: {}", user_id);
//! ```
//!
//! ### Labeling System
//!
//! Labels help associate an identifier with an entity, improving clarity in logs and databases:
//!
//! ```rust,ignore
//! use tagid::{Label, Labeling};
//! use tagid::snowflake::pretty::{IdPrettifier, BASE_23};
//! IdPrettifier::global_initialize(BASE_23.clone());
//!
//! #[derive(Label)]
//! struct Order;
//!
//! let order_labeler = Order::labeler();
//! let order_label = order_labeler.label();
//! assert_eq!(order_label, "Order");
//! ```
//!
//! ## Features Overview
//!
//! | Feature | Description |
//! |--------------|---------------------------------------------------------------|
//! | `"derive"` | Enables `#[derive(Label)]` macro for automatic labeling. |
//! | `"cuid"` | Enables the [`CuidGenerator`] for CUID-based IDs. |
//! | `"ulid"` | Enables the [`UlidGenerator`] for ULID-based IDs. |
//! | `"uuid"` | Enables the [`UuidGenerator`] for UUID-based IDs. |
//! | `"snowflake"`| Enables the [`SnowflakeGenerator`] for distributed IDs. |
//! | `"sqlx"` | Enables database integration via [`sqlx`]. |
//! | `"envelope"` | Provides an envelope struct for wrapping IDs with metadata. |
//!
//! ## Contributing
//!
//! Contributions are welcome! Open an issue or submit a pull request on [GitHub](https://github.com/dmrolfs/tagid-rs).
//!
//! ## License
//!
//! This project is licensed under the MIT License.
extern crate tagid_derive;
pub use *;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use UuidGenerator;
pub use ;
// The default delimiter used to separate entity labels from their ID values.
pub const DELIMITER: &str = "::";