Key-Value-Pair is a flexible structure that carries key/value pairs in which the key is a variable-length integer and the value is either a variable-length integer or a byte field of arbitrary length.
Key-Value-Pairs encode a Type value as a delta from the previous Type value,
or from 0 if there is no previous Type value. This is efficient on the wire
and makes it easy to ensure there is only one instance of a type when needed.
The previous Type value plus the Delta Type MUST NOT be greater than 2^64 - 1.
If a Delta Type is received that would be too large, the Session MUST be closed
with a PROTOCOL_VIOLATION.
Key-Value-Pair is used in both the data plane and control plane, but is optimized for use in the data plane.
Key-Value-Pair {
Delta Type (vi64),
[Length (vi64),]
Value (..)
}
-
Delta Type: an unsigned variable-length integer identifying the Type as a delta encoded value from the previous Type, if any. The Type identifies the type of value and also the subsequent serialization.
-
Length: Only present when Type is odd. Specifies the length of the Value field in bytes. The maximum length of a value is 2^16-1 bytes. If an endpoint receives a length larger than the maximum, it MUST close the session with a
PROTOCOL_VIOLATION. -
Value: A single variable-length integer when Type is even, otherwise a sequence of Length bytes.
If a receiver understands a Type, and the following Value or Length/Value does
not match the serialization defined by that Type, the receiver MUST close
the session with error code KEY_VALUE_FORMATTING_ERROR.
Key-Value-Pairs are always parsed with a known byte length, which bounds the sequence. The source of this length varies by context.