aboutsummaryrefslogtreecommitdiff
path: root/src/filters/player.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/filters/player.rs')
-rw-r--r--src/filters/player.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/filters/player.rs b/src/filters/player.rs
index 8f9196a..4daeb22 100644
--- a/src/filters/player.rs
+++ b/src/filters/player.rs
@@ -64,13 +64,7 @@ pub fn any(player_filter: Box<dyn PlayerFilter>) -> Box<dyn LogFilter> {
///
/// The given SearchField determines in which field something should be searched.
#[derive(Debug, Clone)]
-pub struct NameFilter(SearchField, Regex);
-
-impl NameFilter {
- pub fn new(field: SearchField, regex: Regex) -> Box<dyn PlayerFilter> {
- Box::new(NameFilter(field, regex))
- }
-}
+struct NameFilter(SearchField, Regex);
impl Filter<Agent, Player> for NameFilter {
fn filter_early(&self, agent: &Agent) -> Inclusion {
@@ -108,3 +102,18 @@ impl Filter<Agent, Player> for NameFilter {
}
}
}
+
+/// Construct a `PlayerFilter` that searches the given `field` with the given `regex`.
+pub fn name(field: SearchField, regex: Regex) -> Box<dyn PlayerFilter> {
+ Box::new(NameFilter(field, regex))
+}
+
+/// Construct a `PlayerFilter` that searches the character name with the given `regex`.
+pub fn character(regex: Regex) -> Box<dyn PlayerFilter> {
+ name(SearchField::Character, regex)
+}
+
+/// Construct a `PlayerFilter` that searches the account name with the given `regex`.
+pub fn account(regex: Regex) -> Box<dyn PlayerFilter> {
+ name(SearchField::Account, regex)
+}