pub struct HcaptchaRequest { /* private fields */ }
Expand description

Capture the required and optional data for a call to the hcaptcha API

Implementations

Create a new HcaptchaRequest

Input

The Hcaptcha API has two mandatory parameters: secret: The client’s secret key for authentication captcha: HcaptchaCaptcha (including response token)

Output

HcaptchaRequest is returned if the input strings are valid. HcaptchaError is returned if the validation fails.

Example
    use hcaptcha::HcaptchaRequest;
    let secret = get_your_secret();     // your secret key
    let captcha = get_captcha();        // captcha with response token

    let request = HcaptchaRequest::new(&secret, captcha)?;
Logging

If the tracing feature is enabled a debug level span is set for the method. The secret field will not be logged.

Create a new HcaptchaRequest from only the response string

Input

The Hcaptcha API has two mandatory parameters: secret: The client’s secret key for authentication response: The response code to validate

Output

HcaptchaRequest is returned if the inputs are valid. HcaptchaError is returned if the validation fails.

Example
    use hcaptcha::HcaptchaRequest;
    let secret = get_your_secret();     // your secret key
    let response = get_response();    // Hcaptcha client response

    let request = HcaptchaRequest::new_from_response(&secret, &response)?;
Logging

If the tracing feature is enabled a debug level span is set for the method. The secret field will not be logged.

Specify the optional ip address value

Update client IP address.

Example
    use hcaptcha::HcaptchaRequest;
    let secret = get_your_secret();         // your secret key
    let response = get_response();          // user's response token
    let remoteip = get_remoteip_address();    // user's ip address

    let request = HcaptchaRequest::new_from_response(&secret, &response)?
        .set_remoteip(&remoteip)?;

#Logging

If the trace feature is enabled a debug level span is set for the method. The secret field is not logged.

Specify the optional sitekey value

Update the sitekey.

Example

Create a new request and set the sitekey field in the request.

    use hcaptcha::HcaptchaRequest;
    let secret = get_your_secret();     // your secret key
    let captcha = get_captcha();        // captcha
    let sitekey = get_your_sitekey();   // your site key

    let request = HcaptchaRequest::new(&secret, captcha)?
        .set_sitekey(&sitekey);

#Logging

If the trace feature is enabled a debug level span is created for the method. The secret field is not logged.

Trait Implementations

Formats the value using the given formatter. Read more

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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