diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-12-31 09:00:21 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-12-31 12:10:10 +0200 |
commit | acf1ba3f8f1492b961c9a6eb09eb93e882f5eb3f (patch) | |
tree | 1ce0288f878cac71990bb01f358d6035f1626c92 /src/fsiter.rs | |
parent | 686e87981db210fa443404c8473dfe7a3f39b241 (diff) | |
download | obnam2-acf1ba3f8f1492b961c9a6eb09eb93e882f5eb3f.tar.gz |
docs: add documentation comments to crate
Also, make it an error for a public symbol to not be documented.
Sponsored-by: author
Diffstat (limited to 'src/fsiter.rs')
-rw-r--r-- | src/fsiter.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/fsiter.rs b/src/fsiter.rs index 2325793..2747cce 100644 --- a/src/fsiter.rs +++ b/src/fsiter.rs @@ -1,3 +1,5 @@ +//! Iterate over directory tree. + use crate::fsentry::{FilesystemEntry, FsEntryError}; use log::{debug, warn}; use std::path::{Path, PathBuf}; @@ -5,6 +7,7 @@ use walkdir::{DirEntry, IntoIter, WalkDir}; /// Filesystem entry along with additional info about it. pub struct AnnotatedFsEntry { + /// The file system entry being annotated. pub inner: FilesystemEntry, /// Is `entry` a valid CACHEDIR.TAG? pub is_cachedir_tag: bool, @@ -15,19 +18,24 @@ pub struct FsIterator { iter: SkipCachedirs, } +/// Possible errors from iterating over a directory tree. #[derive(Debug, thiserror::Error)] pub enum FsIterError { + /// Error from the walkdir crate. #[error("walkdir failed: {0}")] WalkDir(walkdir::Error), + /// Error reading a file's metadata. #[error("failed to get file system metadata for {0}: {1}")] Metadata(PathBuf, std::io::Error), + /// Error related to file system entries. #[error(transparent)] FsEntryError(#[from] FsEntryError), } impl FsIterator { + /// Create a new iterator. pub fn new(root: &Path, exclude_cache_tag_directories: bool) -> Self { Self { iter: SkipCachedirs::new( |