pub trait Record: Serialize + DeserializeOwned {
const KIND: &'static str;
const SCHEMA: u32;
// Provided method
fn upgrade(from: u32, data: Value) -> Result<Value> { ... }
}Expand description
A value PersistAnt can store under a key with a schema version.
Stored as JSON {"kind", "schema", "data"}. Bump SCHEMA when the shape changes and implement
Record::upgrade to read older data; with no upgrade, older data is refused, never guessed.
Required Associated Constants§
Provided Methods§
Sourcefn upgrade(from: u32, data: Value) -> Result<Value>
fn upgrade(from: u32, data: Value) -> Result<Value>
Turn data written at schema from (older than SCHEMA) into the current shape, in one
step: the result must already be at SCHEMA. The default refuses. Upgraded data carries no
schema marker, so a result that does not fit the current type is reported as
Error::UpgradeFailed; it cannot be told from damaged old data.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".