fn check_discriminators(message: &ControlMessage) -> Result<(), CodecError>Expand description
Refuse a message whose discriminator disagrees with the fields beside it.
One draft-17 message carries a field that says which of the following fields
are on the wire: FETCH’s Fetch Type. This codec holds the alternatives in an
enum of its own, FetchPayload, so a value can say one thing in its
discriminator and another in its body, and the two sides of the codec
resolve that differently — the encoder writes whatever the body holds, and
the decoder reads whatever the discriminator announces.
The result is a message that does not survive its own round trip. A FETCH whose type says Standalone and whose body is a joining pair encodes to a joining request id and a joining start where a Track Namespace and a Track Name belong, and comes back as a Standalone fetch of a track named after two integers — or, more often, as an error, which at least is honest. Refusing at the encoder keeps the two readings from ever diverging on the wire.
The two joining types share one body shape, so the check is between Standalone and everything else rather than one arm per type.