Skip to main content

domain_check_lib/
lib.rs

1//! # Domain Check Library
2//!
3//! A fast, robust library for checking domain availability using RDAP and WHOIS protocols.
4//!
5//! This library provides both high-level and low-level APIs for domain availability checking,
6//! with support for concurrent processing, multiple protocols, and comprehensive error handling.
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use domain_check_lib::{DomainChecker, CheckConfig};
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
15//!     let checker = DomainChecker::new();
16//!     let result = checker.check_domain("example.com").await?;
17//!     
18//!     println!("Domain: {} - Available: {:?}", result.domain, result.available);
19//!     Ok(())
20//! }
21//! ```
22//!
23//! ## Features
24//!
25//! - **RDAP Protocol**: Modern registration data access protocol
26//! - **WHOIS Fallback**: Automatic fallback when RDAP is unavailable
27//! - **Concurrent Processing**: Efficient parallel domain checking
28//! - **Bootstrap Registry**: Dynamic RDAP endpoint discovery
29//! - **Configurable**: Extensive configuration options
30
31// Re-export main public API types and functions
32// This makes them available as domain_check_lib::TypeName
33pub use checker::DomainChecker;
34pub use config::{load_env_config, ConfigManager, FileConfig, GenerationConfig};
35pub use error::DomainCheckError;
36pub use protocols::registry::{
37    get_all_known_tlds, get_available_presets, get_preset_tlds, get_preset_tlds_with_custom,
38    get_whois_server, initialize_bootstrap,
39};
40pub use types::{CheckConfig, CheckMethod, DomainInfo, DomainResult, OutputMode};
41pub use utils::expand_domain_inputs;
42
43// Public modules
44pub mod generate;
45
46// Re-export generation types for convenience
47pub use generate::{apply_affixes, estimate_pattern_count, expand_pattern, generate_names};
48pub use types::{GenerateConfig, GenerationResult};
49
50// Internal modules - these are not part of the public API
51mod checker;
52mod concurrent;
53mod config;
54mod error;
55mod protocols;
56mod types;
57mod utils;
58
59// Type alias for convenience
60pub type Result<T> = std::result::Result<T, DomainCheckError>;
61
62// Library version and metadata
63pub const VERSION: &str = env!("CARGO_PKG_VERSION");
64pub const AUTHOR: &str = env!("CARGO_PKG_AUTHORS");
65
66/// Initialize the library with default settings.
67///
68/// This function can be called to set up global state like logging,
69/// registry caches, etc. It's optional - the library will work without it.
70pub fn init() {
71    // Future: Initialize global caches, logging, etc.
72    // For now, this is a no-op but provides future extensibility
73}
74
75/// Get library information for debugging or display purposes.
76pub fn info() -> LibraryInfo {
77    LibraryInfo {
78        version: VERSION,
79        author: AUTHOR,
80        features: get_enabled_features(),
81    }
82}
83
84/// Information about the library build and features
85#[derive(Debug, Clone)]
86pub struct LibraryInfo {
87    pub version: &'static str,
88    pub author: &'static str,
89    pub features: Vec<&'static str>,
90}
91
92/// Get list of enabled features at compile time
93#[allow(clippy::vec_init_then_push)] // ← Add this line
94fn get_enabled_features() -> Vec<&'static str> {
95    let mut features = Vec::new();
96
97    #[cfg(feature = "rdap")]
98    features.push("rdap");
99
100    #[cfg(feature = "whois")]
101    features.push("whois");
102
103    #[cfg(feature = "bootstrap")]
104    features.push("bootstrap");
105
106    #[cfg(feature = "debug")]
107    features.push("debug");
108
109    features
110}