#[repr(transparent)]pub struct Snid(pub [u8; 16]);Tuple Fields§
§0: [u8; 16]Implementations§
Source§impl Snid
impl Snid
Sourcepub fn new() -> Self
pub fn new() -> Self
Generates a new SNID with ~3.7ns latency. This is the universal paradigm for fast ID generation.
Sourcepub fn try_new() -> Result<Self, Error>
pub fn try_new() -> Result<Self, Error>
Attempts to generate a new SNID without panicking on OS RNG failure.
Sourcepub fn new_fast() -> Self
pub fn new_fast() -> Self
Generates a new SNID with lock-free per-P state. Deprecated: Use new() instead.
Sourcepub fn new_with(opts: Options) -> Self
pub fn new_with(opts: Options) -> Self
Generates a configured ID using options. This is the universal paradigm for configured ID generation.
Sourcepub fn new_spatial(_lat: f64, _lng: f64) -> Self
pub fn new_spatial(_lat: f64, _lng: f64) -> Self
Generates a spatial ID from lat/lng coordinates. This is the universal paradigm for spatial ID generation.
Sourcepub fn batch(count: usize) -> Vec<Self>
pub fn batch(count: usize) -> Vec<Self>
Generates a batch of IDs efficiently. This is the universal paradigm for batch generation.
Sourcepub fn try_batch(count: usize) -> Result<Vec<Self>, Error>
pub fn try_batch(count: usize) -> Result<Vec<Self>, Error>
Attempts to generate a batch of IDs without panicking on OS RNG failure.
Sourcepub fn fill_slice(out: &mut [Self])
pub fn fill_slice(out: &mut [Self])
Fills an existing ID slice in place.
This is the lowest-allocation generation API for callers that own their buffers, such as network send paths, database ingest loops, and arenas.
Sourcepub fn fill_bytes(out: &mut [u8]) -> usize
pub fn fill_bytes(out: &mut [u8]) -> usize
Fills a byte buffer with raw SNID bytes and returns the number of IDs written.
Only complete 16-byte slots are written; trailing bytes are ignored.
Sourcepub fn append_binary_batch(count: usize, out: &mut Vec<u8>)
pub fn append_binary_batch(count: usize, out: &mut Vec<u8>)
Appends count raw 16-byte SNIDs to an existing byte buffer.
pub fn from_bytes(bytes: [u8; 16]) -> Self
pub fn to_bytes(self) -> [u8; 16]
Sourcepub fn write_uuid_string(&self, out: &mut [u8; 36])
pub fn write_uuid_string(&self, out: &mut [u8; 36])
Writes the standard hyphenated UUID text form into out.
Sourcepub fn to_uuid_string(&self) -> String
pub fn to_uuid_string(&self) -> String
Returns the standard hyphenated UUID text form.
Sourcepub fn from_uuid_string(value: &str) -> Result<Self, Error>
pub fn from_uuid_string(value: &str) -> Result<Self, Error>
Parses a standard hyphenated UUID string into a SNID.
Only UUIDv7 values are accepted.
pub fn from_hex(hex_value: &str) -> Result<Self, Error>
pub fn canonical_atom(atom: &str) -> Option<&'static str>
pub fn to_wire(self, atom: &str) -> Result<String, Error>
Sourcepub fn write_wire<'a>(
self,
atom: &str,
out: &'a mut [u8; 28],
) -> Result<&'a str, Error>
pub fn write_wire<'a>( self, atom: &str, out: &'a mut [u8; 28], ) -> Result<&'a str, Error>
Writes a wire-format ID (ATOM:payload) into a stack-provided buffer.
The output buffer must be at least 28 bytes for canonical three-byte atoms.
Sourcepub fn append_wire(self, atom: &str, out: &mut Vec<u8>) -> Result<(), Error>
pub fn append_wire(self, atom: &str, out: &mut Vec<u8>) -> Result<(), Error>
Appends wire-format bytes into an existing buffer without allocating.
Sourcepub fn to_wire_default(self) -> String
pub fn to_wire_default(self) -> String
Formats an ID using the default wire format with “MAT:” atom. This is the universal paradigm for serialization (default atom). Note: Use the Display trait instead via format!(“{}”, id)
Sourcepub fn with_atom(self, atom: &str) -> String
pub fn with_atom(self, atom: &str) -> String
Formats an ID with a custom atom. This is the universal paradigm for serialization (override atom).
Sourcepub fn to_base32(self) -> String
pub fn to_base32(self) -> String
Formats an ID using Crockford Base32 encoding. This is case-insensitive and excludes ambiguous characters (I, L, O).
Sourcepub fn write_base32(self, out: &mut [u8; 27]) -> &str
pub fn write_base32(self, out: &mut [u8; 27]) -> &str
Writes Crockford Base32 text into out and returns the written slice.
pub fn append_base32(self, out: &mut Vec<u8>)
Sourcepub fn new_safe() -> Self
pub fn new_safe() -> Self
Generates a public-safe ID with time-blurring and pure CSPRNG entropy. This is the “One ID” solution for database PK + public API use. Time-blurring: Truncates timestamp to nearest second (instead of millisecond) Pure CSPRNG: Fills 74 bits with cryptographic randomness (no monotonic counter) Performance: ~40-50ns (vs 5ns for new())
Sourcepub fn try_new_safe() -> Result<Self, Error>
pub fn try_new_safe() -> Result<Self, Error>
Attempts to generate a public-safe ID without panicking on OS RNG failure.
pub fn parse_wire(value: &str) -> Result<(Self, String), Error>
Sourcepub fn parse(value: &str) -> Result<Self, Error>
pub fn parse(value: &str) -> Result<Self, Error>
Parses a wire string and returns the ID. This is the universal paradigm for parsing wire strings.
Sourcepub fn parse_uuid(value: &str) -> Result<Self, Error>
pub fn parse_uuid(value: &str) -> Result<Self, Error>
Parses a UUID string and returns the ID. This is the universal paradigm for parsing UUID strings.