1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Contains the implementations related to [`BaseLayerImageDto`].

use uuid::Uuid;

use crate::model::{
    dto::base_layer_images::{BaseLayerImageDto, UpdateBaseLayerImageDto},
    entity::base_layer_images::BaseLayerImages,
};

impl From<BaseLayerImages> for BaseLayerImageDto {
    fn from(entity: BaseLayerImages) -> Self {
        Self {
            id: entity.id,
            layer_id: entity.layer_id,
            path: entity.path,
            rotation: entity.rotation,
            scale: entity.scale,
            x: entity.x,
            y: entity.y,
        }
    }
}

impl From<(Uuid, UpdateBaseLayerImageDto)> for BaseLayerImages {
    fn from((id, dto): (Uuid, UpdateBaseLayerImageDto)) -> Self {
        Self {
            id,
            layer_id: dto.layer_id,
            path: dto.path,
            rotation: dto.rotation,
            scale: dto.scale,
            x: dto.x,
            y: dto.y,
        }
    }
}

impl From<BaseLayerImageDto> for BaseLayerImages {
    fn from(dto: BaseLayerImageDto) -> Self {
        Self {
            id: dto.id,
            layer_id: dto.layer_id,
            path: dto.path,
            rotation: dto.rotation,
            scale: dto.scale,
            x: dto.x,
            y: dto.y,
        }
    }
}