feat: partial incorporation of custom predicates into statement and operation structures in middleware (#84)
* Add custom predicates to middleware Statement enum * Add custom op enum variant and wildcard matching procedures
This commit is contained in:
parent
538353a701
commit
05c21ebe6a
6 changed files with 119 additions and 36 deletions
|
|
@ -171,7 +171,7 @@ fn resolve_wildcard(args: &[&str], priv_args: &[&str], v: &HashOrWildcardStr) ->
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::middleware::PodType;
|
||||
use crate::middleware::{CustomPredicateRef, PodType};
|
||||
|
||||
#[test]
|
||||
fn test_custom_pred() {
|
||||
|
|
@ -204,7 +204,7 @@ mod tests {
|
|||
println!("a.0. eth_friend = {}", builder.predicates.last().unwrap());
|
||||
let eth_friend = builder.finish();
|
||||
// This batch only has 1 predicate, so we pick it already for convenience
|
||||
let eth_friend = Predicate::Custom(eth_friend, 0);
|
||||
let eth_friend = Predicate::Custom(CustomPredicateRef(eth_friend, 0));
|
||||
|
||||
// next chunk builds:
|
||||
// eth_dos_distance_base(src_or, src_key, dst_or, dst_key, distance_or, distance_key) = and<
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use anyhow::Result;
|
|||
use itertools::Itertools;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::From;
|
||||
use std::fmt;
|
||||
use std::{fmt, hash as h};
|
||||
|
||||
use crate::middleware::{
|
||||
self,
|
||||
|
|
@ -22,7 +22,7 @@ pub use operation::*;
|
|||
pub use statement::*;
|
||||
|
||||
/// This type is just for presentation purposes.
|
||||
#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, Default, h::Hash, PartialEq, Eq)]
|
||||
pub enum PodClass {
|
||||
#[default]
|
||||
Signed,
|
||||
|
|
@ -30,7 +30,7 @@ pub enum PodClass {
|
|||
}
|
||||
|
||||
// An Origin, which represents a reference to an ancestor POD.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, h::Hash, Default)]
|
||||
pub struct Origin(pub PodClass, pub PodId);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
|
@ -166,7 +166,7 @@ impl SignedPod {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, h::Hash)]
|
||||
pub struct AnchoredKey(pub Origin, pub String);
|
||||
|
||||
impl From<AnchoredKey> for middleware::AnchoredKey {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue