Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Synchronous Anti-Captcha client.

Implementations§

Source§

impl Client

Source

pub fn new(api_key: impl Into<String>) -> Result<Self>

Creates a client and the runtime that drives it.

Fails only when the Tokio runtime cannot be started.

Source

pub fn from_async(inner: Client) -> Result<Self>

Wraps an already configured async client.

Source

pub fn inner(&self) -> &Client

The async client underneath, for the settings builders.

Source

pub fn set_api_key(&mut self, api_key: impl Into<String>)

Source

pub fn configure(&mut self, change: impl FnOnce(Client) -> Client)

Applies a builder method of the async client, e.g. client.configure(|c| c.with_soft_id(1187).quiet()).

Source

pub fn file_to_base64(path: impl AsRef<Path>) -> Result<String>

Reads a file and encodes it in base64.

Source

pub fn to_base64(bytes: impl AsRef<[u8]>) -> String

Encodes bytes in base64.

Source

pub fn get_balance(&self) -> Result<f64>

Account balance in US dollars.

Source

pub fn get_credits_balance(&self) -> Result<f64>

Number of prepaid captcha credits on the account.

Source

pub fn json_request(&self, method: &str, payload: Value) -> Result<Value>

Calls any API method with your own payload.

Source

pub fn create_task(&self, task: Value) -> Result<i64>

Submits a task and returns its id.

Source

pub fn wait_for_result(&self, task_id: i64) -> Result<Solution>

Polls until the task is solved or the waiting limit runs out.

Source

pub fn solve_task(&self, task: Value) -> Result<Solution>

Sends a task type this library does not wrap yet.

Source

pub fn solve_image( &self, base64_body: &str, settings: &ImageSettings, ) -> Result<Solution>

Source

pub fn solve_image_to_coordinates( &self, base64_body: &str, settings: &ImageToCoordinates, ) -> Result<Solution>

Source

pub fn solve_recaptcha_v2(&self, settings: &RecaptchaV2) -> Result<Solution>

Source

pub fn solve_recaptcha_v2_proxy_on( &self, settings: &RecaptchaV2, ) -> Result<Solution>

Source

pub fn solve_recaptcha_v3(&self, settings: &RecaptchaV3) -> Result<Solution>

Source

pub fn solve_hcaptcha(&self, settings: &HCaptcha) -> Result<Solution>

Source

pub fn solve_hcaptcha_proxy_on(&self, settings: &HCaptcha) -> Result<Solution>

Source

pub fn solve_funcaptcha(&self, settings: &FunCaptcha) -> Result<Solution>

Source

pub fn solve_funcaptcha_proxy_on( &self, settings: &FunCaptcha, ) -> Result<Solution>

Source

pub fn solve_geetest(&self, settings: &GeeTest) -> Result<Solution>

Source

pub fn solve_geetest_proxy_on(&self, settings: &GeeTest) -> Result<Solution>

Source

pub fn solve_turnstile(&self, settings: &Turnstile) -> Result<Solution>

Source

pub fn solve_turnstile_proxy_on(&self, settings: &Turnstile) -> Result<Solution>

Source

pub fn solve_prosopo(&self, settings: &Prosopo) -> Result<Solution>

Source

pub fn solve_prosopo_proxy_on(&self, settings: &Prosopo) -> Result<Solution>

Source

pub fn solve_friendly_captcha( &self, settings: &FriendlyCaptcha, ) -> Result<Solution>

Source

pub fn solve_friendly_captcha_proxy_on( &self, settings: &FriendlyCaptcha, ) -> Result<Solution>

Source

pub fn solve_altcha(&self, settings: &Altcha) -> Result<Solution>

Source

pub fn solve_altcha_proxy_on(&self, settings: &Altcha) -> Result<Solution>

Source

pub fn solve_amazon(&self, settings: &Amazon) -> Result<Solution>

Source

pub fn solve_amazon_proxy_on(&self, settings: &Amazon) -> Result<Solution>

Source

pub fn solve_antigate(&self, settings: &AntiGate) -> Result<Solution>

Source

pub fn report_incorrect_image_captcha(&self, task_id: i64) -> Result<()>

Source

pub fn report_incorrect_recaptcha(&self, task_id: i64) -> Result<()>

Source

pub fn report_correct_recaptcha(&self, task_id: i64) -> Result<()>

Source

pub fn report_incorrect_hcaptcha(&self, task_id: i64) -> Result<()>

Source

pub fn solve_image_file( &self, path: impl AsRef<Path>, settings: &ImageSettings, ) -> Result<Solution>

Solves an image captcha read from a file.

Source

pub fn solve_image_to_coordinates_file( &self, path: impl AsRef<Path>, settings: &ImageToCoordinates, ) -> Result<Solution>

Solves an image-to-coordinates captcha read from a file.

Source

pub fn set_max_waiting_time(&mut self, timeout: Duration)

How long to keep polling before giving up. Default 300 seconds.

Trait Implementations§

Source§

impl Debug for Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Move for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

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> 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, 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