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: 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)
}
}