fn encode_parameters(
params: &[KeyValuePair],
buf: &mut impl BufMut,
) -> Result<(), CodecError>Expand description
Encode a count-prefixed list of parameters with delta-encoded types.
Errors with CodecError::InvalidField on a uint8-valued parameter whose
value decode_parameters would refuse, so the two directions accept the
same set of frames.
The check is not a mirror added for tidiness. A uint8 parameter’s value is written as one octet, and a value that does not fit one is otherwise truncated to its low byte: GROUP_ORDER 258 becomes the byte 0x02, which is Descending — a well-formed frame carrying a value the caller never asked for, and one no receiver could tell from a genuine Descending. Refusing is the only outcome that does not silently rewrite the message.
The two structure rules are here for a plainer reason. A value under a type that defines a structure and is not that structure — a Token, a filter — is one the receiver must close the session over, so writing it is not a way to send it; the sender’s first sign of trouble would be the session going.