Skip to main content

ApiClientWrapper

Struct ApiClientWrapper 

Source
pub struct ApiClientWrapper<ApiClient> {
    pub api_client: GuardedApi<ApiClient>,
    /* private fields */
}

Fields§

§api_client: GuardedApi<ApiClient>

Implementations§

Source§

impl<C: XmtpBackendClient> ApiClientWrapper<C>

Source

pub async fn create_upload( &self, request: CreateUploadRequest, ) -> Result<CreateUploadResponse>

Get the request to send to the configured storage target.

Source§

impl<C: XmtpBackendClient> ApiClientWrapper<C>

Source

pub async fn get_configuration(&self) -> Result<GetConfigurationResponse>

Read what the deployment publishes about itself.

Not retried here: the caller decides what a failure means. build fails with ConfigurationUnavailable; a refresh attempt logs and waits out its own schedule.

Source

pub fn backend_url(&self) -> Option<&str>

The backend URL this client sends to, when the transport knows it. None skips the comparison with the stored backend URL.

Source

pub fn has_credential_source(&self) -> bool

Whether a credential source was configured on the transport.

Source§

impl<C: XmtpBackendClient> ApiClientWrapper<C>

Source

pub async fn publish_identity_update<U: Into<IdentityUpdate>>( &self, update: U, ) -> Result<Cursor>

Source

pub async fn get_identity_updates_v2( &self, filters: Vec<GetIdentityUpdatesV2Filter>, ) -> Result<HashMap<String, Vec<IdentityUpdateLog>>>

Read every update the filters name and return them by inbox, in sequence order. Use Self::fold_identity_updates to store a long history without retaining it all.

Source

pub async fn fold_identity_updates<E: From<ApiError> + Display>( &self, filters: Vec<GetIdentityUpdatesV2Filter>, limits: IncomingBatchLimits, fold: impl FnMut(Vec<IdentityUpdateLog>) -> Result<(), E>, ) -> Result<(), E>

Read the updates the filters name one bounded page at a time, in sequence order for each inbox, without retaining earlier pages. Every update names one of the filters’ inboxes exactly. An API or fold error stops the read; the caller stores each page before the next request.

Source

pub async fn get_inbox_ids( &self, identifiers: Vec<ApiIdentifier>, ) -> Result<Vec<Option<String>>>

Return one optional inbox id for every input, in the same order.

Source

pub async fn verify_smart_contract_wallet_signatures( &self, request: VerifySmartContractWalletSignaturesRequest, ) -> Result<VerifySmartContractWalletSignaturesResponse>

Verify every signature and return one verdict per signature, in request order. The signatures go out in requests of at most the published max_scw_signatures, never more than MAX_SCW_SIGNATURES_PER_REQUEST, and within max_request_bytes, with up to MAX_READ_CHUNKS_IN_FLIGHT requests in flight. A response whose verdict count differs from its request’s is a retryable ApiError::VerdictCount.

Source§

impl<C: XmtpBackendClient> ApiClientWrapper<C>

Source

pub async fn query_group_messages( &self, group_id: GroupId, ) -> Result<Vec<GroupMessage>>

Source

pub async fn query_group_messages_with_cursors( &self, cursors: TopicCursor, ) -> Result<Vec<GroupMessage>>

Source

pub async fn query_latest_group_message( &self, group_id: GroupId, ) -> Result<Option<GroupMessage>>

Source

pub async fn query_welcome_messages<Id: AsRef<[u8]> + Copy>( &self, installation_id: Id, ) -> Result<Vec<WelcomeMessage>>

Source

pub async fn query_first_welcome( &self, destination: InstallationId, max_bytes: usize, ) -> Result<Option<ServerEnvelope>>

The lowest-sequence envelope on the Welcome topic of destination, with validated metadata and an undecoded payload. One Query with limit 1 from cursor 0, so later envelopes are never fetched.

Source

pub async fn query_welcome_messages_with_cursors( &self, cursors: TopicCursor, ) -> Result<Vec<WelcomeMessage>>

