Skip to main content

validate_kind

Function validate_kind 

Source
pub fn validate_kind(kind: &str) -> Result<(), String>
Expand description

The one kind-format rule (typed dispatch), enforced identically at handler registration, at enqueue in every backend, and at the HTTP API.

[A-Za-z0-9_] first, then word characters or one of - [ ] < > / . : +, 1..=128 bytes. That is River’s charset (\A[\w][\w\-\[\]<>/.·:+]+\z) with three deliberate differences, each with a reason:

  • ASCII-only word characters. Go’s \w is ASCII and Rust’s regex \w is Unicode-aware; a rule written as \w would mean two different things in the two languages, which is precisely the drift the conformance suite exists to catch.
  • Minimum length ONE, where River requires two. River’s trailing + forbids a single-character kind. headgate’s own conformance corpus enqueues kind w, and a one-letter kind is not a hazard — it is a short name.
  • No · (U+00B7). It follows from ASCII-only; nothing in the corpus uses it.

Whitespace and control characters are rejected by construction: neither is in the permitted set. The message is raw (no Display prefix) because the API serves it verbatim in a 400 body and both servers must emit the same bytes.