Skip to main content

Module event_id

Module event_id 

Source
Expand description

Binary codec and fast hashing for event IDs.

Since room v3 an event ID is the event’s sha256 reference hash: $ followed by 43 characters of unpadded base64 (standard alphabet in v3, URL-safe in v4+), so the 32 hash bytes and the ID convert losslessly in both directions.

TODO: Move this into Ruma and generalize for other identifiers.

Re-exportsΒ§

pub use crate::utils::hash::sha256::Digest as Sha256;

StructsΒ§

FoldHasher
Streaming state for RandomState.
RandomState
BuildHasher for event-ID-keyed maps and sets.

ConstantsΒ§

ALPHABET_LEN πŸ”’
ALPHABET_STANDARD πŸ”’
ALPHABET_URL_SAFE πŸ”’
ENCODED_LEN πŸ”’
INVALID πŸ”’
SEXTETS_LEN πŸ”’

StaticsΒ§

SEED πŸ”’
SEXTETS πŸ”’

FunctionsΒ§

decode
Decode an event ID into the sha256 it encodes. None unless the ID has the v3+ shape with canonical unpadded base64 in either alphabet.
decode_bytes πŸ”’
decode_encoded πŸ”’
encode
Encode a sha256 into the URL-safe (room v4+) form of the event ID. A v3 (standard-alphabet) ID does not round-trip through this form.
fold πŸ”’
fold_bytes πŸ”’
folded_multiply πŸ”’
hash_bytes πŸ”’
sextets πŸ”’