aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-06-12 01:06:08 +0200
committerDaniel <kingdread@gmx.de>2020-06-12 01:06:08 +0200
commite7449ee3883709320978526637720d46f16ff09d (patch)
tree98f5fc57424e70bbf41052d7989246903cc41a82 /src
parentc3d6e1bd3f5c793dc5df6b668a07ccc4d81455a9 (diff)
downloadraidgrep-e7449ee3883709320978526637720d46f16ff09d.tar.gz
raidgrep-e7449ee3883709320978526637720d46f16ff09d.tar.bz2
raidgrep-e7449ee3883709320978526637720d46f16ff09d.zip
implement filter_early for Comparator
Diffstat (limited to 'src')
-rw-r--r--src/filters/values.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/filters/values.rs b/src/filters/values.rs
index f64d6dd..3109ef4 100644
--- a/src/filters/values.rs
+++ b/src/filters/values.rs
@@ -18,7 +18,7 @@ use std::{
use chrono::{DateTime, Duration, Utc};
-use super::{log::LogFilter, Filter};
+use super::{log::LogFilter, Filter, Inclusion};
use crate::{EarlyLogResult, LogResult};
/// A producer for a given value.
@@ -101,6 +101,15 @@ impl<V> Filter<EarlyLogResult, LogResult> for Comparator<V>
where
V: Ord,
{
+ fn filter_early(&self, early_log: &EarlyLogResult) -> Inclusion {
+ self.0
+ .produce_early(early_log)
+ .and_then(|lhs| self.2.produce_early(early_log).map(|rhs| lhs.cmp(&rhs)))
+ .map(|ordering| self.1.matches(ordering))
+ .map(Into::into)
+ .unwrap_or(Inclusion::Unknown)
+ }
+
fn filter(&self, log: &LogResult) -> bool {
let lhs = self.0.produce(log);
let rhs = self.2.produce(log);