domain-status 0.2.1

Concurrent URL status checker that captures comprehensive metadata in SQLite.
Documentation
#![recursion_limit = "256"]
// Pedantic clippy: only allow genuinely noise-level lints.
// items_after_statements: function-scoped `static LazyLock` is idiomatic Rust.
// struct_field_names: _us/_ms suffixes on timing fields are intentional clarity.
// similar_names: geoip_cc_b/geoip_cn_b etc are clear in context.
// needless_continue: used intentionally for clarity in drain loop.
#![allow(
    clippy::items_after_statements,
    clippy::struct_field_names,
    clippy::similar_names,
    clippy::needless_continue
)]
//! `domain_status` library: core URL scanning functionality
//!
//! This library provides high-level APIs for scanning URLs and capturing comprehensive
//! metadata including HTTP status, TLS certificates, DNS information, technology
//! fingerprints, and more.
//!
//! # Example
//!
//! ```no_run
//! use domain_status::{Config, run_scan};
//! use tokio;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = Config {
//!     file: std::path::PathBuf::from("urls.txt"),
//!     max_concurrency: 50,
//!     rate_limit_rps: 20,
//!     ..Default::default()
//! };
//!
//! let report = run_scan(config).await?;
//! println!("Processed {} URLs: {} succeeded, {} failed",
//!          report.total_urls, report.successful, report.failed);
//! # Ok(())
//! # }
//! ```
//!
//! # Requirements
//!
//! This library requires a Tokio runtime. Use `#[tokio::main]` in your application
//! or ensure you're calling library functions within an async context.
//!
//! # Stability and API guarantees
//!
//! - **Stable:** Exit codes (see project docs), [`Config`] validation rules, and public function signatures and types follow `SemVer`.
//! - **Primary embed API:** [`Config`] + [`run_scan`] + [`export`] + [`summary`] (+ typed errors / exit codes).
//! - **Advanced (may narrow further in 0.x):** [`whois`], [`GeoIpService`], [`cli`].
//! - **Crate-private:** initialization helpers, most config constants/header names, fetch/fingerprint/storage internals.
//! - **May change:** Exact wording of error messages, the internal error chain and downcasting behavior, and default config values (e.g. timeouts, limits) may change in patch or minor releases to improve safety or diagnostics.

#![deny(
    clippy::enum_glob_use,
    missing_debug_implementations,
    missing_docs,
    unsafe_code
)]

mod app;
mod cache_paths;
pub mod cli;
mod clock;
pub mod config;
mod const_str;
mod dns;
mod domain;
mod error_handling;
pub mod exit_codes;
pub mod export;
mod fetch;
mod fingerprint;
mod geoip;
pub(crate) mod initialization;
mod models;
mod parse;
mod run;
mod runtime_metrics;
mod security;
mod sql;
mod status_server;
mod storage;
pub mod summary;
mod tls;
mod user_agent;
mod utils;
pub mod whois;

// Re-export public API
pub use cli::evaluate_exit_code;
pub use config::{Config, FailOn, LogFormat, LogLevel, ScanDependencyOverrides};
pub use error_handling::{
    log_error_chain, DatabaseError, ErrorExt, FingerprintError, MigrationError, ReqwestErrorExt,
    RunScanError, StartupError,
};
// Reachable from `StartupError::StatusServer(_)` — surface the type so callers
// matching on that variant can name it.
pub use exit_codes::{EXIT_NO_URLS_PCT, EXIT_POLICY_FAILURE, EXIT_RUNTIME_ERROR, EXIT_SUCCESS};
pub use geoip::GeoIpService;
pub use models::{KeyAlgorithm, TlsVersion};
pub use run::{run_scan, ScanReport};
pub use status_server::StatusServerLifecycleError;
pub use storage::{
    init_db_pool_with_path, query_run_history, run_migrations, RunSummary, UrlRecord,
};
pub use summary::{format_scan_summary, query_scan_summary, ScanSummary, SummaryOptions};
// Low-level insert helpers used by the crate's own integration tests under
// `tests/`. These are NOT a stable public API — they expose internals of the
// SQLite write pipeline, with all the surface that requires (column lists,
// FK ordering, retry semantics). Gated behind the `test-utils` feature so the
// default published crate doesn't include them in its semver surface.
//
// Enable with `cargo test --features test-utils` (already part of `just test`,
// `just ci`, and the CI workflow's `--all-features` invocation).
#[cfg(feature = "test-utils")]
pub use storage::insert::url::{insert_url_record, UrlRecordInsertParams};
#[cfg(feature = "test-utils")]
pub use whois::seed_whois_cache;

pub use utils::print_io_error_hint_if_applicable;
pub use whois::{lookup_whois, WhoisResult};