Upgrade

Struct Upgrade 

Source
pub struct Upgrade<Latest, Prior, Err>
where Err: Error, Prior: Versioned<Err>, Latest: Versioned<Err>, Latest::Output: TryFrom<Prior::Output>,
{ /* private fields */ }
Expand description

The Upgrade struct is used to upgrade data from a previous version to the latest version.

Prior::VERSION must be less than Latest::VERSION!

Upgrades can be chained!

Trait Implementations§

Source§

impl<Latest, Prior, Dec, Err> Decodable<Dec, Err> for Upgrade<Latest, Prior, Err>
where Dec: Decoder, Prior: Versioned<Err> + Decodable<Dec, Err>, Prior::Output: Decode<Dec>, Latest: Versioned<Err> + Decodable<Dec, Err>, Latest::Output: TryFrom<Prior::Output> + Decode<Dec>, Err: Error + From<<Dec as Decoder>::Error> + From<<Latest::Output as TryFrom<Prior::Output>>::Error>,

Source§

fn decode_with_version( decoder: &mut Dec, version: u32, ) -> Result<Self::Output, Err>

Decodes the data with a provided version tag. Is helpful for use in combination with Upgrade. Read more
Source§

fn decode(decoder: &mut Dec) -> Result<Self::Output, Err>

Decodes versioned data and validates the version. Will consume the version from the reader. Read more
Source§

unsafe fn decode_body(decoder: &mut Dec) -> Result<Self::Output, Err>

Decodes only the body, assuming the version has already been validated. Read more
Source§

impl<Latest, Prior, Enc, Err> Encodable<Enc, Err> for Upgrade<Latest, Prior, Err>
where Err: Error + From<<Enc as Encoder>::Error>, Enc: Encoder, Prior: Versioned<Err>, Latest: Versioned<Err>, Latest::Output: Encode<Enc> + TryFrom<Prior::Output>,

Source§

fn encode(data: &Self::Output, encoder: &mut Enc) -> Result<(), Err>

Encodes the data including the version tag. Read more
Source§

impl<Latest, Prior, Err> Versioned<Err> for Upgrade<Latest, Prior, Err>
where Err: Error, Prior: Versioned<Err>, Latest: Versioned<Err>, Latest::Output: TryFrom<Prior::Output>,

Source§

const VERSION: u32 = Latest::VERSION

The version tag of this data
Source§

type Output = <Latest as Versioned<Err>>::Output

The type that the versioned data is encoding

Auto Trait Implementations§

§

impl<Latest, Prior, Err> Freeze for Upgrade<Latest, Prior, Err>
where <Latest as Versioned<Err>>::Output: Sized,

§

impl<Latest, Prior, Err> RefUnwindSafe for Upgrade<Latest, Prior, Err>
where <Latest as Versioned<Err>>::Output: Sized, Prior: RefUnwindSafe, Latest: RefUnwindSafe, Err: RefUnwindSafe,

§

impl<Latest, Prior, Err> Send for Upgrade<Latest, Prior, Err>
where <Latest as Versioned<Err>>::Output: Sized, Prior: Send, Latest: Send, Err: Send,

§

impl<Latest, Prior, Err> Sync for Upgrade<Latest, Prior, Err>
where <Latest as Versioned<Err>>::Output: Sized, Prior: Sync, Latest: Sync, Err: Sync,

§

impl<Latest, Prior, Err> Unpin for Upgrade<Latest, Prior, Err>
where <Latest as Versioned<Err>>::Output: Sized, Prior: Unpin, Latest: Unpin, Err: Unpin,

§

impl<Latest, Prior, Err> UnwindSafe for Upgrade<Latest, Prior, Err>
where <Latest as Versioned<Err>>::Output: Sized, Prior: UnwindSafe, Latest: UnwindSafe, Err: UnwindSafe,

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> 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, 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.