pub enum FeaturesStateVersioned {
V1(FeaturesStateV1),
}Expand description
Versioned envelope over the on-disk FeaturesState layouts.
On-disk format. This is the single-variant shell: V1 is the bare borsh of
FeaturesStateV1 with no discriminant, byte-identical to the pre-envelope
format. The seam exists so the next field addition is a “new variant +
lifter” change rather than an unguarded wire bump: that bump adds a V2
variant chosen by a writer-side feature gate, so an old binary halts at
can_process_block before reading bytes it cannot decode (the
StakeInfoVersioned::encode template). Until then Self::deserialize
always decodes the untagged V1 record.
Why V2 cannot reuse leading-byte tag dispatch. StakeInfoVersioned
tells its tagged V2 apart from an untagged V1 by the leading byte, but only
because StakeInfoV1 begins with an Option discriminant constrained to
0/1, leaving tag 2 provably disjoint from every valid V1 record.
FeaturesStateV1 instead begins with authority: Pubkey, whose first byte
is an arbitrary u8 (0..=255); no tag byte is disjoint from a V1 record
whose authority happens to start with it. A future V2 must therefore
disambiguate structurally (the scheme is chosen when the variant is
designed), not on a single leading byte.
Variants§
V1(FeaturesStateV1)
Schema version 1 — the original FeaturesState layout (untagged on
disk).
Implementations§
Source§impl FeaturesStateVersioned
impl FeaturesStateVersioned
Sourcepub fn serialize(&self) -> Result<Vec<u8>, Error>
pub fn serialize(&self) -> Result<Vec<u8>, Error>
Encode to the on-disk byte layout.
V1 is the bare borsh of FeaturesStateV1 (byte-identical to the
pre-envelope format). A future variant encodes its version marker here.
Sourcepub fn deserialize(data: &[u8]) -> Result<Self, Error>
pub fn deserialize(data: &[u8]) -> Result<Self, Error>
Decode the on-disk byte layout.
Today only the untagged V1 record exists, so the whole slice is decoded
as FeaturesStateV1. A future V2 cannot be told apart from V1 by a
leading byte (V1 begins with an unconstrained Pubkey, not an Option
discriminant), so when V2 lands this will need a structural cue rather
than leading-byte dispatch. See FeaturesStateVersioned.
Trait Implementations§
Source§impl Clone for FeaturesStateVersioned
impl Clone for FeaturesStateVersioned
Source§fn clone(&self) -> FeaturesStateVersioned
fn clone(&self) -> FeaturesStateVersioned
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FeaturesStateVersioned
impl Debug for FeaturesStateVersioned
impl Eq for FeaturesStateVersioned
Source§impl From<&FeaturesState> for FeaturesStateVersioned
Defaults to the V1 wire form. A future feature-gated writer would use an
encode(state, feature_active) picker (the StakeInfoVersioned template) to
choose a newer variant; this conversion is the no-feature-context path.
impl From<&FeaturesState> for FeaturesStateVersioned
Defaults to the V1 wire form. A future feature-gated writer would use an
encode(state, feature_active) picker (the StakeInfoVersioned template) to
choose a newer variant; this conversion is the no-feature-context path.
Source§fn from(s: &FeaturesState) -> Self
fn from(s: &FeaturesState) -> Self
Source§impl From<FeaturesState> for FeaturesStateVersioned
impl From<FeaturesState> for FeaturesStateVersioned
Source§fn from(s: FeaturesState) -> Self
fn from(s: FeaturesState) -> Self
Source§impl From<FeaturesStateVersioned> for FeaturesState
impl From<FeaturesStateVersioned> for FeaturesState
Source§fn from(v: FeaturesStateVersioned) -> Self
fn from(v: FeaturesStateVersioned) -> Self
Source§impl PartialEq for FeaturesStateVersioned
impl PartialEq for FeaturesStateVersioned
Source§fn eq(&self, other: &FeaturesStateVersioned) -> bool
fn eq(&self, other: &FeaturesStateVersioned) -> bool
self and other values to be equal, and is used by ==.