Source

pub async fn upload_key_package( &self, key_package: Vec<u8>, ) -> Result<EnvelopeMeta>

Source

pub async fn fetch_key_packages( &self, keys: &[InstallationId], ) -> Result<KeyPackageMap>

Source

pub async fn newest_key_package( &self, id: &InstallationId, ) -> Result<Option<(KeyPackage, Cursor)>>

The newest package on the key package topic of id, with its sequence id.

Source

pub async fn send_welcome_messages( &self, messages: &[WelcomeMessage], ) -> Result<Vec<EnvelopeMeta>>

Source

pub async fn send_group_messages( &self, units: Vec<PublishUnit>, ) -> Result<Vec<EnvelopeMeta>>

Source

pub async fn publish_commit_log( &self, entries: Vec<SealedCommitLogEntry>, stored: &mut Vec<EnvelopeMeta>, ) -> Result<()>

Publish commit-log entries in the given order, one request at a time, and stop at the first failed request. Each stored entry’s metadata is appended to stored, so on an error stored names the stored prefix of entries and a retry starts from the first entry after it.

Source

pub async fn query_commit_log( &self, cursors: TopicCursor, ) -> Result<Vec<CommitLogEntry>>

Read commit-log topics without opening any entry. An envelope whose metadata does not decode is logged and left out; the read still returns every other envelope, so one bad envelope never fails it.

Source

pub async fn get_newest_message_metadata( &self, group_ids: &[GroupId], ) -> Result<HashMap<GroupId, GroupMessageMetadata>>

Source§

impl<C: XmtpMlsStreams + XmtpBackendClient> ApiClientWrapper<C>
where C::GroupMessageStream: 'static, C::WelcomeMessageStream: 'static,

Source§

impl<C: XmtpBackendClient> ApiClientWrapper<C>

Each request ends by deadline, which the caller shares across the requests of one notification turn. A rate-limit wait that would pass it returns the rejection at once, so the notification worker schedules the next attempt from its delay.

Source

pub async fn register( &self, request: RegisterRequest, deadline: Instant, ) -> Result<RecipientState>

Create or renew a notification recipient.

Source

pub async fn unregister( &self, request: UnregisterRequest, deadline: Instant, ) -> Result<UnregisterResponse>

Delete a notification recipient and its subscriptions.

Source

pub async fn update_subscriptions( &self, request: UpdateSubscriptionsRequest, deadline: Instant, ) -> Result<RecipientState>

Atomically update notification subscriptions and renew the recipient.

Source§

impl<C: XmtpBackendClient> ApiClientWrapper<C>

Source

pub async fn publish_units( &self, units: Vec<PublishUnit>, ) -> Result<Vec<EnvelopeMeta>>

Publish each atomic unit and return metadata in envelope order.

Source

pub async fn publish_units_in_order( &self, units: Vec<PublishUnit>, stored: &mut Vec<EnvelopeMeta>, ) -> Result<()>

Publish units with one request in flight at a time, in unit order, and stop at the first failed request. Each stored envelope’s metadata is appended to stored as its request returns, so on an error stored names the stored prefix; the envelopes of the failed request may or may not be stored. A commit-log reader, which keeps only a continuous chain, never sees a later request stored ahead of an earlier one.

Source

pub async fn query_ordered_page( &self, cursors: TopicCursor, limit: u32, limits: IncomingBatchLimits, ) -> Result<OrderedQueryPage>

Read one bounded ordered page without decoding MLS payloads. Commit each batch before requesting more from the new received prefix F.

Source

pub async fn fold_ordered_pages<E: From<ApiError>>( &self, cursors: TopicCursor, limits: IncomingBatchLimits, fold: impl FnMut(Vec<OrderedEnvelopeBatch>, &mut TopicCursor) -> Result<(), E>, ) -> Result<(), E>

Fold one bounded ordered page at a time without retaining earlier pages. Cursors advance before the fold runs. Remove a topic from the fold’s cursors to stop reading it. An API or fold error stops the read immediately; the caller owns persistence of each page and its durable cursors.

