pub struct AtomicId<const BITS: usize>;Expand description
The main entry point for generating atomic IDs of a specific bit width.
Use the const generic BITS parameter to select the desired ID size.
For 24 and 32-bit IDs, the short feature must be enabled.
§Examples
use atomic_id::{AtomicId, x64, x128};
// Generate a 64-bit ID
let id64 = AtomicId::<x64>::new();
// Generate a 128-bit ID
let id128 = AtomicId::<x128>::new();Implementations§
Source§impl AtomicId<64>
impl AtomicId<64>
Sourcepub fn new() -> String
pub fn new() -> String
Generate a new 64-bit ID, encoded as a 13-character base36 string.
§Example
use atomic_id::{AtomicId, x64};
let id = AtomicId::<x64>::new();
assert_eq!(id.len(), 13);Sourcepub fn base58() -> String
pub fn base58() -> String
Generate a new 64-bit ID, encoded as an 11-character base58 string.
§Example
use atomic_id::{AtomicId, x64};
let id = AtomicId::<x64>::base58();
assert_eq!(id.len(), 11);Sourcepub fn base91() -> String
pub fn base91() -> String
Generate a new 64-bit ID, encoded as a 10-character base91 string.
§Example
use atomic_id::{AtomicId, x64};
let id = AtomicId::<x64>::base91();
assert_eq!(id.len(), 10);Sourcepub fn base36() -> String
pub fn base36() -> String
Generate a new 64-bit ID, encoded as a 13-character base36 string.
§Example
use atomic_id::{AtomicId, x64};
let id = AtomicId::<x64>::base36();
assert_eq!(id.len(), 13);Sourcepub fn hex() -> String
pub fn hex() -> String
Generate a new 64-bit ID, encoded as a 16-character hexadecimal string.
§Example
use atomic_id::{AtomicId, x64};
let id = AtomicId::<x64>::hex();
assert_eq!(id.len(), 16);Sourcepub fn batch(n: usize) -> Vec<String>
pub fn batch(n: usize) -> Vec<String>
Generate a batch of 64-bit IDs, encoded as base36 strings.
§Example
use atomic_id::{AtomicId, x64};
let ids = AtomicId::<x64>::batch(3);
assert_eq!(ids.len(), 3);Sourcepub fn base58_batch(n: usize) -> Vec<String>
pub fn base58_batch(n: usize) -> Vec<String>
Generate a batch of 64-bit IDs as base58 strings.
Sourcepub fn base91_batch(n: usize) -> Vec<String>
pub fn base91_batch(n: usize) -> Vec<String>
Generate a batch of 64-bit IDs as base91 strings.
Sourcepub fn base36_batch(n: usize) -> Vec<String>
pub fn base36_batch(n: usize) -> Vec<String>
Generate a batch of 64-bit IDs as base36 strings.
Sourcepub fn hex_batch(n: usize) -> Vec<String>
pub fn hex_batch(n: usize) -> Vec<String>
Generate a batch of 64-bit IDs as hexadecimal strings.
Sourcepub fn sequential() -> String
pub fn sequential() -> String
Generate a sequential 64-bit ID as a base36 string.
This method uses a simple atomic counter, making the IDs sequential but not time-sortable. It is useful for scenarios where strict ordering is more important than distributed uniqueness.
§Example
use atomic_id::{AtomicId, x64};
let id1 = AtomicId::<x64>::sequential();
let id2 = AtomicId::<x64>::sequential();
// id2 will be lexicographically greater than id1
assert!(id2 > id1);Sourcepub fn sequential_base58() -> String
pub fn sequential_base58() -> String
Generate a sequential 64-bit ID as a base58 string.
Sourcepub fn sequential_base91() -> String
pub fn sequential_base91() -> String
Generate a sequential 64-bit ID as a base91 string.
Sourcepub fn sequential_base36() -> String
pub fn sequential_base36() -> String
Generate a sequential 64-bit ID as a base36 string.
Sourcepub fn sequential_hex() -> String
pub fn sequential_hex() -> String
Generate a sequential 64-bit ID as a hexadecimal string.
Sourcepub fn sequential_batch(n: usize) -> Vec<String>
pub fn sequential_batch(n: usize) -> Vec<String>
Generate a batch of sequential 64-bit IDs as base36 strings.
Sourcepub fn sequential_base58_batch(n: usize) -> Vec<String>
pub fn sequential_base58_batch(n: usize) -> Vec<String>
Generate a batch of sequential 64-bit IDs as base58 strings.
Sourcepub fn sequential_base91_batch(n: usize) -> Vec<String>
pub fn sequential_base91_batch(n: usize) -> Vec<String>
Generate a batch of sequential 64-bit IDs as base91 strings.
Sourcepub fn sequential_base36_batch(n: usize) -> Vec<String>
pub fn sequential_base36_batch(n: usize) -> Vec<String>
Generate a batch of sequential 64-bit IDs as base36 strings.
Sourcepub fn sequential_hex_batch(n: usize) -> Vec<String>
pub fn sequential_hex_batch(n: usize) -> Vec<String>
Generate a batch of sequential 64-bit IDs as hexadecimal strings.
Source§impl AtomicId<128>
impl AtomicId<128>
Sourcepub fn new() -> String
pub fn new() -> String
Generate a new 128-bit ID, encoded as a 25-character base36 string.
§Example
use atomic_id::{AtomicId, x128};
let id = AtomicId::<x128>::new();
assert_eq!(id.len(), 25);Sourcepub fn base58() -> String
pub fn base58() -> String
Generate a new 128-bit ID, encoded as a 22-character base58 string.
§Example
use atomic_id::{AtomicId, x128};
let id = AtomicId::<x128>::base58();
assert_eq!(id.len(), 22);Sourcepub fn base91() -> String
pub fn base91() -> String
Generate a new 128-bit ID, encoded as a 20-character base91 string.
§Example
use atomic_id::{AtomicId, x128};
let id = AtomicId::<x128>::base91();
assert_eq!(id.len(), 20);Sourcepub fn base36() -> String
pub fn base36() -> String
Generate a new 128-bit ID, encoded as a 25-character base36 string.
§Example
use atomic_id::{AtomicId, x128};
let id = AtomicId::<x128>::base36();
assert_eq!(id.len(), 25);Sourcepub fn hex() -> String
pub fn hex() -> String
Generate a new 128-bit ID, encoded as a 32-character hexadecimal string.
§Example
use atomic_id::{AtomicId, x128};
let id = AtomicId::<x128>::hex();
assert_eq!(id.len(), 32);Sourcepub fn batch(n: usize) -> Vec<String>
pub fn batch(n: usize) -> Vec<String>
Generate a batch of 128-bit IDs, encoded as base36 strings.
§Example
use atomic_id::{AtomicId, x128};
let ids = AtomicId::<x128>::batch(3);
assert_eq!(ids.len(), 3);Sourcepub fn base58_batch(n: usize) -> Vec<String>
pub fn base58_batch(n: usize) -> Vec<String>
Generate a batch of 128-bit IDs as base58 strings.
Sourcepub fn base91_batch(n: usize) -> Vec<String>
pub fn base91_batch(n: usize) -> Vec<String>
Generate a batch of 128-bit IDs as base91 strings.
Sourcepub fn base36_batch(n: usize) -> Vec<String>
pub fn base36_batch(n: usize) -> Vec<String>
Generate a batch of 128-bit IDs as base36 strings.
Source§impl AtomicId<256>
impl AtomicId<256>
Sourcepub fn new() -> String
pub fn new() -> String
Generate a new 256-bit ID, encoded as a 52-character base36 string.
The raw 256-bit ID is composed of four 64-bit parts, each of which is encoded into a 13-character base36 string and then joined.
§Example
use atomic_id::{AtomicId, x256};
let id = AtomicId::<x256>::new();
assert_eq!(id.len(), 52);Sourcepub fn base58() -> String
pub fn base58() -> String
Generate a new 256-bit ID, encoded as a 44-character base58 string.
§Example
use atomic_id::{AtomicId, x256};
let id = AtomicId::<x256>::base58();
assert_eq!(id.len(), 44);Sourcepub fn base91() -> String
pub fn base91() -> String
Generate a new 256-bit ID, encoded as a 40-character base91 string.
§Example
use atomic_id::{AtomicId, x256};
let id = AtomicId::<x256>::base91();
assert_eq!(id.len(), 40);Sourcepub fn base36() -> String
pub fn base36() -> String
Generate a new 256-bit ID, encoded as a 52-character base36 string.
§Example
use atomic_id::{AtomicId, x256};
let id = AtomicId::<x256>::base36();
assert_eq!(id.len(), 52);Sourcepub fn hex() -> String
pub fn hex() -> String
Generate a new 256-bit ID, encoded as a 64-character hexadecimal string.
§Example
use atomic_id::{AtomicId, x256};
let id = AtomicId::<x256>::hex();
assert_eq!(id.len(), 64);Sourcepub fn batch(n: usize) -> Vec<String>
pub fn batch(n: usize) -> Vec<String>
Generate a batch of 256-bit IDs, encoded as base36 strings.
§Example
use atomic_id::{AtomicId, x256};
let ids = AtomicId::<x256>::batch(3);
assert_eq!(ids.len(), 3);Sourcepub fn base58_batch(n: usize) -> Vec<String>
pub fn base58_batch(n: usize) -> Vec<String>
Generate a batch of 256-bit IDs as base58 strings.
Sourcepub fn base91_batch(n: usize) -> Vec<String>
pub fn base91_batch(n: usize) -> Vec<String>
Generate a batch of 256-bit IDs as base91 strings.
Sourcepub fn base36_batch(n: usize) -> Vec<String>
pub fn base36_batch(n: usize) -> Vec<String>
Generate a batch of 256-bit IDs as base36 strings.