dehashed_rs/
lib.rs

1//! # dehashed-rs
2//!
3//! This crate provides a SDK for the API of [dehashed](https://dehashed.com/).
4//!
5//! Please note, that this project is not an official implementation from dehashed.
6//!
7//! ## Usage
8//!
9//!
10//! ```rust
11//! use dehashed_rs::*;
12//! # tokio_test::block_on(async {
13//! let email = "test@example.com".to_string();
14//! let api_key = "<api_key>".to_string();
15//!
16//! // Create an api instance
17//! let api = DehashedApi::new(api_key).unwrap();
18//!
19//! // Query for the domain example.com
20//! if let Ok(res) = api
21//!     .search(Query::Domain(SearchType::Simple("example.com".to_string())))
22//!     .await
23//! {
24//!     println!("{res:?}");
25//! }
26//! # })
27//! ```
28//!
29//! or if you enable the `tokio` feature, you can utilize the scheduler to abstract
30//! away the need to manage get past the rate limit:
31//!
32//! ```rust
33//! use dehashed_rs::*;
34//! use tokio::sync::oneshot;
35//!# tokio_test::block_on(async {
36//! let email = "test@example.com".to_string();
37//! let api_key = "<api_key>".to_string();
38//!
39//! // Create an api instance
40//! let api = DehashedApi::new(api_key).unwrap();
41//! // Create the scheduler
42//! let scheduler = api.start_scheduler();
43//!
44//! let tx = scheduler.retrieve_sender();
45//!
46//! let (ret_tx, ret_rx) = oneshot::channel();
47//!
48//! // Schedule a query for the email "test@example.com"
49//! tx.send(ScheduledRequest::new(
50//!     Query::Email(SearchType::Simple("test@example.com".to_string())),
51//!     ret_tx,
52//! ))
53//! .await
54//! .unwrap();
55//!
56//! // Retrieve the result
57//! if let Ok(res) = ret_rx.await {
58//!     println!("{res:?}");
59//! }
60//! # })
61//! ```
62//!
63//! If you need type definitions for utoipa, there available under the feature flag `utoipa`.
64
65#![warn(missing_docs)]
66
67pub use api::*;
68pub use error::DehashedError;
69#[cfg(feature = "tokio")]
70pub use scheduler::*;
71
72mod api;
73mod error;
74pub(crate) mod res;
75#[cfg(feature = "tokio")]
76mod scheduler;
77#[cfg(test)]
78mod tests;