pub enum VarKey {
Key1(Key1),
Key2(Key2),
Key4(Key4),
Key8(Key),
}
Expand description
A variably sized header Key
NOTE: We DO NOT impl Serialize/Deserialize for this type because we use non-postcard-compatible format (externally tagged) on the wire.
NOTE: VarKey implements PartialEq
by reducing two VarKeys down to the
smaller of the two forms, and checking whether they match. This allows
a key in 8-byte form to be compared to a key in 1, 2, or 4-byte form
for equality.
Variants§
Key1(Key1)
A one byte key
Key2(Key2)
A two byte key
Key4(Key4)
A four byte key
Key8(Key)
An eight byte key
Implementations§
Source§impl VarKey
impl VarKey
Sourcepub fn shrink_to(&mut self, kind: VarKeyKind)
pub fn shrink_to(&mut self, kind: VarKeyKind)
Keys can not be reaised, but instead only shrunk.
This method will shrink to the requested length if that length is smaller than the current representation, or if the requested length is the same or larger than the current representation, it will be kept unchanged
Sourcepub fn kind(&self) -> VarKeyKind
pub fn kind(&self) -> VarKeyKind
The current kind/length of the key
Trait Implementations§
Source§impl PartialEq for VarKey
We implement PartialEq MANUALLY for VarKey, because keys of different lengths SHOULD compare
as equal.
impl PartialEq for VarKey
We implement PartialEq MANUALLY for VarKey, because keys of different lengths SHOULD compare as equal.