From e7449ee3883709320978526637720d46f16ff09d Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Jun 2020 01:06:08 +0200 Subject: implement filter_early for Comparator --- src/filters/values.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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 Filter for Comparator 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); -- cgit v1.2.3