Struct hcaptcha::Hcaptcha[][src]

pub struct Hcaptcha { /* fields omitted */ }

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.

Implementations

impl Hcaptcha[src]

pub fn new(secret: &str, response: &str) -> Hcaptcha[src]

Create a new Hcaptcha Request

Example


let secret = ""; // your secret key
let token = "";  // user's token

let hcaptcha = Hcaptcha::new(secret, token)
                .verify()
                .await;

assert!(hcaptcha.is_err());

pub fn set_user_ip(self, user_ip: &IpAddr) -> Hcaptcha[src]

Specify the optional ip address value

Example


let secret = ""; // your secret key
let token = "";  // user's token
let user_ip = IpAddr::V4(Ipv4Addr::new(192, 168, 0, 17));

let hcaptcha = Hcaptcha::new(secret, token)
                .set_user_ip(&user_ip)
                .verify()
                .await;

assert!(hcaptcha.is_err());

pub fn set_site_key(self, site_key: &str) -> Hcaptcha[src]

Specify the optional site key value

Example


let secret = ""; // your secret key
let token = "";  // user's token
let site_key = "10000000-ffff-ffff-ffff-000000000001";

let hcaptcha = Hcaptcha::new(secret, token)
                .set_site_key(site_key)
                .verify()
                .await;

assert!(hcaptcha.is_err());

pub async fn verify(&mut self) -> Result<(), HcaptchaError>[src]

Verify a hcaptcha user response

Example


let secret = "0x0000000000000000000000000000000000000000";
let token = "";
let user_ip = IpAddr::V4(Ipv4Addr::new(123, 123, 123, 123));
let site_key = "10000000-ffff-ffff-ffff-000000000001";

let response = Hcaptcha::new(secret, token)
                .set_user_ip(&user_ip)
                .set_site_key(&site_key)
                .verify()
                .await;

assert!(response.is_err());

pub fn hostname(&self) -> Option<String>[src]

Get the hostname returned in the response Option string containig the hostname of the site where the captcha was solved

pub fn timestamp(&self) -> Option<String>[src]

Get the timestamp from the response Option string containing the timestamp of the captcha (ISO format yyyy-MM-dd’T’HH:mm:ssZZ)

pub fn credit(&self) -> Option<bool>[src]

Get the credit flag Optional flag showing whether the response will be credited

pub fn score(&self) -> Option<f32>[src]

Get the score

ENTERPRISE feature: a score denoting malicious activity.

pub fn score_reason(&self) -> Option<HashSet<String>>[src]

Get the reasons for the score

ENTERPRISE feature: reason(s) for score. See BotStop.com for details.

Trait Implementations

impl Debug for Hcaptcha[src]

impl Default for Hcaptcha[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.