controller/src/return_models.rs

25 lines
574 B
Rust
Raw Normal View History

2022-07-17 18:19:36 +00:00
use serde::Serialize;
2022-04-02 23:35:51 +00:00
use crate::db::models::Schedule;
use crate::db::schedules::get_schedule_tags;
2022-04-02 23:35:51 +00:00
#[derive(Debug, Serialize)]
pub struct ReturnSchedule {
#[serde(flatten)]
pub schedule: Schedule,
pub tags: Vec<String>,
}
impl From<Schedule> for ReturnSchedule {
fn from(schedule: Schedule) -> Self {
let tags: Vec<String> = get_schedule_tags(&schedule);
2022-07-17 18:19:36 +00:00
ReturnSchedule { schedule, tags }
2022-04-02 23:35:51 +00:00
}
2022-07-17 18:19:36 +00:00
}
impl From<&Schedule> for ReturnSchedule {
fn from(schedule: &Schedule) -> Self {
ReturnSchedule::from(schedule.clone())
}
}