use crate::api; use crate::config::Config; use crate::models::helper::*; #[derive(Debug)] pub struct AlmanacT { config: Config, } impl Model for AlmanacT { type FetchData = api::Almanac; const NAME: &'static str = "Almanac"; fn refresh(sr: &ModelHandle) -> Option { let sref = sr.clone(); let sd = sr.data(); sr.service().api_almanac(&sd.config, move |result| { sref.set_received(result); }) } } #[derive(Clone, PartialEq, Eq, Debug)] pub struct Almanac(pub(super) ModelHandle); impl std::ops::Deref for Almanac { type Target = ModelHandle; fn deref(&self) -> &Self::Target { &self.0 } } impl Almanac { pub fn new(config: Config) -> Self { Self(ModelHandle::new( AlmanacT { config }, (), )) } pub(super) fn new_shared(config: Config, base: ModelBase) -> Self { Self(ModelHandle::new( AlmanacT { config }, base, )) } }