Skip to main content

reserve_core/
lib.rs

1//! The engine behind `reserve`. Everything the tool knows how to do lives here.
2
3pub mod error;
4pub mod limit;
5pub mod lookup;
6pub mod tld;
7
8pub use error::{Error, ErrorId, ExitClass, Result};
9pub use limit::{
10    BreakerState, CAUTIOUS_LIMIT, HostLimit, Pacer, PacingLimits, PausedHost, Refusal,
11};
12pub use lookup::{
13    Attempt, AttemptOutcome, BOOTSTRAP_URL, Delegation, Engine, Finding, Freshness, Reason,
14    Registration, Server, Servers, ServiceMap, Settings, Source, SourcePolicy, Status, Tally,
15    reorders_text, shapes_letters,
16};
17pub use tld::{
18    CATALOG_VERSION, Catalog, Depth, Extension, ExtensionKind, Family, Filter, Group, LengthRule,
19    MAX_INPUT_BYTES, NormalizedName, Page, Selector, Sort, SortDirection, SortKey, Suffix,
20    SweepPlan, normalize_name, parse_name,
21};
22
23pub const VERSION: &str = env!("CARGO_PKG_VERSION");
24
25/// @docgen Registries ask bulk clients to be identifiable; operators block anonymous sweeps first.
26#[must_use]
27pub fn user_agent() -> String {
28    format!("reserve/{VERSION} (+https://reserve.devops.bd)")
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34
35    #[test]
36    fn the_user_agent_names_the_tool_and_its_version() {
37        let agent = user_agent();
38        assert!(agent.starts_with("reserve/"));
39        assert!(agent.contains(VERSION));
40    }
41}