Crate hcaptcha[][src]

Hcaptcha

Build the request and verify

Build the request using the Hcaptcha builder.

Execute [verify] on the request once to execute.

Following a successful response the additional response in HcaptchaResponse can be requested from the [Hcapthca] struct.

Examples

use hcaptcha::Hcaptcha;
use std::net::{IpAddr, Ipv4Addr};

#[tokio::main]
async fn main() {
    let remote_ip = IpAddr::V4(Ipv4Addr::new(192, 168, 0, 17));

    let res = Hcaptcha::new("your_private_key", "user_response")
                .set_user_ip(&remote_ip)
                .verify()
                .await;

    if res.is_ok() {
        println!("Success");
    } else {
        println!("Failure");
    }
}

Feature Flags

  • logging: Enbles debug logs for the request and response structs.

Re-exports

pub use error::HcaptchaError;

Modules

error

Error module for hcaptcha Provides an error type to capture error codes from the hcaptcha api and errors output from crates used by the library.

Structs

Hcaptcha

Builder to compose a request for the hcaptcha validation endpoint, verify the request and read the additional information that may be supplied in the response.