#[cfg(any(feature = "blocking", feature = "async"))]
use std::sync::Arc;
#[cfg(any(feature = "blocking", feature = "async"))]
use crate::detect::DetectionEngine;
#[cfg(any(feature = "blocking", feature = "async"))]
use crate::registry::RegistryProvider;
#[cfg(all(feature = "parser", any(feature = "blocking", feature = "async")))]
use crate::parser::CompositeParser;
mod lookup;
mod plan;
#[cfg(any(feature = "blocking", feature = "async"))]
mod checker;
#[cfg(feature = "async")]
mod asynchronous;
#[cfg(feature = "blocking")]
mod blocking;
pub use lookup::{Explanation, Lookup};
pub use plan::{Plan, Preference, ReferralPolicy};
#[cfg(any(feature = "blocking", feature = "async"))]
pub use checker::{CheckReport, DEFAULT_POPULAR_TLDS};
#[cfg(feature = "async")]
pub use asynchronous::{AsyncWhoisClient, AsyncWhoisClientBuilder, DEFAULT_CONCURRENCY};
#[cfg(feature = "async")]
pub use checker::AsyncChecker;
#[cfg(feature = "blocking")]
pub use blocking::{WhoisClient, WhoisClientBuilder};
#[cfg(feature = "blocking")]
pub use checker::Checker;
#[cfg(any(feature = "blocking", feature = "async"))]
#[derive(Debug, Clone)]
pub(crate) struct Parts {
pub registry: Arc<dyn RegistryProvider>,
pub engine: Arc<DetectionEngine>,
#[cfg(feature = "parser")]
pub parser: Arc<CompositeParser>,
pub preference: Preference,
pub referrals: ReferralPolicy,
}
#[cfg(any(feature = "blocking", feature = "async"))]
impl Parts {
pub(crate) fn new(
registry: Option<Arc<dyn RegistryProvider>>,
engine: Option<Arc<DetectionEngine>>,
preference: Preference,
referrals: ReferralPolicy,
) -> Self {
Parts {
registry: registry.unwrap_or_else(crate::registry::default_provider),
engine: engine.unwrap_or_else(|| Arc::new(DetectionEngine::standard())),
#[cfg(feature = "parser")]
parser: Arc::new(CompositeParser::standard()),
preference,
referrals,
}
}
#[cfg(feature = "parser")]
pub(crate) fn with_parser(mut self, parser: Option<Arc<CompositeParser>>) -> Self {
if let Some(parser) = parser {
self.parser = parser;
}
self
}
}