alert-me/app/src/data/area.rs

25 lines
704 B
Rust

use serde::{Deserialize, Serialize};
use crate::json;
use super::{circle::Circle, polygon::Polygon, text::Text};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Area {
pub description: Text,
pub regions: Vec<String>,
pub polygons: Vec<Polygon>,
pub circles: Vec<Circle>,
}
impl From<json::area::Area> for Area {
fn from(value: json::area::Area) -> Self {
Self {
description: value.description.into(),
regions: value.regions.into_iter().map(|x| x.region).collect(),
polygons: value.polygons.into_iter().map(|x| x.into()).collect(),
circles: value.circles.into_iter().map(|x| x.into()).collect(),
}
}
}