mailio_id (mailio v0.2.0)

Identifier generation.

Two families of ids:

  • Allocated ids (account, mailbox, thread, identity, ...) are ULIDs: lexicographically sortable, 128-bit, time-ordered.
  • Content-addressed ids (email, blob, msgid lookup) are derived from a SHA-256 of the content so the same bytes always map to the same id, making ingestion idempotent.

Summary

Functions

Lowercase base32 (Crockford) of an arbitrary binary, no padding.

Lowercase hex SHA-256, used as the blob/<hex> doc id segment.

Public blob id: sha256-<hex> of the content.

Email id: lowercase base32 of SHA-256(raw message), truncated to 26 chars (130 bits). Same raw bytes -> same email id.

Hash of a Message-ID header value for the msgid/<hash> lookup doc.

Generate a ULID: 48-bit millisecond timestamp + 80 bits of randomness, Crockford base32, 26 chars, sortable by creation time.

Functions

account_id()

-spec account_id() -> binary().

b32_lower(Bin)

-spec b32_lower(binary()) -> binary().

Lowercase base32 (Crockford) of an arbitrary binary, no padding.

blob_hex(Content)

-spec blob_hex(binary()) -> binary().

Lowercase hex SHA-256, used as the blob/<hex> doc id segment.

blob_id(Content)

-spec blob_id(binary()) -> binary().

Public blob id: sha256-<hex> of the content.

email_id(Raw)

-spec email_id(binary()) -> binary().

Email id: lowercase base32 of SHA-256(raw message), truncated to 26 chars (130 bits). Same raw bytes -> same email id.

grant_id()

-spec grant_id() -> binary().

identity_id()

-spec identity_id() -> binary().

job_id()

-spec job_id() -> binary().

mailbox_id()

-spec mailbox_id() -> binary().

msgid_hash(MessageId)

-spec msgid_hash(binary()) -> binary().

Hash of a Message-ID header value for the msgid/<hash> lookup doc.

rule_id()

-spec rule_id() -> binary().

submission_id()

-spec submission_id() -> binary().

thread_id()

-spec thread_id() -> binary().

ulid()

-spec ulid() -> binary().

Generate a ULID: 48-bit millisecond timestamp + 80 bits of randomness, Crockford base32, 26 chars, sortable by creation time.