Skip to main content

Module dict

Module dict 

Source
Expand description

DICT (RFC 2229) server — the model is the dictionary.

The server greets with 220, then reads one command per line. The commands whose answer is content — DEFINE, MATCH, SHOW DB/STRAT/INFO/SERVER — raise an event and the model answers with a structured action. Everything whose answer is fixed by the protocol — CLIENT, STATUS, HELP, OPTION, QUIT, AUTH, and any command this server does not know — is answered here without consulting anyone, so a stranger typing garbage costs no model call.

Four properties worth knowing before changing the loop:

  1. A command is a line, and a line is bounded. RFC 2229 caps a command line at 1024 bytes including CRLF (wire::MAX_LINE_BYTES). A longer one is refused with 500 and the connection closes — there is no way to resynchronise with a peer that ignored a MUST, and buffering toward its newline is a memory hole.
  2. The model cannot write framing. Its actions are rendered by wire, and the loop then checks that the reply’s status code fits the command it answers (a 152 to a DEFINE is refused, not sent). A reply that does not fit, no reply, and a backend failure all end the same way: 420 Server temporarily unavailable, then close.
  3. OPTION MIME is connection state the executor cannot see. The action executor is stateless, so the loop applies wire::apply_mime to what the executor rendered. Replies injected from the dashboard ([ message ]) do not pass through the loop and are written without the MIME preface.
  4. The deadlines wrap the read, not the answer. A command parked for a human under a manual rule is never closed by first_byte_timeout_secs or idle_timeout_secs.

Re-exports§

pub use wire::MAX_LINE_BYTES;

Modules§

actions
DICT protocol actions: what the model is told, and how its answers become wire bytes.
wire
DICT (RFC 2229) wire format: command parsing and response rendering.

Structs§

DictServer

Enums§

Command
One parsed command line.

Functions§

parse_command
Parse one command line (without its line terminator). Commands are case-insensitive.