pub trait LatestVersioned: Sized {
type Latest: Versioned + Serialize + FromDomain<Self>;
const ENTITY_NAME: &'static str;
// Provided method
fn to_latest(self) -> Self::Latest { ... }
}Expand description
Associates a domain entity with its latest versioned representation.
This trait enables automatic saving of domain entities using their latest version.
It should typically be derived using the #[version_migrate] attribute macro.
§Example
ⓘ
#[derive(Serialize, Deserialize)]
#[version_migrate(entity = "task", latest = TaskV1_1_0)]
struct TaskEntity {
id: String,
title: String,
description: Option<String>,
}
// Now you can save entities directly
let entity = TaskEntity { ... };
let json = migrator.save_entity(entity)?;Required Associated Constants§
Sourceconst ENTITY_NAME: &'static str
const ENTITY_NAME: &'static str
The entity name used for migration paths.
Required Associated Types§
Sourcetype Latest: Versioned + Serialize + FromDomain<Self>
type Latest: Versioned + Serialize + FromDomain<Self>
The latest versioned type for this entity.
Provided Methods§
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.