Struct rebackup::config::WalkerRule[][src]

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>>,
}

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 str

Rule’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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.