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§
pub use derived_traits::Version;pub use derived_traits::VersionsDispatch;pub use upgrade::Upgrade;
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§
- Errors that can arise in the unversionizing process.
Traits§
- Marker trait for a type that it not really versioned, where the
versionizemethod 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
Versionizecan 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
VersionizeandUnversionizetrait for a type that should not be versioned. Theversionizemethod will simply return self - Implement the
Versiontrait for the target type. - This derives the
VersionizeandUnversionizetrait 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
VersionsDispatchtrait 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.