pub trait Versioned {
const VERSION: &'static str;
const VERSION_KEY: &'static str = "version";
const DATA_KEY: &'static str = "data";
}Expand description
A trait for versioned data schemas.
This trait marks a type as representing a specific version of a data schema.
It should be derived using #[derive(Versioned)] along with the #[versioned(version = "x.y.z")] attribute.
§Custom Keys
You can customize the serialization keys:
ⓘ
#[derive(Versioned)]
#[versioned(
version = "1.0.0",
version_key = "schema_version",
data_key = "payload"
)]
struct Task { ... }
// Serializes to: {"schema_version":"1.0.0","payload":{...}}Required Associated Constants§
Provided Associated Constants§
Sourceconst VERSION_KEY: &'static str = "version"
const VERSION_KEY: &'static str = "version"
The key name for the version field in serialized data. Defaults to “version”.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.