pub struct ApiClientWrapper<ApiClient> {
pub api_client: GuardedApi<ApiClient>,
/* private fields */
}Fields§
§api_client: GuardedApi<ApiClient>Implementations§
Source§impl<C: XmtpBackendClient> ApiClientWrapper<C>
impl<C: XmtpBackendClient> ApiClientWrapper<C>
Sourcepub async fn create_upload(
&self,
request: CreateUploadRequest,
) -> Result<CreateUploadResponse>
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>
impl<C: XmtpBackendClient> ApiClientWrapper<C>
Sourcepub async fn get_configuration(&self) -> Result<GetConfigurationResponse>
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.
Sourcepub fn backend_url(&self) -> Option<&str>
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.
Sourcepub fn has_credential_source(&self) -> bool
pub fn has_credential_source(&self) -> bool
Whether a credential source was configured on the transport.
Source§impl<C: XmtpBackendClient> ApiClientWrapper<C>
impl<C: XmtpBackendClient> ApiClientWrapper<C>
pub async fn publish_identity_update<U: Into<IdentityUpdate>>( &self, update: U, ) -> Result<Cursor>
Sourcepub async fn get_identity_updates_v2(
&self,
filters: Vec<GetIdentityUpdatesV2Filter>,
) -> Result<HashMap<String, Vec<IdentityUpdateLog>>>
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.
Sourcepub async fn fold_identity_updates<E: From<ApiError> + Display>(
&self,
filters: Vec<GetIdentityUpdatesV2Filter>,
limits: IncomingBatchLimits,
fold: impl FnMut(Vec<IdentityUpdateLog>) -> Result<(), E>,
) -> Result<(), E>
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.
Sourcepub async fn get_inbox_ids(
&self,
identifiers: Vec<ApiIdentifier>,
) -> Result<Vec<Option<String>>>
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.
Sourcepub async fn verify_smart_contract_wallet_signatures(
&self,
request: VerifySmartContractWalletSignaturesRequest,
) -> Result<VerifySmartContractWalletSignaturesResponse>
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>
impl<C: XmtpBackendClient> ApiClientWrapper<C>
pub async fn query_group_messages( &self, group_id: GroupId, ) -> Result<Vec<GroupMessage>>
pub async fn query_group_messages_with_cursors( &self, cursors: TopicCursor, ) -> Result<Vec<GroupMessage>>
pub async fn query_latest_group_message( &self, group_id: GroupId, ) -> Result<Option<GroupMessage>>
pub async fn query_welcome_messages<Id: AsRef<[u8]> + Copy>( &self, installation_id: Id, ) -> Result<Vec<WelcomeMessage>>
Sourcepub async fn query_first_welcome(
&self,
destination: InstallationId,
max_bytes: usize,
) -> Result<Option<ServerEnvelope>>
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.
pub async fn query_welcome_messages_with_cursors( &self, cursors: TopicCursor, ) -> Result<Vec<WelcomeMessage>>
pub async fn upload_key_package( &self, key_package: Vec<u8>, ) -> Result<EnvelopeMeta>
pub async fn fetch_key_packages( &self, keys: &[InstallationId], ) -> Result<KeyPackageMap>
Sourcepub async fn newest_key_package(
&self,
id: &InstallationId,
) -> Result<Option<(KeyPackage, Cursor)>>
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.
pub async fn send_welcome_messages( &self, messages: &[WelcomeMessage], ) -> Result<Vec<EnvelopeMeta>>
pub async fn send_group_messages( &self, units: Vec<PublishUnit>, ) -> Result<Vec<EnvelopeMeta>>
Sourcepub async fn publish_commit_log(
&self,
entries: Vec<SealedCommitLogEntry>,
stored: &mut Vec<EnvelopeMeta>,
) -> Result<()>
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.
Sourcepub async fn query_commit_log(
&self,
cursors: TopicCursor,
) -> Result<Vec<CommitLogEntry>>
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.
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,
impl<C: XmtpMlsStreams + XmtpBackendClient> ApiClientWrapper<C>where
C::GroupMessageStream: 'static,
C::WelcomeMessageStream: 'static,
pub async fn subscribe_group_messages( &self, groups: &[&GroupId], ) -> Result<<GuardedApi<C> as XmtpMlsStreams>::GroupMessageStream>
pub async fn subscribe_group_messages_with_cursors( &self, cursors: &TopicCursor, ) -> Result<<GuardedApi<C> as XmtpMlsStreams>::GroupMessageStream>
pub async fn subscribe_welcome_messages( &self, installations: &[&InstallationId], ) -> Result<<GuardedApi<C> as XmtpMlsStreams>::WelcomeMessageStream>
pub async fn subscribe_welcome_messages_with_cursors( &self, cursors: &TopicCursor, ) -> Result<<GuardedApi<C> as XmtpMlsStreams>::WelcomeMessageStream>
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.
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.
Sourcepub async fn register(
&self,
request: RegisterRequest,
deadline: Instant,
) -> Result<RecipientState>
pub async fn register( &self, request: RegisterRequest, deadline: Instant, ) -> Result<RecipientState>
Create or renew a notification recipient.
Sourcepub async fn unregister(
&self,
request: UnregisterRequest,
deadline: Instant,
) -> Result<UnregisterResponse>
pub async fn unregister( &self, request: UnregisterRequest, deadline: Instant, ) -> Result<UnregisterResponse>
Delete a notification recipient and its subscriptions.
Sourcepub async fn update_subscriptions(
&self,
request: UpdateSubscriptionsRequest,
deadline: Instant,
) -> Result<RecipientState>
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>
impl<C: XmtpBackendClient> ApiClientWrapper<C>
Sourcepub async fn publish_units(
&self,
units: Vec<PublishUnit>,
) -> Result<Vec<EnvelopeMeta>>
pub async fn publish_units( &self, units: Vec<PublishUnit>, ) -> Result<Vec<EnvelopeMeta>>
Publish each atomic unit and return metadata in envelope order.
Sourcepub async fn publish_units_in_order(
&self,
units: Vec<PublishUnit>,
stored: &mut Vec<EnvelopeMeta>,
) -> Result<()>
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.
Sourcepub async fn query_ordered_page(
&self,
cursors: TopicCursor,
limit: u32,
limits: IncomingBatchLimits,
) -> Result<OrderedQueryPage>
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.
Sourcepub async fn fold_ordered_pages<E: From<ApiError>>(
&self,
cursors: TopicCursor,
limits: IncomingBatchLimits,
fold: impl FnMut(Vec<OrderedEnvelopeBatch>, &mut TopicCursor) -> Result<(), E>,
) -> Result<(), E>
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.
Sourcepub async fn newest_topic_cursors(
&self,
topics: Vec<Topic>,
) -> Result<TopicCursor>
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.
Sourcepub async fn query_all(
&self,
cursors: TopicCursor,
limit: u32,
) -> Result<Vec<ServerEnvelope>>
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.
Sourcepub async fn settle_units(
&self,
units: &[PublishUnit],
) -> Result<Vec<Option<EnvelopeMeta>>>
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>
impl<ApiClient> ApiClientWrapper<ApiClient>
pub fn new( api_client: ApiClient, retry_strategy: Retry<ExponentialBackoff>, ) -> Self
Sourcepub fn set_configuration(&mut self, configuration: Arc<ServerConfiguration>)
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.
Sourcepub fn configuration(&self) -> &ServerConfiguration
pub fn configuration(&self) -> &ServerConfiguration
What this wrapper chunks and pre-validates against.
Sourcepub fn limits(&self) -> &LimitsConfiguration
pub fn limits(&self) -> &LimitsConfiguration
The request shapes the deployment accepts.
Sourcepub fn attach_inbox_id(&mut self, inbox_id: Option<String>)
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>
impl<A> Clone for ApiClientWrapper<A>
Source§impl<ApiClient: Debug> Debug for ApiClientWrapper<ApiClient>
impl<ApiClient: Debug> Debug for ApiClientWrapper<ApiClient>
Source§impl<C> SmartContractSignatureVerifier for ApiClientWrapper<C>where
C: XmtpBackendClient,
impl<C> SmartContractSignatureVerifier for ApiClientWrapper<C>where
C: XmtpBackendClient,
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,
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,
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>
impl<ApiClient> Sync for ApiClientWrapper<ApiClient>
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
impl<T> AggregateExpressionMethods for T
§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read more§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read more§fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoSql for T
impl<T> IntoSql for T
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].