xmtp_api/configuration.rs
1//! The unauthenticated configuration read (spec 006 ยง5, CFG-040).
2
3use crate::{ApiClientWrapper, Result, dyn_err};
4use xmtp_proto::{api_client::XmtpBackendClient, backend_v1 as wire};
5
6impl<C: XmtpBackendClient> ApiClientWrapper<C> {
7 /// Read what the deployment publishes about itself.
8 ///
9 /// Not retried here: the caller decides what a failure means. `build`
10 /// fails with `ConfigurationUnavailable`; a refresh attempt logs and waits
11 /// out its own schedule (CFG-046).
12 #[xmtp_common::rpc_span]
13 pub async fn get_configuration(&self) -> Result<wire::GetConfigurationResponse> {
14 self.api_client
15 .get_configuration(wire::GetConfigurationRequest {})
16 .await
17 .map_err(dyn_err)
18 }
19
20 /// The backend URL this client sends to, when the transport knows it.
21 /// `None` skips the URL comparison of CFG-042 and CFG-055.
22 pub fn backend_url(&self) -> Option<&str> {
23 self.api_client.backend_url()
24 }
25
26 /// Whether a credential source was configured on the transport (CFG-062).
27 pub fn has_credential_source(&self) -> bool {
28 self.api_client.has_credential_source()
29 }
30}