Skip to main content

ClientConfig

Struct ClientConfig 

Source
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: String

Base 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: String

Base URL for synchronous task operations.

§timeout: Duration

Timeout 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: Duration

Timeout 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: PollingConfig

Polling 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: String

User agent sent with every request.

Implementations§

Source§

impl ClientConfig

Source

pub fn builder() -> ClientConfigBuilder

Create an instance of ClientConfig using the builder syntax

Source§

impl ClientConfig

Source

pub fn with_client_key(self, value: impl Into<String>) -> Self

Sets the client key instead of loading it from the default environment variable.

Source

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.

Source

pub const fn with_timeout(self, value: Duration) -> Self

Sets the timeout for asynchronous endpoints and balance queries.

Source

pub const fn with_sync_timeout(self, value: Duration) -> Self

Sets the timeout for the synchronous task endpoint.

Source

pub const fn with_polling(self, value: PollingConfig) -> Self

Sets asynchronous task polling options.

Source

pub const fn with_app_id(self, value: i32) -> Self

Sets the optional developer application identifier.

Source

pub fn with_proxy(self, value: impl Into<String>) -> Self

Sets the proxy used by the SDK HTTP client.

Source

pub fn with_user_agent(self, value: impl Into<String>) -> Self

Overrides the user agent sent with every request.

Trait Implementations§

Source§

impl Clone for ClientConfig

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 Debug for ClientConfig

Source§

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

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

impl Default for ClientConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ClientConfig

Source§

impl From<&str> for ClientConfig

Source§

fn from(client_key: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ClientConfig

Source§

fn from(client_key: String) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ClientConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ClientConfig

Auto Trait Implementations§

Blanket Implementations§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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