Skip to main content

Crate sigid_core

Crate sigid_core 

Source
Expand description

§SigID Core

Zero-dependency, no_std core for generating 26-character identifiers in Crockford Base32 format.

§Example

use sigid_core::{Generator, SigId26};

let mut gen = Generator::new(0x123456789abcdef);
let id = gen.generate(1234567890).unwrap();
println!("{}", id);

Structs§

Generator
ID generator as a pure state machine
SigId26
26-character identifier in Crockford Base32 format

Enums§

Error
Error types

Constants§

ALPHABET
Crockford Base32 alphabet
ALPHABET_LOWER
Crockford Base32 alphabet (lowercase)
COUNTER_BITS
Counter bits (14 bits)
COUNTER_MAX
Maximum counter value (2^14 - 1) = 16383
EPOCH
Epoch: 2020-01-01 00:00:00 UTC (milliseconds)
ID_BYTES
ID length in bytes (128 bits)
ID_LENGTH
ID length in characters
RANDOM_BITS
Random bits (50 bits)
RANDOM_MAX
Maximum random value (2^50 - 1)
TIMESTAMP_BITS
Timestamp bits (48 bits)
TIMESTAMP_MAX
Maximum timestamp value (2^48 - 1)
WORKER_BITS
Worker ID bits (16 bits)
WORKER_MAX
Maximum worker ID value (2^16 - 1)

Functions§

crc16
Calculate CRC-16 for data
decode_crockford32
Decode 26 Crockford Base32 characters to 16 bytes
encode_crockford32
Encode 16 bytes to 26 Crockford Base32 characters
iso7064_checksum
Calculate ISO 7064 Mod 37,36 checksum (like ISBN)

Type Aliases§

Result
Result type for no_std compatibility