aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index db2a5e7..33b3c45 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,7 +7,7 @@ use std::path::PathBuf;
use std::str::FromStr;
use anyhow::{anyhow, Error, Result};
-use chrono::{DateTime, TimeZone, Utc, Weekday};
+use chrono::{DateTime, TimeZone, Utc};
use colored::Colorize;
use itertools::Itertools;
use log::debug;
@@ -16,6 +16,7 @@ use rustyline::Editor;
use structopt::StructOpt;
use walkdir::{DirEntry, WalkDir};
+use evtclib::raw::parser::PartialEvtc;
use evtclib::{EliteSpec, EventKind, Log, Profession};
mod fexpr;
@@ -155,6 +156,17 @@ pub enum FightOutcome {
Wipe,
}
+/// A stripped version of [`LogResult`][LogResult] that is available early in the parsing process.
+///
+/// This can be used by filters to filter out logs early, before they will be fully parsed.
+#[derive(Debug, Clone)]
+pub struct EarlyLogResult {
+ /// The path to the log file.
+ log_file: PathBuf,
+ /// The partially parsed evtc.
+ evtc: PartialEvtc,
+}
+
impl FromStr for FightOutcome {
type Err = &'static str;
@@ -368,7 +380,12 @@ fn search_log(entry: &DirEntry, filter: &dyn LogFilter) -> Result<Option<LogResu
let mut stream = wrapper.get_stream();
let partial = evtclib::raw::parser::parse_partial_file(&mut stream)?;
- let early_ok = filter.filter_early(&partial);
+ let early_log = EarlyLogResult {
+ log_file: entry.path().to_owned(),
+ evtc: partial,
+ };
+ let early_ok = filter.filter_early(&early_log);
+ let partial = early_log.evtc;
if early_ok == Inclusion::Exclude {
return Ok(None);