Struct DomainChecker

Source
pub struct DomainChecker { /* private fields */ }
Expand description

Main domain checker that coordinates availability checking operations.

The DomainChecker handles all aspects of domain checking including:

  • Protocol selection (RDAP vs WHOIS)
  • Concurrent processing
  • Error handling and retries
  • Result formatting

§Example

use domain_check_lib::{DomainChecker, CheckConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let checker = DomainChecker::new();
    let result = checker.check_domain("example.com").await?;
    println!("Available: {:?}", result.available);
    Ok(())
}

Implementations§

Source§

impl DomainChecker

Source

pub fn new() -> Self

Create a new domain checker with default configuration.

Default settings:

  • Concurrency: 10
  • Timeout: 5 seconds
  • WHOIS fallback: enabled
  • Bootstrap: disabled
  • Detailed info: disabled
Source

pub fn with_config(config: CheckConfig) -> Self

Create a new domain checker with custom configuration.

§Example
use domain_check_lib::{DomainChecker, CheckConfig};
use std::time::Duration;

let config = CheckConfig::default()
    .with_concurrency(20)
    .with_timeout(Duration::from_secs(10))
    .with_detailed_info(true);
     
let checker = DomainChecker::with_config(config);
Source

pub async fn check_domain( &self, domain: &str, ) -> Result<DomainResult, DomainCheckError>

Check availability of a single domain.

This is the most basic operation - check one domain and return the result. The domain should be a fully qualified domain name (e.g., “example.com”).

The checking process:

  1. Validates the domain format
  2. Attempts RDAP check first (modern protocol)
  3. Falls back to WHOIS if RDAP fails and fallback is enabled
  4. Returns comprehensive result with timing and method information
§Arguments
  • domain - The domain name to check (e.g., “example.com”)
§Returns

A DomainResult containing availability status and optional details.

§Errors

Returns DomainCheckError if:

  • The domain name is invalid
  • Network errors occur
  • All checking methods fail
Source

pub async fn check_domains( &self, domains: &[String], ) -> Result<Vec<DomainResult>, DomainCheckError>

Check availability of multiple domains concurrently.

This method processes all domains in parallel according to the concurrency setting, then returns all results at once.

§Arguments
  • domains - Slice of domain names to check
§Returns

Vector of DomainResult in the same order as input domains.

§Example
use domain_check_lib::DomainChecker;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let checker = DomainChecker::new();
    let domains = vec!["example.com".to_string(), "google.com".to_string(), "test.org".to_string()];
    let results = checker.check_domains(&domains).await?;
     
    for result in results {
        println!("{}: {:?}", result.domain, result.available);
    }
    Ok(())
}
Source

pub fn check_domains_stream( &self, domains: &[String], ) -> Pin<Box<dyn Stream<Item = Result<DomainResult, DomainCheckError>> + Send + '_>>

Check domains and return results as a stream.

This method yields results as they become available, which is useful for real-time updates or when processing large numbers of domains. Results are returned in the order they complete, not input order.

§Arguments
  • domains - Slice of domain names to check
§Returns

A stream that yields DomainResult items as they complete.

§Example
use domain_check_lib::DomainChecker;
use futures::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let checker = DomainChecker::new();
    let domains = vec!["example.com".to_string(), "google.com".to_string()];
     
    let mut stream = checker.check_domains_stream(&domains);
    while let Some(result) = stream.next().await {
        match result {
            Ok(domain_result) => println!("✓ {}: {:?}", domain_result.domain, domain_result.available),
            Err(e) => println!("✗ Error: {}", e),
        }
    }
    Ok(())
}
Source

pub async fn check_domains_from_file( &self, file_path: &str, ) -> Result<Vec<DomainResult>, DomainCheckError>

Read domain names from a file and check their availability.

The file should contain one domain name per line. Empty lines and lines starting with ‘#’ are ignored as comments.

§Arguments
  • file_path - Path to the file containing domain names
§Returns

Vector of DomainResult for all valid domains in the file.

§Errors

Returns DomainCheckError if:

  • The file cannot be read
  • The file contains too many domains (over limit)
  • No valid domains are found in the file
Source

pub fn config(&self) -> &CheckConfig

Get the current configuration for this checker.

Source

pub fn set_config(&mut self, config: CheckConfig)

Update the configuration for this checker.

This allows modifying settings like concurrency or timeout after the checker has been created. Note that this will recreate the internal protocol clients with the new settings.

Trait Implementations§

Source§

impl Clone for DomainChecker

Source§

fn clone(&self) -> DomainChecker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DomainChecker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,