bones_utils/
ulid.rs

1use crate::prelude::*;
2
3pub use ulid::Ulid;
4
5/// Extension trait for [`Ulid`].
6pub trait UlidExt {
7    /// Constructor that) is the same as [`Ulid::new()`], but that works on WASM, too using the
8    /// [`instant`] crate.
9    fn create() -> Self;
10}
11
12impl UlidExt for Ulid {
13    fn create() -> Self {
14        Ulid::from_parts(
15            instant::now().floor() as u64,
16            THREAD_RNG.with(|rng| rng.gen_u128()),
17        )
18    }
19}