pub struct WalkerRule {
pub name: &'static str,
pub description: Option<String>,
pub only_for: Option<WalkerItemType>,
pub matches: Box<dyn Fn(&Path, &WalkerConfig, &Path) -> bool>,
pub action: Box<dyn Fn(&Path, &WalkerConfig, &Path) -> Result<WalkerRuleResult, Error>>,
}Expand description
Walker rule (run on individual items)
use rebackup::config::*;
let rule = WalkerRule {
// Name of the rule
name: "nomedia",
// Optional description of the rule
description: None,
// The type of items the rule applies to (`None` for all)
only_for: Some(WalkerItemType::Directory),
// Check if the rule would match a specific item
matches: Box::new(|path, _, _| path.join(".nomedia").is_file()),
// Apply the rule to determine what to do
action: Box::new(|_, _, _| Ok(WalkerRuleResult::ExcludeItem)),
};Fields§
§name: &'static strRule’s name
description: Option<String>Rule’s optional description
only_for: Option<WalkerItemType>Indicate if the rule should only be applied on a specific type of filesystem items
matches: Box<dyn Fn(&Path, &WalkerConfig, &Path) -> bool>Predicate to indicate if the rule should be run on a specific item.
The checking should be as fast as possible, the goal of this callback being to not having as much overhad as action.
Arguments are the item’s absolute path, the walker’s configuration, as well as the source directory (absolute, canonicalized)
action: Box<dyn Fn(&Path, &WalkerConfig, &Path) -> Result<WalkerRuleResult, Error>>Action to perform when the rule is applies on a specific item
Arguments are the item’s absolute path, the walker’s configuration, as well as the source directory (absolute, canonicalized)
Auto Trait Implementations§
impl Freeze for WalkerRule
impl !RefUnwindSafe for WalkerRule
impl !Send for WalkerRule
impl !Sync for WalkerRule
impl Unpin for WalkerRule
impl !UnwindSafe for WalkerRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more