42 lines
809 B
Rust
42 lines
809 B
Rust
use crate::api;
|
|
use crate::config::Config;
|
|
use crate::models::helper::*;
|
|
|
|
#[derive(Debug)]
|
|
pub struct WorldGeoT {
|
|
config: Config,
|
|
}
|
|
|
|
impl Model for WorldGeoT {
|
|
type FetchData = api::world_geo::FeatureCollection;
|
|
const NAME: &'static str = "WorldGeo";
|
|
|
|
fn refresh(sr: &ModelHandle<Self>) -> Option<api::FetchTask> {
|
|
let sref = sr.clone();
|
|
let sd = sr.data();
|
|
sr.service().api_world_geo(&sd.config, move |result| {
|
|
sref.set_received(result);
|
|
})
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
|
pub struct WorldGeo(pub(super) ModelHandle<WorldGeoT>);
|
|
|
|
impl std::ops::Deref for WorldGeo {
|
|
type Target = ModelHandle<WorldGeoT>;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl WorldGeo {
|
|
pub fn new(config: Config) -> Self {
|
|
Self(ModelHandle::new(
|
|
WorldGeoT { config },
|
|
(),
|
|
))
|
|
}
|
|
}
|