pub struct StateSchemaUpgrade { /* private fields */ }Expand description
One directed application-schema upgrade a codec declares.
An upgrade rewrites a JSON-object payload recorded at from
into the shape to expects. The framework, not the codec,
selects and applies the edges, so a codec never inspects a recorded version
to decide what an older payload meant.
Edges strictly increase the version and at most one edge may leave any version, which is what makes a resolved chain deterministic and bounded.
Implementations§
Source§impl StateSchemaUpgrade
impl StateSchemaUpgrade
Sourcepub fn new(
from: StateSchemaVersion,
to: StateSchemaVersion,
apply: fn(&[u8]) -> Result<Vec<u8>, StateCodecError>,
) -> Result<StateSchemaUpgrade, StateError>
pub fn new( from: StateSchemaVersion, to: StateSchemaVersion, apply: fn(&[u8]) -> Result<Vec<u8>, StateCodecError>, ) -> Result<StateSchemaUpgrade, StateError>
Declares a directed upgrade between two application schema versions.
apply must be deterministic: the same payload bytes must always
produce the same result, because a restart replays the same chain over
the same durable bytes.
§Errors
Returns StateError::NonIncreasingUpgrade when to does not exceed
from, which would let a chain loop or move backwards.
Sourcepub const fn from(&self) -> StateSchemaVersion
pub const fn from(&self) -> StateSchemaVersion
Returns the version this upgrade reads.
Sourcepub const fn to(&self) -> StateSchemaVersion
pub const fn to(&self) -> StateSchemaVersion
Returns the version this upgrade produces.
Trait Implementations§
Source§impl Clone for StateSchemaUpgrade
impl Clone for StateSchemaUpgrade
Source§fn clone(&self) -> StateSchemaUpgrade
fn clone(&self) -> StateSchemaUpgrade
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StateSchemaUpgrade
Auto Trait Implementations§
impl Freeze for StateSchemaUpgrade
impl RefUnwindSafe for StateSchemaUpgrade
impl Send for StateSchemaUpgrade
impl Sync for StateSchemaUpgrade
impl Unpin for StateSchemaUpgrade
impl UnsafeUnpin for StateSchemaUpgrade
impl UnwindSafe for StateSchemaUpgrade
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more