Skip to main content

offline_protocol/
lib.rs

1//! Main protocol engine for the Offline Protocol SDK.
2//!
3//! This crate ties together all the components (core, transport, router, reliability)
4//! into a single easy-to-use API.
5//!
6//! All code in this crate is 100% safe Rust with no unsafe blocks.
7
8#![deny(unsafe_code)]
9#![warn(missing_docs)]
10
11pub mod config;
12pub mod constants;
13pub mod error;
14pub mod events;
15#[cfg(feature = "file-store")]
16pub mod file_store;
17pub mod file_transfer;
18mod group_mesh;
19mod media_envelope;
20pub mod mls;
21pub mod mls_observability;
22pub mod protocol;
23pub mod protocol_state_storage;
24pub mod storage_conformance;
25mod storage_namespace;
26/// The conformance suite for [`mls::MlsStorage`] implementations, beside
27/// the protocol-state one, so a Rust host verifies both backends from here.
28pub use offline_protocol_mls::storage_conformance as mls_storage_conformance;
29pub use storage_namespace::{account_storage_namespace, is_account_storage_namespace};
30pub mod telemetry;
31pub mod transport_manager;
32pub mod visualization;
33
34pub use config::{
35    CustodyConfig, DataConfig, EncryptionConfig, GroupConfig, OverflowPolicy, PendingQueueConfig,
36    ProtocolConfig, SecurityConfig, CUSTODY_MIN_BYTES_PER_DEPOSITOR, DEFAULT_CUSTODY_HOLD_MS,
37    DEFAULT_PENDING_TTL_MS,
38};
39pub use error::{Error, EstablishmentState, Result, SessionStateError};
40pub use events::{
41    DecryptionFailureCode, DocRemovedBy, DorsEscalationPhase, DorsEscalationReasonCode,
42    DorsReasonCode, Event, EventCallback, GroupInfoMember, PresenceSource, PresenceStatus,
43    UserGroupSummary,
44};
45#[cfg(feature = "file-store")]
46pub use file_store::{
47    EnvStoreKey, FileProtocolStateStorage, FileStoreError, FileStorePair, SealedFileMlsStorage,
48    SealedState, StaticStoreKey, StoreKeyError, StoreKeyProvider,
49};
50pub use group_mesh::{
51    GroupRichReadiness, GroupSendOptions, RelaySyncState, MAX_RELAY_CAPABILITIES,
52    MAX_RELAY_CAPABILITY_TOKEN_BYTES,
53};
54/// Replicated-document types.
55///
56/// Re-exported so callers never name `offline-protocol-data` directly: the
57/// value model and the size constants are part of this crate's surface, and
58/// the engine behind them is not part of anyone's.
59#[cfg(feature = "data")]
60pub use offline_protocol_data::{DataValue, DOC_SIZE_WARN_BYTES, MAX_DOC_BYTES, MAX_VALUE_BYTES};
61pub use offline_protocol_services::MeshServices;
62pub use protocol::custody::{CustodyRefusal, CustodyStats};
63pub use protocol::mesh_relay::{MeshRelayConfig, MeshRelayStats};
64pub use protocol::{GatewayCarrier, MediaSendOptions, OfflineProtocol, SendMessageOptions};
65pub use protocol_state_storage::{
66    ProtocolStateError, ProtocolStateResult, ProtocolStateStorage,
67    MAX_PROTOCOL_STATE_RECORD_TRANSFER_BYTES,
68};
69pub use transport_manager::TransportManager;
70pub use visualization::{
71    MessageStats, NetworkLink, NetworkNode, NetworkTopology, NetworkVisualizer, NodeRole,
72};
73
74#[cfg(test)]
75mod dors_integration_tests;
76#[cfg(test)]
77mod group_mesh_tests;
78#[cfg(test)]
79mod test_identity;
80
81// Re-export reliability types for configuration and telemetry frames
82pub use offline_protocol_reliability::{
83    AckConfig, DeduplicatorConfig, DeduplicatorMode, DeduplicatorStats, RetryConfig,
84    RetryQueueStats,
85};
86
87// Re-export MLS types for end-to-end encryption
88pub use mls::{
89    EncryptedMessage, GroupId, GroupInfo, KeyPackageBundle, MlsManager, MlsStorage, WelcomeMessage,
90};
91pub use mls_observability::{
92    DecryptionFailureKind, MlsErrorCategory, MlsEventEmitter, MlsLifecycleEvent,
93    MlsOperationContext, NoopMlsEventEmitter,
94};
95#[cfg(feature = "telemetry-pipe")]
96pub use telemetry::{AppState, TelemetryHost, TelemetryOs, TelemetryPipe, TelemetryStats};
97pub use telemetry::{
98    DeviceCapabilitySnapshot, MetricsFrame, MlsVerbosity, NoopTelemetrySink, RoutingDecision,
99    RoutingPhase, RoutingReasonCode, TelemetryConfig, TelemetryRecord, TelemetrySink,
100    TransportStateEvent,
101};