pub struct StoreId(/* private fields */);Expand description
Identifies one incarnation of a store’s persistent state.
Not a device, and not a peer. The distinction is the whole clause: a tablet
restored from a backup, or a disk image cloned onto a second machine, will
reissue the same origin positions to different events. If a StoreId
survived that, two genuinely different events would carry one EventId, and
every peer’s deduplication would silently drop real facts — no error, no
conflict, just missing history.
So it is minted when a store’s persistent state is created, and re-minted when that state is restored or cloned. An adapter that cannot detect a restore must offer an out-of-band operation to re-mint, and must say so.
Never derive one from a hostname, a device identifier, a peer name, or anything else that survives a restore.
§Representation
[u8; 16] rather than u128, which is the choice a reader is most likely to
assume was made by default. Three reasons, none about size:
- A
u128has a byte order and an array does not. Every adapter persisting one must chooseto_be_bytesorto_le_bytes, and two adapters choosing differently produce logs that disagree about identity while both pass every in-process rule. Ordon[u8; 16]is lexicographic over exactly the bytes an adapter stores, so it agrees with theBLOB/BYTEAcollation a database already applies.Ordon au128is numeric and agrees only under one endianness.- An integer invites arithmetic — incrementing, ranging, comparing as a magnitude — on a value whose 128 bits are opaque by construction.
Implementations§
Source§impl StoreId
impl StoreId
Sourcepub const fn from_bytes(bytes: [u8; 16]) -> Self
pub const fn from_bytes(bytes: [u8; 16]) -> Self
Wraps sixteen bytes minted by the adapter.
There is deliberately no random constructor here. happenstance-core has
no entropy source, is no_std-capable, and must not acquire a getrandom
dependency to mint a value only an adapter is in a position to persist.
Trait Implementations§
impl Copy for StoreId
Source§impl<'de> Deserialize<'de> for StoreId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for StoreId
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for StoreId
impl Display for StoreId
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Thirty-two lowercase hex characters, with no dashes.
Deliberately not UUID-formatted. A StoreId has no version nibble
and no variant bits, and formatting it with dashes invites an operator —
or a downstream tool — to parse it as a UUID and read structure into it
that is not there.