diff options
-rw-r--r-- | src/fexpr/grammar.lalrpop | 1 | ||||
-rw-r--r-- | src/fexpr/mod.rs | 2 | ||||
-rw-r--r-- | src/filters/player.rs | 13 | ||||
-rw-r--r-- | src/main.rs | 24 |
4 files changed, 13 insertions, 27 deletions
diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index 6a7a9a0..45f4fde 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -4,7 +4,6 @@ use super::{ FightOutcome, filters, PlayerClass, - SearchField, }; use evtclib::Boss; use std::collections::HashSet; diff --git a/src/fexpr/mod.rs b/src/fexpr/mod.rs index 452d66c..c6a3a39 100644 --- a/src/fexpr/mod.rs +++ b/src/fexpr/mod.rs @@ -3,7 +3,7 @@ //! This module contains methods to parse a given string into an abstract filter tree, check its //! type and convert it to a [`Filter`][super::filters::Filter]. // Make it available in the grammar mod. -use super::{filters, playerclass::PlayerClass, FightOutcome, SearchField}; +use super::{filters, playerclass::PlayerClass, FightOutcome}; use std::{error, fmt}; diff --git a/src/filters/player.rs b/src/filters/player.rs index 2b14eb0..d3185e0 100644 --- a/src/filters/player.rs +++ b/src/filters/player.rs @@ -3,7 +3,7 @@ //! Additionally, it provides methods to lift a player filter to a log filter with [`any`][any] and //! [`all`][all]. use super::{ - super::{guilds, playerclass::PlayerClass, EarlyLogResult, LogResult, Player, SearchField}, + super::{guilds, playerclass::PlayerClass, EarlyLogResult, LogResult, Player}, log::LogFilter, Filter, Inclusion, }; @@ -61,6 +61,17 @@ pub fn any(player_filter: Box<dyn PlayerFilter>) -> Box<dyn LogFilter> { !all(!player_filter) } +/// A flag indicating which fields should be searched. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum SearchField { + /// Only search the account name. + Account, + /// Only search the character name. + Character, + /// Only search the guild name or tag. + Guild, +} + /// Filter that filters players according to their name. /// /// The given SearchField determines in which field something should be searched. diff --git a/src/main.rs b/src/main.rs index 40f434c..ee1c232 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,30 +101,6 @@ pub struct Opt { expression: Vec<String>, } -/// A flag indicating which fields should be searched. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum SearchField { - /// Only search the account name. - Account, - /// Only search the character name. - Character, - /// Only search the guild name or tag. - Guild, -} - -impl FromStr for SearchField { - type Err = &'static str; - - fn from_str(s: &str) -> Result<Self, Self::Err> { - match s { - "account" => Ok(SearchField::Account), - "character" => Ok(SearchField::Character), - "guild" => Ok(SearchField::Guild), - _ => Err("Must be account or character"), - } - } -} - /// A log that matches the search criteria. #[derive(Debug, Clone)] pub struct LogResult { |