pub struct ClientBuilder { /* private fields */ }Expand description
Fluent builder for Client. Use Client::builder to construct one.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_key(self, token: impl Into<String>) -> ClientBuilder
pub fn api_key(self, token: impl Into<String>) -> ClientBuilder
Authenticate with a static OpenApp API key. The base URL is derived from the
token unless overridden via ClientBuilder::base_url.
Sourcepub fn token_provider(self, provider: Arc<dyn TokenProvider>) -> ClientBuilder
pub fn token_provider(self, provider: Arc<dyn TokenProvider>) -> ClientBuilder
Use a custom TokenProvider.
Sourcepub fn base_url(self, url: impl AsRef<str>) -> Result<ClientBuilder, SdkError>
pub fn base_url(self, url: impl AsRef<str>) -> Result<ClientBuilder, SdkError>
Override the API base URL. Rarely needed — an OpenApp API key embeds its base
URL, so calling ClientBuilder::api_key usually suffices.
Sourcepub fn user_agent(self, ua: impl Into<String>) -> ClientBuilder
pub fn user_agent(self, ua: impl Into<String>) -> ClientBuilder
Set the User-Agent header. Defaults to "openapp-sdk/<version>".
Sourcepub fn default_timeout(self, timeout: Duration) -> ClientBuilder
pub fn default_timeout(self, timeout: Duration) -> ClientBuilder
Set the default per-request timeout.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> ClientBuilder
pub fn retry_policy(self, policy: RetryPolicy) -> ClientBuilder
Override the default retry policy.
Sourcepub fn interceptor(
self,
interceptor: impl Interceptor + 'static,
) -> ClientBuilder
pub fn interceptor( self, interceptor: impl Interceptor + 'static, ) -> ClientBuilder
Add an Interceptor. Interceptors run in insertion order.
Sourcepub fn reqwest_client(self, client: Client) -> ClientBuilder
pub fn reqwest_client(self, client: Client) -> ClientBuilder
Supply a pre-built reqwest::Client (e.g. with a custom TLS root bundle).
Sourcepub fn build(self) -> Result<Client, SdkError>
pub fn build(self) -> Result<Client, SdkError>
Finalize the builder into a Client.
§Errors
Returns SdkError::Config when no authentication or base URL has been
configured, or when a token-provider error has been deferred from
ClientBuilder::api_key.
§Panics
Panics if the default reqwest::Client cannot be built. In practice this
only happens if the host is missing TLS roots, which is treated as a
programmer error rather than a recoverable condition.