[][src]Struct liboverdrop::FragmentScanner

pub struct FragmentScanner { /* fields omitted */ }

Methods

impl FragmentScanner[src]

pub fn new(
    base_dirs: Vec<String>,
    shared_path: &str,
    ignore_dotfiles: bool,
    allowed_extensions: Vec<String>
) -> Self
[src]

Returns a new FragmentScanner, initialized with a vector of directory paths to scan for configuration fragments.

Arguments

  • base_dirs - Vector holding base components of directories where configuration fragments are located.
  • shared_path - Common relative path from each entry in base_dirs to the directory holding configuration fragments.
  • ignore_dotfiles - Whether to ignore dotfiles (hidden files with name prefixed with '.').
  • allowed_extensions - Only scan files that have an extension listed in allowed_extensions. If an empty vector is passed, then any extensions are allowed.

shared_path is concatenated to each entry in base_dirs to form the directory paths to scan.

Example

let base_dirs = vec![
    String::from("/usr/lib"),
    String::from("/run"),
    String::from("/etc"),
];
let allowed_extensions = vec![
    String::from("toml"),
];

use liboverdrop::FragmentScanner;
let od_cfg = FragmentScanner::new(base_dirs, "my-crate/config.d", false, allowed_extensions);

pub fn scan(&self) -> BTreeMap<String, PathBuf>[src]

Scan unique configuration fragments from the set configuration directories. Returns a collections::BTreeMap indexed by configuration fragment filename, holding the path where the unique configuration fragment is located.

Configuration fragments are stored in the BTreeMap in alphanumeric order by filename. Configuration fragments existing in directories that are scanned later override fragments of the same filename in directories that are scanned earlier.

Example

let base_dirs = vec![
    "/usr/lib".to_string(),
    "/run".to_string(),
    "/etc".to_string(),
];
let allowed_extensions = vec![
    String::from("toml"),
];

use liboverdrop::FragmentScanner;
let od_cfg = FragmentScanner::new(base_dirs, "my-crate/config.d", false, allowed_extensions);
let fragments = od_cfg.scan();

Auto Trait Implementations

Blanket Implementations

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.

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

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

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