use std::ops::Deref;
use crate::models::LookupResponse;
#[derive(Debug, Clone, PartialEq)]
pub struct Lookup {
pub is_bogon: bool,
pub answer: LookupResponse,
}
impl Lookup {
pub(crate) fn served(answer: LookupResponse) -> Self {
Self { is_bogon: answer.is_bogon.unwrap_or(false), answer }
}
}
impl Deref for Lookup {
type Target = LookupResponse;
fn deref(&self) -> &LookupResponse {
&self.answer
}
}
impl Lookup {
pub fn is_hosting_or_false(&self) -> bool {
self.is_hosting.unwrap_or(false)
}
pub fn is_relay_or_false(&self) -> bool {
self.is_relay.unwrap_or(false)
}
pub fn is_tor_or_false(&self) -> bool {
self.is_tor.unwrap_or(false)
}
pub fn is_cdn_or_false(&self) -> bool {
self.is_cdn.unwrap_or(false)
}
pub fn is_resproxy_or_false(&self) -> bool {
self.is_resproxy.unwrap_or(false)
}
pub fn is_dcproxy_or_false(&self) -> bool {
self.is_dcproxy.unwrap_or(false)
}
pub fn is_mobproxy_or_false(&self) -> bool {
self.is_mobproxy.unwrap_or(false)
}
pub fn is_pubproxy_or_false(&self) -> bool {
self.is_pubproxy.unwrap_or(false)
}
pub fn is_anycast_or_false(&self) -> bool {
self.is_anycast.unwrap_or(false)
}
pub fn is_carrier_or_false(&self) -> bool {
self.is_carrier.unwrap_or(false)
}
pub fn is_satellite_or_false(&self) -> bool {
self.is_satellite.unwrap_or(false)
}
pub fn is_ssh_or_false(&self) -> bool {
self.is_ssh.unwrap_or(false)
}
pub fn is_smtp_or_false(&self) -> bool {
self.is_smtp.unwrap_or(false)
}
pub fn is_web_or_false(&self) -> bool {
self.is_web.unwrap_or(false)
}
pub fn is_dns_resolver_or_false(&self) -> bool {
self.is_dns_resolver.unwrap_or(false)
}
pub fn is_bittorrent_or_false(&self) -> bool {
self.is_bittorrent.unwrap_or(false)
}
}