[][src]Struct rocheck::RoCheck

pub struct RoCheck { /* fields omitted */ }

Methods

impl RoCheck[src]

pub fn new(cookie: &str) -> RoCheck[src]

Create and initialize a new RoCheck class.

let client = RoCheck::new("MySecurityToken");

pub async fn get_data<'_, '_>(
    &'_ self,
    place_id: i64,
    job_id: &'_ str
) -> Result<HashMap<String, Value>, Box<dyn Error>>
[src]

Retrieve additional data other than the IP.

let client = RoCheck::new("MySecurityToken");
let data = client.get_data(123456, "JobIdFromRequest").await?;
data.get("some-field");

pub async fn get_ip<'_, '_>(
    &'_ self,
    place_id: i64,
    job_id: &'_ str
) -> Result<String, Box<dyn Error>>
[src]

Retrieve the IP belonging to this PlaceId and JobId

let client = RoCheck::new("MySecurityToken");
let ip = client.get_ip(123456, "JobIdFromRequest").await?;

pub async fn verify_ip<'_, '_, '_>(
    &'_ self,
    place_id: i64,
    job_id: &'_ str,
    ip: &'_ str
) -> Result<bool, Box<dyn Error>>
[src]

Retrieve the IP belonging to this PlaceId and JobId and compare it to the inputted IP.

let my_ip = "127.0.0.1";
let client = RoCheck::new("MySecurityToken");
		
let ip_verified = client.verify_ip(123456, "JobIdFromRequest", my_ip).await?;

pub async fn validate_ip<'_, '_, '_>(
    &'_ self,
    place_id: i64,
    job_id: &'_ str,
    ip: &'_ str
) -> bool
[src]

This function is equivalent to verify_ip, however it will always return true/false. If this function fails, it will return false. This is useful for cases where you don't need to know why it failed (e.g place_id doesn't exist, or job id doesn't exist) without adding boilerplate.

let my_ip = "127.0.0.1";
let client = RoCheck::new("MySecurityToken");

let ip_verified = client.validate_ip(123456i64, "JobIdFromRequest", my_ip).await;

Auto Trait Implementations

impl !RefUnwindSafe for RoCheck

impl Send for RoCheck

impl Sync for RoCheck

impl Unpin for RoCheck

impl !UnwindSafe for RoCheck

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, 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.