Struct hcaptcha::Hcaptcha [−][src]
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
Auto Trait Implementations
impl RefUnwindSafe for Hcaptcha
impl Send for Hcaptcha
impl Sync for Hcaptcha
impl Unpin for Hcaptcha
impl UnwindSafe for Hcaptcha
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,