reserve-core 0.2.0

Core lookup, catalog, and rate-limiting engine behind the reserve domain finder
Documentation
//! The engine behind `reserve`. Everything the tool knows how to do lives here.

pub mod error;
pub mod limit;
pub mod lookup;
pub mod tld;

pub use error::{Error, ErrorId, ExitClass, Result};
pub use limit::{BreakerState, HostLimit, Pacer, PacingLimits, PausedHost, Refusal};
pub use lookup::{
    BOOTSTRAP_URL, Delegation, Engine, Finding, Freshness, Reason, Registration, Server, Servers,
    ServiceMap, Settings, Source, SourcePolicy, Status, Tally,
};
pub use tld::{
    CATALOG_VERSION, Catalog, Depth, Extension, ExtensionKind, Family, Filter, Group, LengthRule,
    NormalizedName, Page, Selector, Sort, SortDirection, SortKey, Suffix, SweepPlan,
    normalize_name, parse_name,
};

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// @docgen Registries ask bulk clients to be identifiable; operators block anonymous sweeps first.
#[must_use]
pub fn user_agent() -> String {
    format!("reserve/{VERSION} (+https://reserve.devops.bd)")
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn the_user_agent_names_the_tool_and_its_version() {
        let agent = user_agent();
        assert!(agent.starts_with("reserve/"));
        assert!(agent.contains(VERSION));
    }
}