Crate tfhe_versionable

source ·
Expand description

Provides a way to add versioning informations/backward compatibility on rust types used for serialization.

This crates provides a set of traits Versionize and Unversionize that perform a conversion between a type and its Versioned counterpart. The versioned type is an enum that has a variant for each version of the type. These traits can be generated using the tfhe_versionable_derive::Versionize proc macro.

Re-exports§

Modules§

  • These traits are not meant to be manually implemented, they are just used in the derive macro for easier access to generated types
  • How to perform conversion from one version to the next.

Enums§

Traits§

  • Marker trait for a type that it not really versioned, where the versionize method returns Self or &Self.
  • This trait means that we can convert from a versioned enum into the target type. This trait can only be implemented on Owned/static types, whereas Versionize can also be implemented on reference types.
  • This trait means that the type can be converted into a versioned equivalent type.
  • This trait is used as a proxy to be more felxible when deriving Versionize for Vec. This way, we can chose to skip versioning Vec if T is a native types but still versionize in a loop if T is a custom type. This is used as a workaround for feature(specialization) and to bypass the orphan rule.

Derive Macros§

  • This derives the Versionize and Unversionize trait for a type that should not be versioned. The versionize method will simply return self
  • Implement the Version trait for the target type.
  • This derives the Versionize and Unversionize trait for the target type. This macro has a mandatory attribute parameter, which is the name of the versioned enum for this type. This enum can be anywhere in the code but should be in scope.
  • Implement the VersionsDispatch trait for the target type. The type where this macro is applied should be an enum where each variant is a version of the type that we want to versionize.