From f921a73fb0ab4e3e6cca6587144cbfa07b1fe50d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Jan 2016 21:28:08 +0100 Subject: [PATCH 1/5] content.rs: Add documentation --- libimagstore/src/content.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libimagstore/src/content.rs b/libimagstore/src/content.rs index 1e5f792b..ade530f1 100644 --- a/libimagstore/src/content.rs +++ b/libimagstore/src/content.rs @@ -1 +1,4 @@ +/** + * EntryContent type + */ pub type EntryContent = String; From 67ae39ab5b8ec5f3888b8fe977c90ac5513abf84 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Jan 2016 21:28:18 +0100 Subject: [PATCH 2/5] header.rs: Add documentation --- libimagstore/src/header.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libimagstore/src/header.rs b/libimagstore/src/header.rs index daa2e579..9f33e1c9 100644 --- a/libimagstore/src/header.rs +++ b/libimagstore/src/header.rs @@ -1,5 +1,11 @@ use toml::Table; +/** + * EntryHeader + * + * This is basically a wrapper around toml::Table which provides convenience to the user of the + * librray. + */ #[derive(Debug, Clone)] pub struct EntryHeader { toml: Table, @@ -7,12 +13,18 @@ pub struct EntryHeader { impl EntryHeader { + /** + * Get a new header object with a already-filled toml table + */ pub fn new(toml: Table) -> EntryHeader { EntryHeader { toml: toml, } } + /** + * Get the table which lives in the background + */ pub fn toml(&self) -> &Table { &self.toml } From 64ee182d63d0f046849ef021f7aa380e7f8995f8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Jan 2016 21:28:29 +0100 Subject: [PATCH 3/5] entry.rs: Add documentation --- libimagstore/src/entry.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libimagstore/src/entry.rs b/libimagstore/src/entry.rs index e7c21102..682b5538 100644 --- a/libimagstore/src/entry.rs +++ b/libimagstore/src/entry.rs @@ -2,6 +2,11 @@ use header::EntryHeader; use content::EntryContent; use store::StoreId; +/** + * An Entry of the store + * + * Contains location, header and content part. + */ #[derive(Debug, Clone)] pub struct Entry { location: StoreId, From 434a76653690b2efea15bfa20fe7855488dea1fb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Jan 2016 21:30:41 +0100 Subject: [PATCH 4/5] lazyfile.rs: Add documentation --- libimagstore/src/lazyfile.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libimagstore/src/lazyfile.rs b/libimagstore/src/lazyfile.rs index 2d4f3cf4..988639c5 100644 --- a/libimagstore/src/lazyfile.rs +++ b/libimagstore/src/lazyfile.rs @@ -4,6 +4,11 @@ use std::io::{Seek, SeekFrom}; use std::path::{Path, PathBuf}; use std::fs::{File, OpenOptions}; +/** + * LazyFile type + * + * A lazy file is either absent, but a path to it is available, or it is present. + */ pub enum LazyFile { Absent(PathBuf), File(File) @@ -18,13 +23,24 @@ fn create_file>(p: A) -> ::std::io::Result { } impl LazyFile { + + /** + * Create a new LazyFile instance from a Path + */ pub fn new(p: PathBuf) -> LazyFile { LazyFile::Absent(p) } + + /** + * Create a new LazyFile instance from an already existing file + */ pub fn new_with_file(f: File) -> LazyFile { LazyFile::File(f) } + /** + * Get the file behind a LazyFile object + */ pub fn get_file(&mut self) -> Result<&File, StoreError> { match self.get_file_mut() { Ok(file) => Ok(&*file), @@ -32,6 +48,9 @@ impl LazyFile { } } + /** + * Get the mutable file behind a LazyFile object + */ pub fn get_file_mut(&mut self) -> Result<&mut File, StoreError> { let file = match *self { LazyFile::File(ref mut f) => return { @@ -56,6 +75,9 @@ impl LazyFile { unreachable!() } + /** + * Create a file out of this LazyFile object + */ pub fn create_file(&mut self) -> Result<&mut File, StoreError> { let file = match *self { LazyFile::File(ref mut f) => return Ok(f), From cfa8c29eafd9e537d8aac71a19013ff1910c2e7c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Jan 2016 21:31:48 +0100 Subject: [PATCH 5/5] error.rs: Add documentation --- libimagstore/src/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libimagstore/src/error.rs b/libimagstore/src/error.rs index 83cb825e..e05fcdb6 100644 --- a/libimagstore/src/error.rs +++ b/libimagstore/src/error.rs @@ -4,6 +4,9 @@ use std::fmt::Formatter; use std::fmt::Error as FmtError; use std::clone::Clone; +/** + * Kind of store error + */ #[derive(Clone, Copy, Debug)] pub enum StoreErrorKind { FileError, @@ -35,6 +38,9 @@ impl Display for StoreErrorKind { } +/** + * Store error type + */ #[derive(Debug)] pub struct StoreError { err_type: StoreErrorKind, @@ -43,6 +49,9 @@ pub struct StoreError { impl StoreError { + /** + * Build a new StoreError from an StoreErrorKind, optionally with cause + */ pub fn new(errtype: StoreErrorKind, cause: Option>) -> StoreError { @@ -52,6 +61,9 @@ impl StoreError { } } + /** + * Get the error type of this StoreError + */ pub fn err_type(&self) -> StoreErrorKind { self.err_type.clone() }