Enum includer_codegen::utils::FilterRule[][src]

pub enum FilterRule {
    Extension(String),
    Regex(Regex),
}

A rule on how to match a file or path

Variants

Match any file that contains the specified extension.

It is suggested to use the extension helper method instead for ease of use and consistency.

let html_files = FilterRule::Extension("html".to_string());
let inconsistent = FilterRule::Extension(".html".to_string());

Note: For consistency, the extension should not have a leading period

Match any file that has a regex match on its path.

It is suggested to use the regex helper method instead for ease of use and consistency.

use includer_codegen::regex::Regex;

// Match all css files in the "styles" subdirectory
let css_files = FilterRule::Regex(Regex::new(r"^styles[/\\].*\.css$").unwrap());

Note: For consistency, the path compared to the regex should be relative to the root asset path with no leading slash. You can get this result by using strip_prefix.

Methods

impl FilterRule
[src]

Creates a validated FilterRule::Extension

Makes sure that the extension does not have a leading ".".

// Only accept HTML files
FilterRule::extension("html");

Panics

This function will panic if extension is not valid.

// should panic
FilterRule::extension(".html");

Creates a validated Filer::Regex

// Accept all css files that are under the root subdirectory `styles` (multi-platform)
FilterRule::regex(r"^styles[/\\].*\.css$");

Panics

Invalid regex expressions will panic.

// should panic
FilterRule::regex(r"\h");

See if the path matches the filter rule

Auto Trait Implementations

impl Send for FilterRule

impl Sync for FilterRule