Skip to main content

Module component_source

Module component_source 

Source
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§

GroupMetadataReturn
Intermediate proto-shaped result of read_group_metadata_from_extensions. Caller converts to the final crate::group_metadata::GroupMetadata.

Enums§

ComponentSourceError
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, or COMPONENT_REGISTRY may hold.
MAX_FIELD_SNAPSHOT_BYTES
Longest serialized collection snapshot that an application component, USER_DISPLAY_NAME, GROUP_IMAGE, or COMPONENT_REGISTRY may 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 — Remove carries no payload and is handled directly by the caller.
component_id_to_metadata_field
Map a ComponentId back to the MetadataField attribute name that stores it in the legacy GroupMutableMetadata extension.
component_type
Hardcoded logical type of a well-known component. Returns None for 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 AppDataUpdate proposal payload into the per-element changes that should be checked against the component registry.
extract_group_mutable_metadata_capability_aware
Extract GroupMutableMetadata from the AppData dictionary.
extract_group_mutable_metadata_capability_aware_from_extensions
Same as extract_group_mutable_metadata_capability_aware, but driven from the group’s GroupContext extensions alone — no full OpenMlsGroup::load. The mutable metadata lives entirely in the context extensions, so a single StorageProvider::group_context read (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 MetadataField string to its corresponding ComponentId.
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’s GroupContext extensions, with no full OpenMlsGroup. openmls keys the dictionary by its own ComponentId, which is just a u16 alias, so id.as_u16() unwraps our newtype to the key.
read_group_membership_from_dict
Read the GROUP_MEMBERSHIP dict entry and decode it into the legacy GroupMembership proto shape. Used by extract_group_membership on the receive-side validator to bridge the dict-stored membership back into the existing GroupMembership Rust type without rewriting every caller.
read_group_metadata_from_dict
Synthesize a [GroupMetadata] from the AppData dictionary. Returns Ok(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 as read_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 AppDataUpdate proposals on top of the pre-commit dict. Last-write-wins matches the lazy-batching apply order in xmtp_mls’s accumulate_app_data_updates: every Update(payload) is decoded against the running value (so collection deltas compose), and Remove collapses to None.
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 an OpenMlsGroup is at hand; this form is available primarily for unit testing and for commit-validation paths that only carry an Extensions reference.