Enum includer_codegen::utils::FilterRule [−][src]
A rule on how to match a file or path
Variants
Extension(String)
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
Regex(Regex)
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]
impl FilterRule
pub fn extension<S: Into<String>>(extension: S) -> Self
[src]
pub fn extension<S: Into<String>>(extension: S) -> Self
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");
pub fn regex<S: AsRef<str>>(regex_str: S) -> Self
[src]
pub fn regex<S: AsRef<str>>(regex_str: S) -> Self
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");
pub fn matches<P: AsRef<Path>>(&self, relative_path: P) -> bool
[src]
pub fn matches<P: AsRef<Path>>(&self, relative_path: P) -> bool
See if the path matches the filter rule
Auto Trait Implementations
impl Send for FilterRule
impl Send for FilterRule
impl Sync for FilterRule
impl Sync for FilterRule