pub trait CoreContext:
Sized
+ MaybeSend
+ MaybeSync
+ Clone {
type Db: XmtpDb;
type ApiClient: XmtpApi;
type MlsStorage: XmtpMlsStorageProvider;
type Features: MaybeSend + MaybeSync;
type ContextReference: CoreContext<Db = Self::Db, ApiClient = Self::ApiClient, MlsStorage = Self::MlsStorage, Features = Self::Features> + 'static;
Show 35 methods
// Required methods
fn context_ref(&self) -> &Self::ContextReference;
fn features(&self) -> &Self::Features;
fn db(&self) -> <Self::Db as XmtpDb>::DbQuery;
fn api(&self) -> &ApiClientWrapper<Self::ApiClient>;
fn scw_verifier(&self) -> Arc<Box<dyn SmartContractSignatureVerifier>> ⓘ;
fn device_sync(&self) -> &DeviceSync;
fn fork_recovery_opts(&self) -> &ForkRecoveryOpts;
fn worker_config(&self) -> &WorkerConfig;
fn mls_storage(&self) -> &Self::MlsStorage;
fn identity(&self) -> &Identity;
fn version_info(&self) -> &VersionInfo;
fn server_configuration(&self) -> &ServerConfigurationHandle;
fn events(&self) -> &EventBus<InternalEvent>;
fn registration_event_pending(&self) -> &Atomic<bool>;
fn public_event_writer(&self) -> &Arc<dyn EventWriter> ⓘ;
fn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>;
fn retired_delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>;
fn task_channels(&self) -> &TaskWorkerChannels;
fn change_callbacks(&self) -> &UnstableChangeCallbacks;
fn stream_policy(&self) -> &StreamPolicy;
fn sync_metrics(&self) -> Option<Arc<WorkerMetrics<SyncMetric>>>;
fn mutexes(&self) -> &MutexRegistry;
fn cancellation_token(&self) -> &CancellationToken;
fn shutdown_complete(&self) -> bool;
fn mark_shutdown_complete(&self);
fn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ;
fn message_timestamp_ns(&self) -> i64;
// Provided methods
fn device_sync_worker_enabled(&self) -> bool { ... }
fn worker_interval(
&self,
kind: WorkerKind,
const_default: Duration,
) -> (Duration, Duration) { ... }
fn mls_provider(&self) -> XmtpOpenMlsProviderRef<'_, Self::MlsStorage> { ... }
fn signature_request(&self) -> Option<SignatureRequest> { ... }
fn inbox_id(&self) -> &str { ... }
fn installation_id(&self) -> InstallationId { ... }
fn close_message_delivery(&self) -> Result<(), StorageError> { ... }
fn is_closed(&self) -> bool { ... }
}Expand description
The context core code runs on: storage, the API client, the identity,
events and the client’s plain settings. Features is what the crates above
core add; each of them reads its own part through its own trait.
Required Associated Types§
type Db: XmtpDb
type ApiClient: XmtpApi
type MlsStorage: XmtpMlsStorageProvider
type Features: MaybeSend + MaybeSync
Sourcetype ContextReference: CoreContext<Db = Self::Db, ApiClient = Self::ApiClient, MlsStorage = Self::MlsStorage, Features = Self::Features> + 'static
type ContextReference: CoreContext<Db = Self::Db, ApiClient = Self::ApiClient, MlsStorage = Self::MlsStorage, Features = Self::Features> + 'static
Owned, cloneable handle for background work; it cannot borrow short-lived resources.
Required Methods§
Sourcefn context_ref(&self) -> &Self::ContextReference
fn context_ref(&self) -> &Self::ContextReference
Return the handle to clone when work can outlive this context borrow.
fn features(&self) -> &Self::Features
fn db(&self) -> <Self::Db as XmtpDb>::DbQuery
fn api(&self) -> &ApiClientWrapper<Self::ApiClient>
fn scw_verifier(&self) -> Arc<Box<dyn SmartContractSignatureVerifier>> ⓘ
fn device_sync(&self) -> &DeviceSync
fn fork_recovery_opts(&self) -> &ForkRecoveryOpts
fn worker_config(&self) -> &WorkerConfig
fn mls_storage(&self) -> &Self::MlsStorage
fn identity(&self) -> &Identity
fn version_info(&self) -> &VersionInfo
Sourcefn server_configuration(&self) -> &ServerConfigurationHandle
fn server_configuration(&self) -> &ServerConfigurationHandle
The configuration snapshot every consumer reads.
fn events(&self) -> &EventBus<InternalEvent>
fn registration_event_pending(&self) -> &Atomic<bool>
fn public_event_writer(&self) -> &Arc<dyn EventWriter> ⓘ
Sourcefn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>
fn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>
This context’s default-consumer token; the database is the ownership authority.
Sourcefn retired_delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>
fn retired_delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>
A closed reader’s delivery ownership whose release failed, kept until a
storage repair releases it. Lock it only while holding
Self::delivery_owner.
fn task_channels(&self) -> &TaskWorkerChannels
Sourcefn change_callbacks(&self) -> &UnstableChangeCallbacks
fn change_callbacks(&self) -> &UnstableChangeCallbacks
Unstable: the host’s registered group-change callbacks.
Sourcefn stream_policy(&self) -> &StreamPolicy
fn stream_policy(&self) -> &StreamPolicy
The limits on incoming work. Internal client policy.
fn sync_metrics(&self) -> Option<Arc<WorkerMetrics<SyncMetric>>>
fn mutexes(&self) -> &MutexRegistry
fn cancellation_token(&self) -> &CancellationToken
Sourcefn shutdown_complete(&self) -> bool
fn shutdown_complete(&self) -> bool
Returns true only after Client::close has fully torn the client
down (workers drained + DB disconnected). Distinct from Self::is_closed
which fires the moment shutdown begins — this guards close’s
idempotency check so a mid-shutdown failure stays retryable.
fn mark_shutdown_complete(&self)
Sourcefn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ
fn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ
Calls that Client::close waits for before it disconnects the database.
Sourcefn message_timestamp_ns(&self) -> i64
fn message_timestamp_ns(&self) -> i64
Timestamp for a newly accepted local message. WASM sends are monotonic.
Provided Methods§
fn device_sync_worker_enabled(&self) -> bool
Sourcefn worker_interval(
&self,
kind: WorkerKind,
const_default: Duration,
) -> (Duration, Duration)
fn worker_interval( &self, kind: WorkerKind, const_default: Duration, ) -> (Duration, Duration)
Resolve (base, jitter) for a worker from the configured
WorkerConfig, falling back to the worker’s compiled-in const.
Sourcefn mls_provider(&self) -> XmtpOpenMlsProviderRef<'_, Self::MlsStorage>
fn mls_provider(&self) -> XmtpOpenMlsProviderRef<'_, Self::MlsStorage>
Creates a new MLS Provider
fn signature_request(&self) -> Option<SignatureRequest>
fn inbox_id(&self) -> &str
fn installation_id(&self) -> InstallationId
Sourcefn close_message_delivery(&self) -> Result<(), StorageError>
fn close_message_delivery(&self) -> Result<(), StorageError>
Release this context’s message consumer before disconnecting its database.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T> CoreContext for &Twhere
T: CoreContext,
impl<T> CoreContext for &Twhere
T: CoreContext,
type Db = <T as CoreContext>::Db
type ApiClient = <T as CoreContext>::ApiClient
type MlsStorage = <T as CoreContext>::MlsStorage
type Features = <T as CoreContext>::Features
type ContextReference = <T as CoreContext>::ContextReference
fn context_ref(&self) -> &<&T as CoreContext>::ContextReference
fn features(&self) -> &<&T as CoreContext>::Features
fn db(&self) -> <<&T as CoreContext>::Db as XmtpDb>::DbQuery
fn api(&self) -> &ApiClientWrapper<<&T as CoreContext>::ApiClient>
fn scw_verifier(&self) -> Arc<Box<dyn SmartContractSignatureVerifier>> ⓘ
fn device_sync(&self) -> &DeviceSync
fn device_sync_worker_enabled(&self) -> bool
fn fork_recovery_opts(&self) -> &ForkRecoveryOpts
fn worker_config(&self) -> &WorkerConfig
fn mls_storage(&self) -> &<&T as CoreContext>::MlsStorage
fn identity(&self) -> &Identity
fn version_info(&self) -> &VersionInfo
fn server_configuration(&self) -> &ServerConfigurationHandle
fn events(&self) -> &EventBus<InternalEvent>
fn registration_event_pending(&self) -> &Atomic<bool>
fn public_event_writer(&self) -> &Arc<dyn EventWriter> ⓘ
fn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>
fn retired_delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>
fn task_channels(&self) -> &TaskWorkerChannels
fn change_callbacks(&self) -> &UnstableChangeCallbacks
fn stream_policy(&self) -> &StreamPolicy
fn sync_metrics(&self) -> Option<Arc<WorkerMetrics<SyncMetric>>>
fn mutexes(&self) -> &MutexRegistry
fn cancellation_token(&self) -> &CancellationToken
fn shutdown_complete(&self) -> bool
fn mark_shutdown_complete(&self)
fn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ
fn message_timestamp_ns(&self) -> i64
Source§impl<XApiClient, XDb, XMls, F> CoreContext for Arc<LocalContext<XApiClient, XDb, XMls, F>>where
XApiClient: XmtpApi + 'static,
XDb: XmtpDb + 'static,
XMls: XmtpMlsStorageProvider + 'static,
F: MaybeSend + MaybeSync + 'static,
impl<XApiClient, XDb, XMls, F> CoreContext for Arc<LocalContext<XApiClient, XDb, XMls, F>>where
XApiClient: XmtpApi + 'static,
XDb: XmtpDb + 'static,
XMls: XmtpMlsStorageProvider + 'static,
F: MaybeSend + MaybeSync + 'static,
Source§fn mls_storage(
&self,
) -> &<Arc<LocalContext<XApiClient, XDb, XMls, F>> as CoreContext>::MlsStorage ⓘ
fn mls_storage( &self, ) -> &<Arc<LocalContext<XApiClient, XDb, XMls, F>> as CoreContext>::MlsStorage ⓘ
a reference to the MLS Storage Type This can be related to ‘db()’ but may also be separate