Struct hcaptcha::HcaptchaRequest
source · [−]pub struct HcaptchaRequest { /* private fields */ }Expand description
Capture the required and optional data for a call to the hcaptcha API
Implementations
sourceimpl HcaptchaRequest
impl HcaptchaRequest
sourcepub fn new(
secret: &str,
captcha: HcaptchaCaptcha
) -> Result<HcaptchaRequest, HcaptchaError>
pub fn new(
secret: &str,
captcha: HcaptchaCaptcha
) -> Result<HcaptchaRequest, HcaptchaError>
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.
sourcepub fn new_from_response(
secret: &str,
response: &str
) -> Result<HcaptchaRequest, HcaptchaError>
pub fn new_from_response(
secret: &str,
response: &str
) -> Result<HcaptchaRequest, HcaptchaError>
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.
sourcepub fn set_remoteip(self, remoteip: &str) -> Result<Self, HcaptchaError>
pub fn set_remoteip(self, remoteip: &str) -> Result<Self, HcaptchaError>
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.
sourcepub fn set_sitekey(self, sitekey: &str) -> Result<Self, HcaptchaError>
pub fn set_sitekey(self, sitekey: &str) -> Result<Self, HcaptchaError>
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
sourceimpl Debug for HcaptchaRequest
impl Debug for HcaptchaRequest
sourceimpl Default for HcaptchaRequest
impl Default for HcaptchaRequest
sourcefn default() -> HcaptchaRequest
fn default() -> HcaptchaRequest
Returns the “default value” for a type. Read more
sourceimpl Serialize for HcaptchaRequest
impl Serialize for HcaptchaRequest
Auto Trait Implementations
impl RefUnwindSafe for HcaptchaRequest
impl Send for HcaptchaRequest
impl Sync for HcaptchaRequest
impl Unpin for HcaptchaRequest
impl UnwindSafe for HcaptchaRequest
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more