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 error::DomainCheckError;
35pub use types::{CheckConfig, CheckMethod, DomainInfo, DomainResult, OutputMode};
36pub use utils::expand_domain_inputs;
37
38// Internal modules - these are not part of the public API
39mod checker;
40mod concurrent;
41mod error;
42mod protocols;
43mod types;
44mod utils;
45
46// Type alias for convenience
47pub type Result<T> = std::result::Result<T, DomainCheckError>;
48
49// Library version and metadata
50pub const VERSION: &str = env!("CARGO_PKG_VERSION");
51pub const AUTHOR: &str = env!("CARGO_PKG_AUTHORS");
52
53/// Initialize the library with default settings.
54///
55/// This function can be called to set up global state like logging,
56/// registry caches, etc. It's optional - the library will work without it.
57pub fn init() {
58 // Future: Initialize global caches, logging, etc.
59 // For now, this is a no-op but provides future extensibility
60}
61
62/// Get library information for debugging or display purposes.
63pub fn info() -> LibraryInfo {
64 LibraryInfo {
65 version: VERSION,
66 author: AUTHOR,
67 features: get_enabled_features(),
68 }
69}
70
71/// Information about the library build and features
72#[derive(Debug, Clone)]
73pub struct LibraryInfo {
74 pub version: &'static str,
75 pub author: &'static str,
76 pub features: Vec<&'static str>,
77}
78
79/// Get list of enabled features at compile time
80#[allow(clippy::vec_init_then_push)] // ← Add this line
81fn get_enabled_features() -> Vec<&'static str> {
82 let mut features = Vec::new();
83
84 #[cfg(feature = "rdap")]
85 features.push("rdap");
86
87 #[cfg(feature = "whois")]
88 features.push("whois");
89
90 #[cfg(feature = "bootstrap")]
91 features.push("bootstrap");
92
93 #[cfg(feature = "debug")]
94 features.push("debug");
95
96 features
97}