robotparser-rs/src/model/rule.rs
svmk 2d19755779
Refactoring of robotparser-rs (#20)
* Migrated sites into robotsparser file.

* Robots.txt refactoring.

* Migrated to new version of url and reqwest.
2020-01-31 17:00:58 +08:00

31 lines
No EOL
792 B
Rust

use crate::model::path_pattern::PathPattern;
use crate::model::path::Path;
/// A rule line is a single "Allow:" (allowance==True) or "Disallow:"
/// (allowance==False) followed by a path."""
#[derive(Debug, Clone)]
pub struct Rule {
path_pattern: PathPattern,
allowance: bool,
}
impl Rule {
pub fn new(path_pattern: impl Into<PathPattern>, allowance: bool) -> Rule {
Rule {
path_pattern: path_pattern.into(),
allowance,
}
}
pub (crate) fn applies_to(&self, path: &Path) -> bool {
return self.path_pattern.applies_to(path);
}
pub (crate) fn get_allowance(&self) -> bool {
return self.allowance;
}
pub (crate) fn get_path_pattern(&self) -> &PathPattern {
return &self.path_pattern;
}
}