From d7e9c3cc46d616c2fcd1a6e9f73adbb79c6570b4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Mon, 21 Dec 2020 01:22:15 +0100 Subject: Add previously missing docs where appropriate --- src/map/data.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/map/data.rs') 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, polygon_rooms: Vec, @@ -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>(&mut self, path: P) -> io::Result { 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>(&self, path: P) -> io::Result<()> { let mut file = File::create(&path)?; -- cgit v1.2.3-70-g09d2