Skip to main content

FeaturesStateVersioned

Enum FeaturesStateVersioned 

Source
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

Source

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.

Source

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

Source§

fn clone(&self) -> FeaturesStateVersioned

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FeaturesStateVersioned

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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.

Source§

fn from(s: &FeaturesState) -> Self

Converts to this type from the input type.
Source§

impl From<FeaturesState> for FeaturesStateVersioned

Source§

fn from(s: FeaturesState) -> Self

Converts to this type from the input type.
Source§

impl From<FeaturesStateVersioned> for FeaturesState

Source§

fn from(v: FeaturesStateVersioned) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for FeaturesStateVersioned

Source§

fn eq(&self, other: &FeaturesStateVersioned) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FeaturesStateVersioned

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.