1use client::Client;
2use error::Result;
3use server::Server;
4
5use crate::error::{err, ErrorKind};
6
7mod client;
8mod dns;
9pub mod error;
10mod query;
11pub mod server;
12pub async fn from_domain<D: AsRef<str>>(domain: D) -> Result<Vec<Server>> {
15 let client = Client::new().await?;
16
17 let servers = client.dns_lookup(domain).await;
20
21 if servers.is_empty() {
22 err!(
23 ErrorKind::NotFound,
24 "Could not find any servers from the given domain"
25 )
26 }
27
28 Ok(servers)
29}
30
31#[cfg(test)]
32mod tests {
33
34 use super::*;
35
36 #[cfg_attr(feature = "runtime-async-std", async_std::test)]
37 #[cfg_attr(feature = "runtime-tokio", tokio::test)]
38 async fn test_from_domain() {
39 let servers = from_domain("gmail.com").await.unwrap();
40
41 assert_eq!(servers.len(), 3);
42 }
43}