Crates.io | oats-rs |
lib.rs | oats-rs |
version | 0.2.1 |
source | src |
created_at | 2024-02-26 06:22:21.852627 |
updated_at | 2024-03-20 11:35:22.342424 |
description | Short, unique ids without the hassle of random uuids. |
homepage | |
repository | https://github.com/Skailys/oats-rs.git |
max_upload_size | |
id | 1153067 |
size | 32,506 |
Short, unique ids without the hassle of random uuids.
cargo add oats-rs
use oats::bowl::{GenerationBehavior, WrappedBowl};
use std::time::SystemTime;
let wrapped_bowl = WrappedBowl::of(1, GenerationBehavior::Normal, Some(SystemTime::now()));
let oat = wrapped_bowl.generate();
assert_eq!(oat.node(), 1);
When using ToString, the Oat object is displayed in a mixed format that includes the node ID and a local unique identifier (LUID) with a timestamp and sequence ID. The LUID is encoded as a URL-safe base64 string without padding.
const ENGINE: FastPortable = FastPortable::from(&URL_SAFE, NO_PAD);
format!("{:X>2X}{}", &self.node, encode_engine(&self luid.to_le_bytes(), &ENGINE))