whois_rust/lib.rs
1/*!
2# WHOIS Rust
3
4This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois
5
6## Usage
7
8You can make a **servers.json** file or copy one from https://github.com/hjr265/node-whois
9
10This is a simple example of **servers.json**.
11
12```json
13{
14 "org": "whois.pir.org",
15 "": "whois.ripe.net",
16 "_": {
17 "ip": {
18 "host": "whois.arin.net",
19 "query": "n + $addr\r\n"
20 }
21 }
22}
23```
24
25Then, use the `from_path` (or `from_string` if your JSON data is in-memory) associated function to create a `WhoIs` instance.
26
27```rust,ignore
28use whois_rust::WhoIs;
29
30let whois = WhoIs::from_path("/path/to/servers.json").unwrap();
31```
32
33Use the `lookup` method and input a `WhoIsLookupOptions` instance to lookup a domain or an IP.
34
35```rust,ignore
36use whois_rust::{WhoIs, WhoIsLookupOptions};
37
38let whois = WhoIs::from_path("/path/to/servers.json").unwrap();
39
40let result: String = whois.lookup(WhoIsLookupOptions::from_string("magiclen.org").unwrap()).unwrap();
41```
42
43## Asynchronous APIs
44
45You may want to use async APIs with your async runtime. This crate supports `tokio`, currently.
46
47```toml
48[dependencies.whois-rust]
49version = "*"
50features = ["tokio"]
51```
52
53After enabling the async feature, the `from_path_async` function and the `lookup_async` function are available.
54
55## Testing
56
57```bash
58# git clone --recurse-submodules git://github.com/magiclen/whois-rust.git
59
60git clone git://github.com/magiclen/whois-rust.git
61
62cd whois-rust
63
64git submodule init
65git submodule update --recursive
66
67cargo test
68```
69*/
70
71#[cfg(feature = "tokio")]
72pub extern crate tokio;
73
74mod target;
75mod who_is;
76mod who_is_error;
77mod who_is_host;
78mod who_is_lookup_options;
79mod who_is_server_value;
80
81pub use target::*;
82pub use who_is::*;
83pub use who_is_error::*;
84pub use who_is_host::*;
85pub use who_is_lookup_options::*;
86pub use who_is_server_value::*;