#identifier #id #tagged #type-safe #128-bit #mysql #postgresql

souvenir-core

Core implementation for souvenir. Not intended to be used directly.

5 releases

Uses new Rust 2024

0.5.5 Sep 6, 2025
0.5.4 Sep 6, 2025
0.5.3 Aug 25, 2025
0.5.2 Aug 25, 2025
0.5.1 Aug 23, 2025

#12 in #128-bit

Download history 308/week @ 2025-08-21 50/week @ 2025-08-28 246/week @ 2025-09-04 27/week @ 2025-09-11 17/week @ 2025-09-18 30/week @ 2025-09-25 15/week @ 2025-10-02 6/week @ 2025-10-09 16/week @ 2025-10-16 7/week @ 2025-10-23

54 downloads per month
Used in 2 crates

MIT license

32KB
853 lines

souvenir_core

This crate contains implementation details for souvenir. This crate is not intended to be used directly.


souvenir

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 String representation of an Id is the type's tag and the 128-bit value encoded into a variant of Crockford Base 32.

Here is a simple example of how this crate can be used.

use souvenir::Id;

let id: Id = Id::random("user".parse().unwrap());
println!("{}", id);

let id2: Id = Id::parse("user_02v58c5a3fy30k560qrtg4").unwrap();
assert_eq!(id2.to_string(), "user_02v58c5a3fy30k560qrtg4");

Integrations for various libraries and databases are also (optionally) available:

  • (De)serialization with serde
  • Random ID generation with rand
  • Postgres, MySQL, and Sqlite support with sqlx and diesel

Dependencies

~0–21MB
~258K SLoC