pub fn list_markdown_files(dir: &Path) -> Result<Vec<PathBuf>>Expand description
Recursively find all Markdown files in a directory.
This function performs a recursive traversal of the given directory, collecting all files that have Markdown extensions. It follows symbolic links and handles filesystem errors gracefully.
§Directory Traversal
- Recursively traverses all subdirectories
- Follows symbolic links (may cause infinite loops with circular links)
- Silently skips entries that cannot be accessed
- Only includes regular files (not directories or special files)
§Arguments
dir- The directory path to search
§Returns
Ok(Vec<PathBuf>)- List of absolute paths to Markdown filesErr(...)- Only on severe filesystem errors (rare)
§Behavior
- Returns empty vector if directory doesn’t exist (not an error)
- Files are returned in filesystem order (not sorted)
- Paths are absolute and canonicalized
- Uses
is_markdown_filefor extension validation
§Examples
let files = list_markdown_files(Path::new("resources/"))?;
for file in files {
println!("Found: {}", file.display());
}§Performance
This function loads directory metadata but not file contents, making it
suitable for scanning large directory trees. For processing the files,
consider using MarkdownDocument::read on each result.