use futures::executor; 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, } impl ReturnSchedule { pub fn load_tags(&mut self, pool: &sqlx::Pool) { self.tags = executor::block_on(get_schedule_tags(pool, &self.schedule)).unwrap(); } } impl From for ReturnSchedule { fn from(schedule: Schedule) -> Self { ReturnSchedule { schedule, tags: vec![]} } } impl From<&Schedule> for ReturnSchedule { fn from(schedule: &Schedule) -> Self { ReturnSchedule::from(schedule.clone()) } }