Source

pub async fn newest_topic_cursors( &self, topics: Vec<Topic>, ) -> Result<TopicCursor>

Capture fixed newest targets. Absent topics have target zero. Keep these targets unchanged while waiting for processing to reach them.

Source

pub async fn query_all( &self, cursors: TopicCursor, limit: u32, ) -> Result<Vec<ServerEnvelope>>

Read every page. Each topic advances only to its own returned cursor. Use Self::fold_ordered_pages to process a backlog without retaining it all.

Source

pub async fn settle_units( &self, units: &[PublishUnit], ) -> Result<Vec<Option<EnvelopeMeta>>>

Settle a publish whose outcome is unknown without resending it: a Query of every topic in units, from the start, returns the stored metadata of each envelope in envelope order, matched by its canonical hash. None marks an envelope the backend did not store. Pages that match nothing are dropped, and the read stops once every envelope matched. A record without valid metadata fails the read: it could be any envelope, so the read cannot prove one absent.

Source§

impl<ApiClient> ApiClientWrapper<ApiClient>

Source

pub fn new( api_client: ApiClient, retry_strategy: Retry<ExponentialBackoff>, ) -> Self

Source

pub fn set_configuration(&mut self, configuration: Arc<ServerConfiguration>)

Chunk and pre-validate every later request against this snapshot. Called once, by build, before the client runs.

Source

pub fn configuration(&self) -> &ServerConfiguration

What this wrapper chunks and pre-validates against.

Source

pub fn limits(&self) -> &LimitsConfiguration

The request shapes the deployment accepts.

Source

pub fn attach_inbox_id(&mut self, inbox_id: Option<String>)

Attach an InboxId to this API Client Wrapper. Attaches an inbox_id context to tracing logs, useful for debugging

Trait Implementations§

Source§

impl<A> Clone for ApiClientWrapper<A>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<ApiClient: Debug> Debug for ApiClientWrapper<ApiClient>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C> SmartContractSignatureVerifier for ApiClientWrapper<C>

Source§

fn is_valid_signature<'life0, 'async_trait>( &'life0 self, account_id: AccountId, hash: [u8; 32], signature: Bytes, block_number: Option<BlockNumber>, ) -> Pin<Box<dyn Future<Output = Result<ValidationResponse, VerifierError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Verifies an ERC-6492https://eips.ethereum.org/EIPS/eip-6492 signature.

§Arguments
  • signer - can be the smart wallet address or EOA address.
  • hash - Message digest for the signature.
  • signature - Could be encoded smart wallet signature or raw ECDSA signature.
Source§

fn verify_many<'life0, 'life1, 'async_trait>( &'life0 self, inputs: &'life1 [ScwInput], ) -> Pin<Box<dyn Future<Output = Result<Vec<ValidationResponse>, VerifierError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Verify the inputs in as few backend requests as the published limits allow, and return the verdicts in input order. The split and the verdict-count check are those of ApiClientWrapper::verify_smart_contract_wallet_signatures; its error keeps its retryability.

Auto Trait Implementations§

§

impl<ApiClient> Freeze for ApiClientWrapper<ApiClient>

§

impl<ApiClient> !RefUnwindSafe for ApiClientWrapper<ApiClient>

§

impl<ApiClient> Send for ApiClientWrapper<ApiClient>
where ApiClient: Sync + Send,

§

impl<ApiClient> Sync for ApiClientWrapper<ApiClient>
where ApiClient: Sync + Send,

§

impl<ApiClient> Unpin for ApiClientWrapper<ApiClient>

§

impl<ApiClient> UnsafeUnpin for ApiClientWrapper<ApiClient>

§

impl<ApiClient> !UnwindSafe for ApiClientWrapper<ApiClient>

Blanket Implementations§

§

impl<T> AggregateExpressionMethods for T

§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> IntoSql for T

§

fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>, T: SqlType + TypedExpressionType,

Convert self to an expression for Diesel’s query builder. Read more
§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WindowExpressionMethods for T

§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,