API for checking if subscription matches key

This commit is contained in:
Greg Heartsfield 2021-11-24 16:22:49 -06:00
parent 5bc36cc591
commit 03bc1fab18
2 changed files with 23 additions and 0 deletions

View File

@ -54,6 +54,11 @@ impl Event {
let _e: Event = serde_json::from_str(json)?;
Err(Error::EventParseFailed)
}
// check if this event is valid (should be propagated, stored) based on signature.
pub fn is_valid(&self) -> bool {
false
}
}
#[cfg(test)]

View File

@ -1,4 +1,5 @@
use crate::error::{Error, Result};
use crate::event::Event;
use serde::{Deserialize, Deserializer, Serialize};
//use serde_json::json;
//use serde_json::Result;
@ -89,6 +90,23 @@ impl Subscription {
pub fn get_filter_count(&self) -> usize {
self.filters.len()
}
pub fn interested_in_event(&self, event: &Event) -> bool {
// loop through every filter, and return true if any match this event.
for f in self.filters.iter() {
if f.interested_in_event(event) {
return true;
}
}
}
}
impl ReqFilter {
pub fn interested_in_event(&self, event: &Event) -> bool {
// determine if all populated fields in this filter match the provided event.
todo!();
true
}
}
#[cfg(test)]