yeshenyue2017/web-discovery-kit/robots does not have a README file

    RobotsDiagnostic

    pub(all) struct RobotsDiagnostic {
    code : RobotsDiagnosticCode
    group_index : Int?
    line : Int?
    subject : String
    message : String
    } derive(Eq,
    Debug
    )

    One deterministic, non-fatal policy finding.

    group_index and line are absent when the source record has no group or source line provenance, such as a retained Sitemap extension record.

    RobotsDiagnosticCode

    pub(all) enum RobotsDiagnosticCode {
    EmptyUserAgent
    InvalidUserAgent
    DuplicateUserAgent
    GroupWithoutRules
    IgnoredEmptyRule
    DuplicateRule
    ConflictingRule
    InvalidPattern
    UnmatchablePattern
    InvalidSitemapUrl
    DuplicateSitemapUrl
    } derive(Eq,
    Debug
    )

    Stable category for a non-fatal robots policy inspection finding.

    The parser remains deliberately strict for malformed core records. These diagnostics additionally make it possible to inspect documents assembled by a caller, migrated from a permissive parser, or edited in memory.

    RobotsPolicyInspection

    pub(all) struct RobotsPolicyInspection {
    diagnostics : Array[RobotsDiagnostic]
    sitemap_urls : Array[String]
    group_count : Int
    rule_count : Int
    actionable_rule_count : Int
    } derive(Eq,
    Debug
    )

    Result of inspecting a parsed or caller-constructed robots policy.

    sitemap_urls contains each accepted absolute HTTP(S) Sitemap URL once, in first-seen order. diagnostics preserves document order, which makes the result suitable for stable command-line and CI reporting.

    decide

    Evaluate a URI for a crawler product token. Matching groups with the most specific product token are merged. Among equally specific matching rules, Allow deliberately wins over Disallow as required by RFC 9309.

    extract_sitemap_urls

    fn extract_sitemap_urls(document :
    RobotsDocument
    ) -> Array[String]

    Extract valid absolute HTTP(S) Sitemap URLs from core locations and retained extension records. Invalid and duplicate values are omitted; accepted URLs retain their first-seen spelling and order.

    Example

    test {
    let document = parse("Sitemap: https://example.test/map.xml\n")
    assert_eq(extract_sitemap_urls(document), ["https://example.test/map.xml"])
    }

    inspect_policy

    Inspect a robots policy without changing RFC decision behavior.

    Empty Allow and Disallow patterns are reported as ignored because the matcher deliberately gives them no effect. Duplicate and contradictory rules are reported within each group; this mirrors the scope where their precedence is directly comparable. The function never fetches a URL and never raises for policy quality issues.

    Example

    test {
    let document = parse("User-agent: bot\nDisallow: \n")
    let inspection = inspect_policy(document)
    assert_eq(inspection.actionable_rule_count, 0)
    assert_eq(inspection.diagnostics[0].code, IgnoredEmptyRule)
    }

    normalize_uri_for_match

    fn normalize_uri_for_match(uri : String) -> String raise
    DiscoveryError

    Normalize an origin-form or absolute URI into RFC 9309 comparison octets. Raw non-ASCII bytes and literal */$ are percent encoded; percent-encoded unreserved ASCII octets are decoded before matching as the RFC requires.

    parse

    Parse RFC 9309 groups/rules and retain records outside the core grammar. String inputs are encoded as UTF-8 before the same byte, line, and group limits used by parse_bytes are applied.

    parse_bytes

    Decode and parse a UTF-8 robots file. This entry point lets callers keep malformed byte input outside the normal String API and receive a checked InvalidUtf8 error instead of a panic.