diff options
Diffstat (limited to 'src/map/data.rs')
| -rw-r--r-- | src/map/data.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/map/data.rs b/src/map/data.rs index f978081..1031d3c 100644 --- a/src/map/data.rs +++ b/src/map/data.rs @@ -1,3 +1,5 @@ +//! Module containing the raw map data version of the map. + use super::{IconData, PolygonRoomData, RectRoomData, WallData}; use ron::de::from_reader; use ron::ser::{to_string_pretty, PrettyConfig}; @@ -18,6 +20,7 @@ pub struct MapData { } impl MapData { + /// Create a serialisable map data type from the data elements contained in a map. pub fn new( rect_rooms: Vec<RectRoomData>, polygon_rooms: Vec<PolygonRoomData>, @@ -32,6 +35,7 @@ impl MapData { } } + /// Load the map data from a file. Fails if the file does not exist or cannot be correctly parsed. pub fn load_from_file<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Self> { let file = File::open(&path)?; let data: Self = match from_reader(file) { @@ -44,6 +48,8 @@ impl MapData { Ok(data) } + /// Write the map data to the file located at `path`. If the file already exists, it will be + /// overwritten. If the write fails, an IO-Error is returned. pub fn write_to_file<P: AsRef<Path>>(&self, path: P) -> io::Result<()> { let mut file = File::create(&path)?; |
