Overview
Thexmtp_proto crate provides Rust types and traits for XMTP protocol buffer definitions. It includes gRPC client traits, message types, and API abstractions for both the MLS delivery service and identity service.
Installation
Key Exports
The crate exports protocol buffer types organized by API version:Identity API v1 protocol buffer types.
GetIdentityUpdatesRequestGetIdentityUpdatesResponseGetInboxIdsRequestPublishIdentityUpdateRequest
MLS API v1 protocol buffer types.
GroupMessageWelcomeMessageSendGroupMessagesRequestFetchKeyPackagesRequest
Compiled protocol buffer descriptor set for reflection and dynamic operations.
Core Modules
api_client
Client traits and implementations for XMTP APIs:XmtpMlsClient- MLS delivery service operationsXmtpIdentityClient- Identity service operationsXmtpMlsStreams- Streaming APIs
types
Core type definitions and conversions:GroupId- Group identifier typeInstallationId- Installation identifierGroupMessage- Group message wrapperWelcomeMessage- Welcome message wrapper
codec
Protocol buffer encoding/decoding utilities.traits
API client traits and abstractions:Client- Base client traitQuery- Query operationsQueryStream- Streaming queriesEndpoint- API endpoint abstraction
proto_cache
Caching for protocol buffer operations:GroupUpdateDeduper- Deduplicate group updates
Main Types and Traits
Trait for MLS delivery service operations.Key Methods:
upload_key_package()- Upload key packages for others to add youfetch_key_packages()- Fetch key packages for inviting memberssend_group_messages()- Send messages to groupsend_welcome_messages()- Send welcome messages to new membersquery_group_messages()- Query group messages with paginationquery_welcome_messages()- Query welcome messages
Trait for identity service operations.Key Methods:
publish_identity_update()- Publish identity association changesget_inbox_ids()- Get inbox IDs for addressesget_identity_updates()- Get identity update historyverify_smart_contract_wallet_signatures()- Verify SCW signatures
Trait for streaming operations.Associated Types:
GroupMessageStream- Stream of group messagesWelcomeMessageStream- Stream of welcome messages
subscribe_group_messages()- Subscribe to group message streamsubscribe_welcome_messages()- Subscribe to welcome message stream
Combined trait for full API access.Automatically implemented for types that implement both
XmtpMlsClient and XmtpIdentityClient.Type-erased API client in a Box for dynamic dispatch.
Type-erased API client in an Arc for shared ownership.
Protocol Buffer Types
Group Messages
Represents a message in a group conversation.Fields:
version: GroupMessageVersion- Protocol versiondata: Vec<u8>- Encrypted message datagroup_id: Vec<u8>- Target group ID
Request to send messages to groups.Fields:
messages: Vec<GroupMessage>- Messages to send
Welcome Messages
MLS welcome message for new group members.Fields:
version: WelcomeMessageVersion- Protocol versiondata: Vec<u8>- Encrypted welcome datainstallation_key: Vec<u8>- Target installation
Response containing welcome messages.Fields:
messages: Vec<WelcomeMessage>- Welcome messagespaging_info: Option<PagingInfo>- Pagination state
Identity Updates
Request to publish an identity update.Fields:
identity_update: IdentityUpdate- The update to publish
Request to fetch identity updates.Fields:
requests: Vec<GetIdentityUpdatesRequestItem>- Inbox IDs to querystart_time_ns: u64- Optional start time filter
Response with identity update history.Fields:
responses: Vec<IdentityUpdateLog>- Update logs per inbox
Usage Examples
Using the MLS Client Trait
Querying Messages with Pagination
Streaming Messages
Publishing Identity Updates
Fetching Inbox IDs
Using Type-Erased Clients
Deduplicating Updates
Pagination
Pagination state for API responses.Fields:
cursor: Option<TopicCursor>- Cursor for next pagehas_more: bool- Whether more results existlimit: u32- Page size limit
Trait for types that support pagination.Methods:
info() -> &Option<PagingInfo>- Get paging informationmessages() -> Vec<Message>- Extract messages from response
Error Handling
API client errors are generic:Features
Testing utilities including mock clients and test helpers.
Server-side gRPC implementations (usually for testing).
Development configuration.
Platform Support
- Native (all platforms with full gRPC support)
- WebAssembly (limited gRPC client support)
Statistics and Monitoring
Trait for types that provide statistics.
API call statistics.Fields:
request_count: u64- Total requestserror_count: u64- Total errorsidentity_stats: IdentityStats- Identity API stats
Prelude
Common imports:Dependencies
Key dependencies:prost- Protocol buffer encodingtonic- gRPC client/serverfutures- Async streamsbytes- Efficient byte buffers
