aboutsummaryrefslogtreecommitdiff
path: root/src/filters/log.rs
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-05-01 13:29:38 +0200
committerDaniel <kingdread@gmx.de>2020-05-01 13:29:38 +0200
commit5f765b749f793b2866262546d28ff138a5654dfc (patch)
tree192add4f0c51169f8f2702596d05bee00af6561a /src/filters/log.rs
parent811d7e62695c5c12aecd08b176c4ead641e2ad2c (diff)
downloadraidgrep-5f765b749f793b2866262546d28ff138a5654dfc.tar.gz
raidgrep-5f765b749f793b2866262546d28ff138a5654dfc.tar.bz2
raidgrep-5f765b749f793b2866262546d28ff138a5654dfc.zip
change LogFilter to take EarlyLogResult
This allows us to attach some additional metadata that is not found in the PartialEvtc otherwise, such as the file name.
Diffstat (limited to 'src/filters/log.rs')
-rw-r--r--src/filters/log.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/filters/log.rs b/src/filters/log.rs
index 2d2fc37..60e6912 100644
--- a/src/filters/log.rs
+++ b/src/filters/log.rs
@@ -3,27 +3,26 @@
//! This is the "base unit", as each file corresponds to one log. Filters on other items (such as
//! players) have to be lifted into log filters first.
use super::{
- super::{FightOutcome, LogResult, Weekday},
+ super::{EarlyLogResult, FightOutcome, LogResult},
Filter, Inclusion,
};
use std::collections::HashSet;
-use evtclib::raw::parser::PartialEvtc;
use evtclib::Boss;
-use chrono::{DateTime, Datelike, Utc};
+use chrono::{DateTime, Datelike, Utc, Weekday};
use num_traits::FromPrimitive as _;
/// Filter trait used for filters that operate on complete logs.
-pub trait LogFilter = Filter<PartialEvtc, LogResult>;
+pub trait LogFilter = Filter<EarlyLogResult, LogResult>;
#[derive(Debug, Clone)]
struct BossFilter(HashSet<Boss>);
-impl Filter<PartialEvtc, LogResult> for BossFilter {
- fn filter_early(&self, partial_evtc: &PartialEvtc) -> Inclusion {
- let boss = Boss::from_u16(partial_evtc.header.combat_id);
+impl Filter<EarlyLogResult, LogResult> for BossFilter {
+ fn filter_early(&self, early_log: &EarlyLogResult) -> Inclusion {
+ let boss = Boss::from_u16(early_log.evtc.header.combat_id);
boss.map(|b| self.0.contains(&b).into())
.unwrap_or(Inclusion::Exclude)
}
@@ -42,7 +41,7 @@ pub fn boss(bosses: HashSet<Boss>) -> Box<dyn LogFilter> {
#[derive(Debug, Clone)]
struct OutcomeFilter(HashSet<FightOutcome>);
-impl Filter<PartialEvtc, LogResult> for OutcomeFilter {
+impl Filter<EarlyLogResult, LogResult> for OutcomeFilter {
fn filter(&self, log: &LogResult) -> bool {
self.0.contains(&log.outcome)
}
@@ -76,7 +75,7 @@ pub fn wipe() -> Box<dyn LogFilter> {
#[derive(Debug, Clone)]
struct WeekdayFilter(HashSet<Weekday>);
-impl Filter<PartialEvtc, LogResult> for WeekdayFilter {
+impl Filter<EarlyLogResult, LogResult> for WeekdayFilter {
fn filter(&self, log: &LogResult) -> bool {
self.0.contains(&log.time.weekday())
}
@@ -90,7 +89,7 @@ pub fn weekday(weekdays: HashSet<Weekday>) -> Box<dyn LogFilter> {
#[derive(Debug, Clone)]
struct TimeFilter(Option<DateTime<Utc>>, Option<DateTime<Utc>>);
-impl Filter<PartialEvtc, LogResult> for TimeFilter {
+impl Filter<EarlyLogResult, LogResult> for TimeFilter {
fn filter(&self, log: &LogResult) -> bool {
let after_ok = match self.0 {
Some(time) => time <= log.time,