Add documentation to many parts of the Rust codebase (#552)

* add lots of doccomments

* add conversion traits from layerdatatypes to layers

* add suggested doc improvements

* Code review changes

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Alaska
2022-04-09 08:56:58 +02:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 1455ac3dce
commit 5c99cdef7f
13 changed files with 470 additions and 21 deletions
+4
View File
@@ -16,10 +16,13 @@ use std::cmp::max;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
/// A number that identifies a layer.
/// This does not technically need to be unique globally, only within a folder.
pub type LayerId = u64;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Document {
/// The root layer, usually a [FolderLayer](layers::folder_layer::FolderLayer) that contains all other [Layers](layers::layer_info::Layer).
pub root: Layer,
/// The state_identifier serves to provide a way to uniquely identify a particular state that the document is in.
/// This identifier is not a hash and is not guaranteed to be equal for equivalent documents.
@@ -338,6 +341,7 @@ impl Document {
boxes.reduce(|a, b| [a[0].min(b[0]), a[1].max(b[1])])
}
/// Mark the layer at the provided path, as well as all the folders containing it, as dirty.
pub fn mark_upstream_as_dirty(&mut self, path: &[LayerId]) -> Result<(), DocumentError> {
let mut root = &mut self.root;
root.cache_dirty = true;