Expand description
Single source-of-truth for the per-ComponentId read/encode/apply logic.
Centralizes everything the rest of the MLS pipeline needs to know about
a well-known ComponentId: its logical [ComponentType], where its
current bytes live (OpenMLS AppData dictionary vs. legacy group context
extensions), and how to encode/apply AppDataUpdate payloads.
The helpers are pub so xmtp_mls can call them. They read and write
raw component bytes; xmtp_mls owns the intent and commit paths that
decide when a write is allowed.
§Field bounds
apply_app_data_update_payload rejects a new value of an application
component, USER_DISPLAY_NAME, or GROUP_IMAGE whose scalar,
collection key, or collection value exceeds MAX_FIELD_ELEMENT_BYTES,
or whose serialized collection exceeds MAX_FIELD_SNAPSHOT_BYTES.
[check_update_payload_bounds] applies the element bound to every
element an update payload names, without the state it applies to.
§Inbox-id encoding
The legacy GMM extension stores inbox ids as 64-character hex strings.
Anything serialized through the new AppDataUpdate path uses the
versioned InboxId newtype.
See crate::inbox_id for the full wire-format contract;
the short version is varint(version) || 32-byte payload, with
version 0 producing a 33-byte encoding.
Structs§
- Group
Metadata Return - Intermediate proto-shaped result of
read_group_metadata_from_extensions. Caller converts to the finalcrate::group_metadata::GroupMetadata.
Enums§
- Component
Source Error - Errors surfaced by the component_source layer.
Constants§
- MAX_
FIELD_ ELEMENT_ BYTES - Longest scalar, collection key, or collection value that an application
component,
USER_DISPLAY_NAME,GROUP_IMAGE, orCOMPONENT_REGISTRYmay hold. - MAX_
FIELD_ SNAPSHOT_ BYTES - Longest serialized collection snapshot that an application component,
USER_DISPLAY_NAME,GROUP_IMAGE, orCOMPONENT_REGISTRYmay hold.
Functions§
- apply_
app_ data_ update_ payload - Decode an incoming
AppDataUpdateOperation::Update(bytes)payload and produce the new full bytes of the component, given the prior stored bytes (if any).Update-only —Removecarries no payload and is handled directly by the caller. - component_
id_ to_ metadata_ field - Map a
ComponentIdback to theMetadataFieldattribute name that stores it in the legacyGroupMutableMetadataextension. - component_
type - Hardcoded logical type of a well-known component. Returns
Nonefor app-range components (0xC000-0xFEFF) and for any well-known id that is not yet wired into this match. - expand_
app_ data_ update_ to_ changes - Expand an
AppDataUpdateproposal payload into the per-element changes that should be checked against the component registry. - extract_
group_ mutable_ metadata_ capability_ aware - Extract
GroupMutableMetadatafrom the AppData dictionary. - extract_
group_ mutable_ metadata_ capability_ aware_ from_ extensions - Same as
extract_group_mutable_metadata_capability_aware, but driven from the group’sGroupContextextensions alone — no fullOpenMlsGroup::load. The mutable metadata lives entirely in the context extensions, so a singleStorageProvider::group_contextread (one KV round-trip, no ratchet tree) is all this needs. - inbox_
id_ str_ to_ bytes - Decode a hex-string inbox id into an
InboxId. - merge_
app_ data_ into_ mutable_ metadata - Overlay AppData-dict component values onto a base
GroupMutableMetadata. - merge_
app_ data_ into_ mutable_ metadata_ from_ extensions - Extensions-only variant of
merge_app_data_into_mutable_metadata. - metadata_
field_ to_ component_ id - Map a
MetadataFieldstring to its correspondingComponentId. - read_
component_ bytes - Read the component’s current bytes from the OpenMLS AppData dictionary.
- read_
from_ app_ data_ dict - Look up the component’s bytes in the OpenMLS AppData dictionary.
- read_
from_ app_ data_ dict_ from_ extensions - Extensions-only counterpart of
read_from_app_data_dict— reads the component’s bytes straight from a group’sGroupContextextensions, with no fullOpenMlsGroup. openmls keys the dictionary by its ownComponentId, which is just au16alias, soid.as_u16()unwraps our newtype to the key. - read_
group_ membership_ from_ dict - Read the
GROUP_MEMBERSHIPdict entry and decode it into the legacyGroupMembershipproto shape. Used byextract_group_membershipon the receive-side validator to bridge the dict-stored membership back into the existingGroupMembershipRust type without rewriting every caller. - read_
group_ metadata_ from_ dict - Synthesize a [
GroupMetadata] from the AppData dictionary. ReturnsOk(None)if the critical immutable seeds are absent. - read_
group_ metadata_ from_ extensions - Extensions-only variant of
read_group_metadata_from_dict. Same rationale for the split asread_super_admin_list_from_extensions. - read_
post_ commit_ component_ bytes - Compute the post-commit value of a single component
by overlaying the staged commit’s
AppDataUpdateproposals on top of the pre-commit dict. Last-write-wins matches the lazy-batching apply order inxmtp_mls’saccumulate_app_data_updates: everyUpdate(payload)is decoded against the running value (so collection deltas compose), andRemovecollapses toNone. - read_
super_ admin_ list_ from_ dict - Read the super-admin list from the AppData dictionary.
- read_
super_ admin_ list_ from_ extensions - Extensions-only variant of
read_super_admin_list_from_dict. Use the shim above when anOpenMlsGroupis at hand; this form is available primarily for unit testing and for commit-validation paths that only carry anExtensionsreference.