diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-03-19 07:58:35 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-03-19 07:58:35 +0100 |
commit | 8d1556fce91bbd4301cd13d4ad087640d343fad1 (patch) | |
tree | 7d532d67ffb33baa4f10b16a5b407b51a93ad661 /src/map.rs | |
parent | 32a202068b177c1218632fee41179f651e3b08e9 (diff) |
Adding update methods to the map
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/map.rs b/src/map.rs index dd1fe1c6347e..6d279db468e3 100644 --- a/src/map.rs +++ b/src/map.rs @@ -1,6 +1,10 @@ //! Implements a map graph and world logic -use crate::data::{Link, Node}; +use crate::{ + data::{Link, Node}, + server::{Result, ServerErr}, + wire::Response +}; use async_std::sync::Arc; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -11,7 +15,7 @@ use std::collections::BTreeMap; /// the map nodes are placed, how much spacing there is, etc. All /// this information is encoded in the same structs because it's /// static, and just more convenient. -#[derive(Serialize, Deserialize)] +#[derive(Default, Serialize, Deserialize)] pub struct Map { /// Node IDs mapped to node objects nodes: BTreeMap<u16, Arc<Node>>, @@ -19,4 +23,15 @@ pub struct Map { links: BTreeMap<u16, Arc<Link>>, } -impl Map {} +impl Map { + pub fn new() -> Arc<Self> { + Arc::new(Self::default()) + } + + pub fn update<F>(&mut self, cb: F) -> Result<Response> + where + F: Fn(&mut Map) -> Result<Response>, + { + unimplemented!() + } +} |