Skip to main content

LatestVersioned

Trait LatestVersioned 

Source
pub trait LatestVersioned: Sized {
    type Latest: Versioned + Serialize + FromDomain<Self>;

    const ENTITY_NAME: &'static str;
    const SAVE: bool = false;

    // 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§

Source

const ENTITY_NAME: &'static str

The entity name used for migration paths.

Provided Associated Constants§

Source

const SAVE: bool = false

Whether this entity supports saving functionality. When false (default), uses into() for read-only access. When true, uses into_with_save() to enable domain entity saving.

Required Associated Types§

Source

type Latest: Versioned + Serialize + FromDomain<Self>

The latest versioned type for this entity.

Provided Methods§

Source

fn to_latest(self) -> Self::Latest

Converts this domain entity into its latest versioned format.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§