Skip to main content

CoreContext

Trait CoreContext 

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

Source

type Db: XmtpDb

Source

type ApiClient: XmtpApi

Source

type MlsStorage: XmtpMlsStorageProvider

Source

type Features: MaybeSend + MaybeSync

Source

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§

Source

fn context_ref(&self) -> &Self::ContextReference

Return the handle to clone when work can outlive this context borrow.

Source

fn features(&self) -> &Self::Features

Source

fn db(&self) -> <Self::Db as XmtpDb>::DbQuery

Source

fn api(&self) -> &ApiClientWrapper<Self::ApiClient>

Source

fn scw_verifier(&self) -> Arc<Box<dyn SmartContractSignatureVerifier>> ⓘ

Source

fn device_sync(&self) -> &DeviceSync

Source

fn fork_recovery_opts(&self) -> &ForkRecoveryOpts

Source

fn worker_config(&self) -> &WorkerConfig

Source

fn mls_storage(&self) -> &Self::MlsStorage

Source

fn identity(&self) -> &Identity

Source

fn version_info(&self) -> &VersionInfo

Source

fn server_configuration(&self) -> &ServerConfigurationHandle

The configuration snapshot every consumer reads.

Source

fn events(&self) -> &EventBus<InternalEvent>

Source

fn registration_event_pending(&self) -> &Atomic<bool>

Source

fn public_event_writer(&self) -> &Arc<dyn EventWriter> ⓘ

Source

fn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>

This context’s default-consumer token; the database is the ownership authority.

Source

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.

Source

fn task_channels(&self) -> &TaskWorkerChannels

Source

fn change_callbacks(&self) -> &UnstableChangeCallbacks

Unstable: the host’s registered group-change callbacks.

Source

fn stream_policy(&self) -> &StreamPolicy

The limits on incoming work. Internal client policy.

Source

fn sync_metrics(&self) -> Option<Arc<WorkerMetrics<SyncMetric>>>

Source

fn mutexes(&self) -> &MutexRegistry

Source

fn cancellation_token(&self) -> &CancellationToken

Source

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.

Source

fn mark_shutdown_complete(&self)

Source

fn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ

Calls that Client::close waits for before it disconnects the database.

Source

fn message_timestamp_ns(&self) -> i64

Timestamp for a newly accepted local message. WASM sends are monotonic.

Provided Methods§

Source

fn device_sync_worker_enabled(&self) -> bool

Source

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.

Source

fn mls_provider(&self) -> XmtpOpenMlsProviderRef<'_, Self::MlsStorage>

Creates a new MLS Provider

Source

fn signature_request(&self) -> Option<SignatureRequest>

Source

fn inbox_id(&self) -> &str

Source

fn installation_id(&self) -> InstallationId

Source

fn close_message_delivery(&self) -> Result<(), StorageError>

Release this context’s message consumer before disconnecting its database.

Source

fn is_closed(&self) -> bool

Returns true once Client::close has been called on this context.

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 &T
where T: CoreContext,

Source§

type Db = <T as CoreContext>::Db

Source§

type ApiClient = <T as CoreContext>::ApiClient

Source§

type MlsStorage = <T as CoreContext>::MlsStorage

Source§

type Features = <T as CoreContext>::Features

Source§

type ContextReference = <T as CoreContext>::ContextReference

Source§

fn context_ref(&self) -> &<&T as CoreContext>::ContextReference

Source§

fn features(&self) -> &<&T as CoreContext>::Features

Source§

fn db(&self) -> <<&T as CoreContext>::Db as XmtpDb>::DbQuery

Source§

fn api(&self) -> &ApiClientWrapper<<&T as CoreContext>::ApiClient>

Source§

fn scw_verifier(&self) -> Arc<Box<dyn SmartContractSignatureVerifier>> ⓘ

Source§

fn device_sync(&self) -> &DeviceSync

Source§

fn device_sync_worker_enabled(&self) -> bool

Source§

fn fork_recovery_opts(&self) -> &ForkRecoveryOpts

Source§

fn worker_config(&self) -> &WorkerConfig

Source§

fn mls_storage(&self) -> &<&T as CoreContext>::MlsStorage

Source§

fn identity(&self) -> &Identity

Source§

fn version_info(&self) -> &VersionInfo

Source§

fn server_configuration(&self) -> &ServerConfigurationHandle

Source§

fn events(&self) -> &EventBus<InternalEvent>

Source§

fn registration_event_pending(&self) -> &Atomic<bool>

Source§

fn public_event_writer(&self) -> &Arc<dyn EventWriter> ⓘ

Source§

fn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>

Source§

fn retired_delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>

Source§

fn task_channels(&self) -> &TaskWorkerChannels

Source§

fn change_callbacks(&self) -> &UnstableChangeCallbacks

Source§

fn stream_policy(&self) -> &StreamPolicy

Source§

fn sync_metrics(&self) -> Option<Arc<WorkerMetrics<SyncMetric>>>

Source§

fn mutexes(&self) -> &MutexRegistry

Source§

fn cancellation_token(&self) -> &CancellationToken

Source§

fn shutdown_complete(&self) -> bool

Source§

fn mark_shutdown_complete(&self)

Source§

fn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ

Source§

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,

Source§

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

Source§

type Db = XDb

Source§

type ApiClient = XApiClient

Source§

type MlsStorage = XMls

Source§

type Features = F

Source§

type ContextReference = Arc<LocalContext<XApiClient, XDb, XMls, F>>

Source§

fn context_ref( &self, ) -> &<Arc<LocalContext<XApiClient, XDb, XMls, F>> as CoreContext>::ContextReference ⓘ

Source§

fn features(&self) -> &F

Source§

fn db( &self, ) -> <<Arc<LocalContext<XApiClient, XDb, XMls, F>> as CoreContext>::Db as XmtpDb>::DbQuery ⓘ

Source§

fn api( &self, ) -> &ApiClientWrapper<<Arc<LocalContext<XApiClient, XDb, XMls, F>> as CoreContext>::ApiClient>

Source§

fn scw_verifier(&self) -> Arc<Box<dyn SmartContractSignatureVerifier>> ⓘ

Source§

fn device_sync(&self) -> &DeviceSync

Source§

fn fork_recovery_opts(&self) -> &ForkRecoveryOpts

Source§

fn worker_config(&self) -> &WorkerConfig

Source§

fn identity(&self) -> &Identity

Source§

fn version_info(&self) -> &VersionInfo

Source§

fn server_configuration(&self) -> &ServerConfigurationHandle

Source§

fn events(&self) -> &EventBus<InternalEvent>

Source§

fn registration_event_pending(&self) -> &Atomic<bool>

Source§

fn public_event_writer(&self) -> &Arc<dyn EventWriter> ⓘ

Source§

fn delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>

Source§

fn retired_delivery_owner(&self) -> &Mutex<RawMutex, Option<DeliveryOwner>>

Source§

fn task_channels(&self) -> &TaskWorkerChannels

Source§

fn change_callbacks(&self) -> &UnstableChangeCallbacks

Source§

fn stream_policy(&self) -> &StreamPolicy

Source§

fn sync_metrics(&self) -> Option<Arc<WorkerMetrics<SyncMetric>>>

Source§

fn mutexes(&self) -> &MutexRegistry

Source§

fn cancellation_token(&self) -> &CancellationToken

Source§

fn shutdown_complete(&self) -> bool

Source§

fn mark_shutdown_complete(&self)

Source§

fn foreground_calls(&self) -> &Arc<ForegroundCalls> ⓘ

Source§

fn message_timestamp_ns(&self) -> i64

Implementors§