@@ -9,7 +9,7 @@ use crate::middleware::{
99 EMPTY_HASH , F , VALUE_SIZE ,
1010} ;
1111
12- #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize , JsonSchema ) ]
12+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize , JsonSchema ) ]
1313pub struct Wildcard {
1414 pub name : String ,
1515 pub index : usize ,
@@ -37,7 +37,7 @@ impl ToFields for Wildcard {
3737 }
3838}
3939
40- #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize , JsonSchema ) ]
40+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize , JsonSchema ) ]
4141#[ serde( tag = "type" , content = "value" ) ]
4242pub enum StatementTmplArg {
4343 None ,
@@ -122,7 +122,7 @@ impl fmt::Display for StatementTmplArg {
122122}
123123
124124/// Statement Template for a Custom Predicate
125- #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize , JsonSchema ) ]
125+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize , JsonSchema ) ]
126126pub struct StatementTmpl {
127127 pub pred : Predicate ,
128128 pub args : Vec < StatementTmplArg > ,
@@ -179,7 +179,7 @@ impl ToFields for StatementTmpl {
179179 }
180180}
181181
182- #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize , JsonSchema ) ]
182+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize , JsonSchema ) ]
183183#[ serde( rename_all = "camelCase" ) ]
184184/// NOTE: fields are not public (outside of crate) to enforce the struct instantiation through
185185/// the `::and/or` methods, which performs checks on the values.
@@ -275,6 +275,21 @@ impl CustomPredicate {
275275 args : vec ! [ ] ,
276276 }
277277 }
278+ pub fn is_conjunction ( & self ) -> bool {
279+ self . conjunction
280+ }
281+ pub fn is_disjunction ( & self ) -> bool {
282+ !self . conjunction
283+ }
284+ pub fn statements ( & self ) -> & [ StatementTmpl ] {
285+ & self . statements
286+ }
287+ pub fn args_len ( & self ) -> usize {
288+ self . args_len
289+ }
290+ pub fn wildcard_names ( & self ) -> & [ String ] {
291+ & self . wildcard_names
292+ }
278293}
279294
280295impl ToFields for CustomPredicate {
@@ -341,13 +356,19 @@ impl fmt::Display for CustomPredicate {
341356 }
342357}
343358
344- #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize , JsonSchema ) ]
359+ #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize , JsonSchema ) ]
345360pub struct CustomPredicateBatch {
346361 id : Hash ,
347362 pub name : String ,
348363 pub ( crate ) predicates : Vec < CustomPredicate > ,
349364}
350365
366+ impl std:: hash:: Hash for CustomPredicateBatch {
367+ fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
368+ self . id . hash ( state) ;
369+ }
370+ }
371+
351372impl ToFields for CustomPredicateBatch {
352373 fn to_fields ( & self , params : & Params ) -> Vec < F > {
353374 // all the custom predicates in order
@@ -401,7 +422,7 @@ impl CustomPredicateBatch {
401422 }
402423}
403424
404- #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize , JsonSchema ) ]
425+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize , JsonSchema ) ]
405426pub struct CustomPredicateRef {
406427 pub batch : Arc < CustomPredicateBatch > ,
407428 pub index : usize ,
0 commit comments