Crates.io | pulsesecurity |
lib.rs | pulsesecurity |
version | 0.1.3 |
source | src |
created_at | 2024-08-02 19:49:56.363265 |
updated_at | 2024-08-14 19:41:00.075222 |
description | Pulse Security SDK |
homepage | https://www.pulsesecurity.org |
repository | https://github.com/pulsesec/pulse-sdk-rust |
max_upload_size | |
id | 1323635 |
size | 10,766 |
cargo add pulsesecurity
pulsesecurity = "0.1.2"
use pulsesecurity::{Pulse, PulseError};
#[tokio::main]
async fn main() {
let pulse = Pulse::new("SITE_KEY".to_string(), "SECRET_KEY".to_string());
let token = "REQUEST_TOKEN".to_string();
match pulse.classify(token).await {
Ok(is_bot) => {
println!("Result: {}", is_bot);
}
Err(err) => match err {
PulseError::TokenNotFoundError(_) => {
println!("Token not found");
}
PulseError::TokenUsedError(_) => {
println!("Token already used");
}
PulseError::TokenExpiredError(_) => {
println!("Token expired");
}
_ => {
println!("Unknown error")
}
},
}
}