Expand description
One entry point for an arriving interaction-model message (Core §8.7, §8.8).
Server exposes the processing of each action — Server::serve_chunk,
Server::serve_write, Server::serve_invoke — and deliberately takes already-decoded
paths, because that is what makes each of them testable against the specification’s own
path tables. What it does not do is decide which of them an opcode means, and that
decision is not the triviality it looks like: between the opcode and the processing sit the
rules of §8.7.2.3 and §8.8.2.3, which a node must apply before it does any work and which
are invisible in the shape of the request.
Dispatcher is that layer. It owns the one piece of state the rules need — §8.7.4’s
TimedWindows — and turns “a message arrived on this exchange” into “send this opcode
back”, or into Served::Subscribe for the one action whose state lives elsewhere.
§What it refuses before the node does any work
| Rule | Section | Answer |
|---|---|---|
| a Timed transaction whose window expired | §8.7.2.3, §8.8.2.3 rule 1 | TIMEOUT |
a Timed transaction whose request says TimedRequest = false | §8.7.2.3, §8.8.2.3 rule 2 | TIMED_REQUEST_MISMATCH |
TimedRequest = true with no window open | §8.7.2.3, §8.8.2.3 rule 3 | TIMED_REQUEST_MISMATCH |
more commands than MaxPathsPerInvoke | §8.8.2.3 rule 4 | INVALID_ACTION |
a TimedRequest with no room to record it | §8.7.3.2 | BUSY |
The fourth is the one a hand-written dispatch reliably forgets. MaxPathsPerInvoke is a
Basic Information attribute (§11.1.5.23) whose default is 1, so a device that does not
enforce it advertises “one command per invoke” and then executes however many a client
sends — which is both a specification violation and the only bound the server has on the
work one message can ask of it.
§Why a length rather than a slice
Every other encoder here returns &'b [u8]. This one returns how many octets it wrote,
because Server::serve_write ties the lifetime of the decoded AttributeData to the
lifetime of the output buffer, and a dispatcher that returned a borrow of the buffer would
propagate that unification into its own signature and tie the request to it too. The
caller writes &buf[..len], which is what it was going to do with the slice anyway.
Structs§
- Dispatcher
- The opcode-to-action layer of §8.7 and §8.8, and the state its rules need.
- Request
- One arriving interaction-model message, with the exchange facts §8.7.4 keys its window on.
Enums§
- Served
- What the caller should do with the result of a dispatch.