weavatrix_scan/selection/
construction.rs1use super::{
2 Error, Path, RepositoryMatcher, Result, ScanOptions, SelectionMatcher, directory_info, fs,
3};
4
5impl SelectionMatcher {
6 pub fn new(root: impl AsRef<Path>) -> Result<Self> {
13 Self::with_options(root, &ScanOptions::default())
14 }
15
16 pub fn with_options(root: impl AsRef<Path>, options: &ScanOptions) -> Result<Self> {
23 let repository = RepositoryMatcher::with_options(root, options)?;
24 let root_file_system = if options.walk.same_file_system {
25 let metadata = fs::metadata(repository.root())
26 .map_err(|source| Error::io(repository.root(), source))?;
27 Some(
28 directory_info(repository.root(), &metadata)
29 .map_err(|source| Error::io(repository.root(), source))?
30 .file_system,
31 )
32 } else {
33 None
34 };
35 Ok(Self {
36 repository,
37 options: options.clone(),
38 root_file_system,
39 })
40 }
41}