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

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

Implementations§

source§

impl HcaptchaRequest

source

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.

source

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.

source

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.

source

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§

source§

impl Debug for HcaptchaRequest

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for HcaptchaRequest

source§

fn default() -> HcaptchaRequest

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

impl Serialize for HcaptchaRequest

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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