Skip to main content

check_parameter_lengths

Function check_parameter_lengths 

Source
fn check_parameter_lengths(
    parameters: &[KeyValuePair],
    varint_typed: &[u64],
) -> Result<(), CodecError>
Expand description

Refuse a parameter whose value is not the shape its type implies.

Section 8.1: “If a receiver understands a parameter type, and the parameter length implied by that type does not match the Parameter Length field, the receiver MUST terminate the session with error code ‘Parameter Length Mismatch’.”

This draft frames every parameter as {Type, Length, Value} with no per-key table, so a parameter that came off the wire always arrives as bytes and its declared length is whatever the sender wrote. For a type whose definition says the value is one integer, the implied length is that varint’s own length, and the two agree only when the value is exactly one varint with nothing after it.

A value already held as a varint is not checked: KeyValuePair::encode_d07 derives its length field from the varint it is about to write, so those two cannot disagree. Only bytes can.