1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::LockboxPath;
/// Options for listing lockbox entries.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ListOptions {
/// Root logical path to list from.
pub path: LockboxPath,
/// Optional glob applied to returned logical paths.
pub glob: Option<String>,
/// Whether descendants should be included recursively.
pub recursive: bool,
/// Whether regular files should be included.
pub include_files: bool,
/// Whether symlink entries should be included.
pub include_symlinks: bool,
/// Whether directory entries should be included.
pub include_directories: bool,
/// Optional maximum number of entries to return.
pub limit: Option<usize>,
}
impl ListOptions {
/// Create default non-recursive listing options for `path`.
pub fn new(path: &LockboxPath) -> Self {
Self {
path: path.clone(),
glob: None,
recursive: false,
include_files: true,
include_symlinks: true,
include_directories: true,
limit: None,
}
}
/// Set the glob pattern used to filter returned logical paths.
///
/// The pattern is validated when the options are passed to the listing API.
pub fn set_glob(&mut self, glob: impl Into<String>) {
self.glob = Some(glob.into());
}
}