Expand description
Timestamp identifiers: the sortable keys this server mints records under.
didbot-pds’s record store mints TIDs, and this module reads one back. A
minter with no matching parser is a format nothing can check, and the
first thing a wrong bit in an rkey costs is the ordering the whole store is
built on.
A TID is a 64-bit integer rendered as thirteen characters of a base32 alphabet ordered so that ASCII order matches numeric order. The layout is one clear top bit, 53 bits of microseconds since the Unix epoch, and a 10-bit clock identifier.
Minter is the other half: the one place a TID is made. Record keys
come from it and so do the revisions a commit is stamped with, and they
come from the same one per store so that neither can repeat the other.
Structs§
- Minter
- Mints TIDs that sort in the order they were minted.
- Tid
- A parsed TID: the timestamp it carries and the clock that minted it.
Enums§
- TidError
- Why a string is not a TID.
Constants§
- BASE32_
SORTABLE - The alphabet a TID is written in: base32 with the digits and letters reordered so that string order matches numeric order.
- TID_
LENGTH - How many characters a TID always is. Not a maximum: a TID is never padded and never abbreviated.
Functions§
- decode_
key 🔒 - Reads back a key
encode_keyproduced, if the string is one. - encode_
key 🔒 - Encodes a 64-bit value as 13 characters of
BASE32_SORTABLE. - micros_
now 🔒 - Microseconds since the Unix epoch, clamped into a TID’s 53 bits.
- parse
- Decodes a TID into the timestamp and clock identifier it carries.
- validate
- Checks a string against the TID rules.