Skip to main content

Overview

The xmtp_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:
module
Identity API v1 protocol buffer types.
  • GetIdentityUpdatesRequest
  • GetIdentityUpdatesResponse
  • GetInboxIdsRequest
  • PublishIdentityUpdateRequest
module
MLS API v1 protocol buffer types.
  • GroupMessage
  • WelcomeMessage
  • SendGroupMessagesRequest
  • FetchKeyPackagesRequest
&'static [u8]
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 operations
  • XmtpIdentityClient - Identity service operations
  • XmtpMlsStreams - Streaming APIs

types

Core type definitions and conversions:
  • GroupId - Group identifier type
  • InstallationId - Installation identifier
  • GroupMessage - Group message wrapper
  • WelcomeMessage - Welcome message wrapper

codec

Protocol buffer encoding/decoding utilities.

traits

API client traits and abstractions:
  • Client - Base client trait
  • Query - Query operations
  • QueryStream - Streaming queries
  • Endpoint - API endpoint abstraction

proto_cache

Caching for protocol buffer operations:
  • GroupUpdateDeduper - Deduplicate group updates

Main Types and Traits

trait
Trait for MLS delivery service operations.Key Methods:
  • upload_key_package() - Upload key packages for others to add you
  • fetch_key_packages() - Fetch key packages for inviting members
  • send_group_messages() - Send messages to group
  • send_welcome_messages() - Send welcome messages to new members
  • query_group_messages() - Query group messages with pagination
  • query_welcome_messages() - Query welcome messages
trait
Trait for identity service operations.Key Methods:
  • publish_identity_update() - Publish identity association changes
  • get_inbox_ids() - Get inbox IDs for addresses
  • get_identity_updates() - Get identity update history
  • verify_smart_contract_wallet_signatures() - Verify SCW signatures
trait
Trait for streaming operations.Associated Types:
  • GroupMessageStream - Stream of group messages
  • WelcomeMessageStream - Stream of welcome messages
Methods:
  • subscribe_group_messages() - Subscribe to group message stream
  • subscribe_welcome_messages() - Subscribe to welcome message stream
trait
Combined trait for full API access.Automatically implemented for types that implement both XmtpMlsClient and XmtpIdentityClient.
Box<dyn BoxableXmtpApi>
Type-erased API client in a Box for dynamic dispatch.
Arc<dyn BoxableXmtpApi>
Type-erased API client in an Arc for shared ownership.

Protocol Buffer Types

Group Messages

struct
Represents a message in a group conversation.Fields:
  • version: GroupMessageVersion - Protocol version
  • data: Vec<u8> - Encrypted message data
  • group_id: Vec<u8> - Target group ID
struct
Request to send messages to groups.Fields:
  • messages: Vec<GroupMessage> - Messages to send

Welcome Messages

struct
MLS welcome message for new group members.Fields:
  • version: WelcomeMessageVersion - Protocol version
  • data: Vec<u8> - Encrypted welcome data
  • installation_key: Vec<u8> - Target installation
struct
Response containing welcome messages.Fields:
  • messages: Vec<WelcomeMessage> - Welcome messages
  • paging_info: Option<PagingInfo> - Pagination state

Identity Updates

struct
Request to publish an identity update.Fields:
  • identity_update: IdentityUpdate - The update to publish
struct
Request to fetch identity updates.Fields:
  • requests: Vec<GetIdentityUpdatesRequestItem> - Inbox IDs to query
  • start_time_ns: u64 - Optional start time filter
struct
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

struct
Pagination state for API responses.Fields:
  • cursor: Option<TopicCursor> - Cursor for next page
  • has_more: bool - Whether more results exist
  • limit: u32 - Page size limit
trait
Trait for types that support pagination.Methods:
  • info() -> &Option<PagingInfo> - Get paging information
  • messages() -> Vec<Message> - Extract messages from response

Error Handling

API client errors are generic:
Implementors define their own error types.

Features

feature
Testing utilities including mock clients and test helpers.
feature
Server-side gRPC implementations (usually for testing).
feature
Development configuration.

Platform Support

  • Native (all platforms with full gRPC support)
  • WebAssembly (limited gRPC client support)

Statistics and Monitoring

trait
Trait for types that provide statistics.
struct
API call statistics.Fields:
  • request_count: u64 - Total requests
  • error_count: u64 - Total errors
  • identity_stats: IdentityStats - Identity API stats

Prelude

Common imports:

Dependencies

Key dependencies:
  • prost - Protocol buffer encoding
  • tonic - gRPC client/server
  • futures - Async streams
  • bytes - Efficient byte buffers