Crates.io | oysterpack_uid |
lib.rs | oysterpack_uid |
version | 0.2.0 |
source | src |
created_at | 2018-10-18 21:04:47.745487 |
updated_at | 2018-11-04 19:42:32.121979 |
description | OysterPack UID is used to generate unique identifiers |
homepage | https://github.com/oysterpack/oysterpack/tree/master/oysterpack-uid |
repository | https://github.com/oysterpack/oysterpack |
max_upload_size | |
id | 91406 |
size | 46,217 |
Provides support for universally unique identifiers that confirm to the ULID spec.
You can generate ULIDs as String or u128. You can convert ULIDs between String and u128.
use oysterpack_uid::{
ulid,
ulid_u128,
ulid_u128_into_string,
ulid_str_into_u128
};
// generates a new ULID as a string
let id_str = ulid();
// generates a new ULID as u128
let id_u128 = ulid_u128();
// conversions between string and u128 ULIDs
let ulid_str = ulid_u128_into_string(id_u128);
assert_eq!(ulid_str_into_u128(&ulid_str).unwrap(), id_u128);
You can define type safe ULID based unique identifiers (Uid):
use oysterpack_uid::Uid;
struct User;
type UserId = Uid<User>;
let id = UserId::new();
use oysterpack_uid::Uid;
trait Foo{}
TypedULID
TypedULID
type FooId = Uid<dyn Foo + Send + Sync>;
let id = FooId::new();
By default, Uiddefault-features = false
.