pub struct ClientConfig {
pub async_base_url: String,
pub sync_base_url: String,
pub timeout: Duration,
pub sync_timeout: Duration,
pub polling: PollingConfig,
pub app_id: Option<i32>,
pub proxy: Option<String>,
pub user_agent: String,
/* private fields */
}Expand description
Configuration shared by the asynchronous and blocking clients.
All builder settings are optional and use the same defaults as
Self::default. The client resolves the key and validates the settings
when it is created.
use std::time::Duration;
use ezcapsolver::ClientConfig;
let config = ClientConfig::builder()
.timeout(Duration::from_secs(60))
.user_agent("my-app/1.0")
.build();
assert_eq!(config.timeout, Duration::from_secs(60));
assert_eq!(config.sync_timeout, Duration::from_secs(240));Fields§
§async_base_url: StringBase URL for asynchronous task operations and balance queries.
Override it to reach a private gateway, or to point the client at a test
server. The service splits the two deployments, so they cannot share one
host — see Self::sync_base_url.
sync_base_url: StringBase URL for synchronous task operations.
timeout: DurationTimeout applied to asynchronous endpoints and balance queries.
These are millisecond-scale enqueue and lookup calls, so a short value keeps a network fault distinguishable from a slow service.
sync_timeout: DurationTimeout applied to the synchronous task endpoint.
A synchronous call blocks until the worker answers, and the service grants some task types a three-minute worker deadline. Sharing the asynchronous timeout would abort a call the service is still billing for, and a call that times out never receives the task ID it would take to recover the result.
polling: PollingConfigPolling settings for asynchronous task completion.
app_id: Option<i32>Optional developer application identifier.
proxy: Option<String>Optional proxy used by the SDK to reach the EzCaptchaSolver API.
user_agent: StringUser agent sent with every request.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn builder() -> ClientConfigBuilder
pub fn builder() -> ClientConfigBuilder
Create an instance of ClientConfig using the builder syntax
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn with_client_key(self, value: impl Into<String>) -> Self
pub fn with_client_key(self, value: impl Into<String>) -> Self
Sets the client key instead of loading it from the default environment variable.
Sourcepub fn with_base_urls(
self,
async_base_url: impl Into<String>,
sync_base_url: impl Into<String>,
) -> Self
pub fn with_base_urls( self, async_base_url: impl Into<String>, sync_base_url: impl Into<String>, ) -> Self
Points the client at different hosts, for a self-hosted deployment or a test server. An empty string keeps the current value.
Sourcepub const fn with_timeout(self, value: Duration) -> Self
pub const fn with_timeout(self, value: Duration) -> Self
Sets the timeout for asynchronous endpoints and balance queries.
Sourcepub const fn with_sync_timeout(self, value: Duration) -> Self
pub const fn with_sync_timeout(self, value: Duration) -> Self
Sets the timeout for the synchronous task endpoint.
Sourcepub const fn with_polling(self, value: PollingConfig) -> Self
pub const fn with_polling(self, value: PollingConfig) -> Self
Sets asynchronous task polling options.
Sourcepub const fn with_app_id(self, value: i32) -> Self
pub const fn with_app_id(self, value: i32) -> Self
Sets the optional developer application identifier.
Sourcepub fn with_proxy(self, value: impl Into<String>) -> Self
pub fn with_proxy(self, value: impl Into<String>) -> Self
Sets the proxy used by the SDK HTTP client.
Sourcepub fn with_user_agent(self, value: impl Into<String>) -> Self
pub fn with_user_agent(self, value: impl Into<String>) -> Self
Overrides the user agent sent with every request.