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
//! A type-safe, tagged identifier library.
//!
//!
//! The crate primarily provides the [`Id`] struct, which stores a 128-bit
//! identifier with its corresponding type (tag). The type can be anything that
//! implements [`Type`].
//!
//! The String representation of an [`Id`] is the type's tag and the
//! 128-bit value encoded into a variant of
//! [Crockford Base 32](https://www.crockford.com/base32.html).
//!
//! Here is a simple example of how this crate can be used.
//!
//! ```
//! use souvenir::{Type, Id};
//!
//! struct User;
//!
//! impl Type for User {
//! // Specify a prefix for all `Id<User>`
//! const PREFIX: &'static str = "user";
//! }
//!
//! let id: Id<User> = Id::random();
//! println!("{}", id);
//!
//! let id2: Id<User> = Id::parse("user_02v58c5a3fy30k560qrtg4rb2k").unwrap();
//! assert_eq!(id2.to_string(), "user_02v58c5a3fy30k560qrtg4rb2k");
//! ```
//!
//! If a type-agnostic identifier needs to be stored, the [`Generic`]
//! struct is available. This can be useful when the type of an identifier is
//! not known at compile time or can have multiple values. Instances of
//! [`Generic`] can be safely casted to an instance of [`Id<T>`]
//! or can be passed around directly.
//!
//! Integrations for various libraries and databases are also (optionally)
//! available:
//! - (De)serialization with [`serde`](https://docs.rs/serde/latest/serde/)
//! - Random ID generation with [`rand`](https://docs.rs/rand/latest/rand/)
//! - Postgres, MySQL, and Sqlite support with
//! [`sqlx`](https://docs.rs/sqlx/latest/sqlx/) and
//! [`diesel`](https://docs.rs/diesel/latest/diesel/)
pub use *;
pub use *;
pub use *;
pub use *;