FromDomain

Trait FromDomain 

Source
pub trait FromDomain<D>: Versioned + Serialize {
    // Required method
    fn from_domain(domain: D) -> Self;
}
Expand description

Converts a domain model back into a versioned DTO.

This trait should be implemented on versioned DTOs to enable conversion from the domain model back to the versioned format for serialization.

§Example

impl FromDomain<TaskEntity> for TaskV1_1_0 {
    fn from_domain(domain: TaskEntity) -> Self {
        TaskV1_1_0 {
            id: domain.id,
            title: domain.title,
            description: domain.description,
        }
    }
}

Required Methods§

Source

fn from_domain(domain: D) -> Self

Converts a domain model into this versioned format.

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.

Implementors§