backend/model/dto/
map_impl.rs

1//! Contains the implementation of [`MapDto`].
2
3use crate::model::entity::Map;
4
5use super::MapDto;
6
7impl From<Map> for MapDto {
8    fn from(map: Map) -> Self {
9        Self {
10            id: map.id.try_into().unwrap_or(-1),
11            name: map.name,
12            created_at: map.created_at,
13            modified_at: map.modified_at,
14            created_by: map.created_by,
15            modified_by: map.modified_by,
16            deletion_date: map.deletion_date,
17            last_visit: map.last_visit,
18            is_inactive: map.is_inactive,
19            zoom_factor: map.zoom_factor,
20            privacy: map.privacy,
21            description: map.description,
22            location: map.location.map(From::from),
23            geometry: map.geometry,
24        }
25    }
26}
27
28impl<T> From<(T, Map)> for MapDto {
29    fn from((_, map): (T, Map)) -> Self {
30        Self::from(map)
31    }
32}