24 lines
535 B
Rust
24 lines
535 B
Rust
use serde::Serialize;
|
|
|
|
use crate::db::models::Schedule;
|
|
use crate::db::schedules::get_schedule_tags;
|
|
|
|
#[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);
|
|
ReturnSchedule { schedule, tags }
|
|
}
|
|
}
|
|
|
|
impl From<&Schedule> for ReturnSchedule {
|
|
fn from(schedule: &Schedule) -> Self {
|
|
ReturnSchedule::from(schedule.clone())
|
|
}
|
|
}
|