1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::time::Duration;
use crate::validators::prelude::*;
use crate::{Target, WhoIsError, WhoIsServerValue};
const DEFAULT_FOLLOW: u16 = 2;
const DEFAULT_TIMEOUT: u64 = 60000;
#[derive(Debug, Clone)]
pub struct WhoIsLookupOptions {
pub target: Target,
pub server: Option<WhoIsServerValue>,
pub follow: u16,
pub timeout: Option<Duration>,
}
impl WhoIsLookupOptions {
#[inline]
pub fn from_target(target: Target) -> WhoIsLookupOptions {
WhoIsLookupOptions {
target,
server: None,
follow: DEFAULT_FOLLOW,
timeout: Some(Duration::from_millis(DEFAULT_TIMEOUT)),
}
}
#[inline]
pub fn from_str<S: AsRef<str>>(s: S) -> Result<WhoIsLookupOptions, WhoIsError> {
Ok(Self::from_target(Target::parse_str(s)?))
}
#[inline]
pub fn from_string<S: Into<String>>(s: S) -> Result<WhoIsLookupOptions, WhoIsError> {
Ok(Self::from_target(Target::parse_string(s)?))
}
}