Skip to main content

check_discriminators

Function check_discriminators 

Source
fn check_discriminators(message: &ControlMessage) -> Result<(), CodecError>
Expand description

Refuse a message whose optional fields disagree with the field that decides whether they are on the wire.

Presence is not a property of the Rust value: the decoder derives it from a Filter Type, a Content Exists flag or a Fetch Type, and reads exactly the fields that discriminator names. An encoder that instead writes whatever happens to be Some produces a frame its own reader refuses - short by the missing fields, so the declared length runs out mid-payload, or long by the surplus ones, so bytes are left over. Section 7 makes either a session close, which is why this refuses rather than papering over it.