Expand description
Compact message storage with binary IDs and interned strings.
Part of vector-core — the single source of truth for compact message types.
This module provides memory-efficient message storage:
[u8; 32]for IDs instead of hex strings (saves ~56 bytes per ID)- Interned npubs via
NpubInterner(each unique npub stored once) - Bitflags for boolean states (1 byte instead of 4+)
- Binary search for O(log n) message lookup
- Boxed optional fields (replied_to, wrapper_id) to save inline space
- Compact timestamp (u32 seconds since 2020 epoch)
Structs§
- Attachment
Flags - Packed flags for attachment state (1 byte instead of multiple bools)
- Compact
Attachment - Memory-efficient attachment with binary hashes and compact strings.
- Compact
Message - Memory-efficient message with binary IDs and interned npubs.
- Compact
Message Vec - Sorted message storage with O(log n) lookup by ID.
- Compact
Reaction - Memory-efficient reaction with binary IDs and interned author.
- Message
Flags - Bitflags for message state (1 byte instead of 4+ bytes for separate bools)
- Npub
Interner - String interner for npubs using sorted Vec + binary search.
- TinyVec
- Ultra-compact vector using a thin pointer (8 bytes on stack).
Constants§
- NO_NPUB
- Sentinel value for “no npub” (avoids Option overhead)
Functions§
- decode_
message_ id - Decode 32 bytes back to an ID string, handling pending IDs specially.
- encode_
message_ id - Encode an ID string to 32 bytes, handling pending IDs specially.
- secs_
from_ compact - Convert compact u32 back to Unix seconds timestamp. Preserves 0 as sentinel for “never set”.
- secs_
to_ compact - Convert Unix seconds timestamp to compact u32 (seconds since 2020). Preserves 0 as sentinel for “never set”.
- timestamp_
from_ compact - Convert compact timestamp back to milliseconds.
- timestamp_
to_ compact - Convert milliseconds timestamp to compact storage. Stores full u64 milliseconds — no precision loss.