nostrdb: ndb_filter_{eq,is_subset_of}: make interfaces const
this makes rust happier Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
573de6b881
commit
de0935582c
@@ -2672,7 +2672,7 @@ ndb_filter_find_elements(struct ndb_filter *filter, enum ndb_filter_fieldtype ty
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ndb_filter_is_subset_of(struct ndb_filter *a, struct ndb_filter *b)
|
int ndb_filter_is_subset_of(const struct ndb_filter *a, const struct ndb_filter *b)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct ndb_filter_elements *b_field, *a_field;
|
struct ndb_filter_elements *b_field, *a_field;
|
||||||
@@ -2700,20 +2700,22 @@ int ndb_filter_is_subset_of(struct ndb_filter *a, struct ndb_filter *b)
|
|||||||
// A is a subset of B because `k:1` and `a:b` both exist in A
|
// A is a subset of B because `k:1` and `a:b` both exist in A
|
||||||
|
|
||||||
for (i = 0; i < b->num_elements; i++) {
|
for (i = 0; i < b->num_elements; i++) {
|
||||||
b_field = ndb_filter_get_elements(b, i);
|
b_field = ndb_filter_get_elements((struct ndb_filter*)b, i);
|
||||||
a_field = ndb_filter_find_elements(a, b_field->field.type);
|
a_field = ndb_filter_find_elements((struct ndb_filter*)a,
|
||||||
|
b_field->field.type);
|
||||||
|
|
||||||
if (a_field == NULL)
|
if (a_field == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!ndb_filter_field_eq(a, a_field, b, b_field))
|
if (!ndb_filter_field_eq((struct ndb_filter*)a, a_field,
|
||||||
|
(struct ndb_filter*)b, b_field))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ndb_filter_eq(struct ndb_filter *a, struct ndb_filter *b)
|
int ndb_filter_eq(const struct ndb_filter *a, const struct ndb_filter *b)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct ndb_filter_elements *a_els, *b_els;
|
struct ndb_filter_elements *a_els, *b_els;
|
||||||
@@ -2722,13 +2724,15 @@ int ndb_filter_eq(struct ndb_filter *a, struct ndb_filter *b)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < a->num_elements; i++) {
|
for (i = 0; i < a->num_elements; i++) {
|
||||||
a_els = ndb_filter_get_elements(a, i);
|
a_els = ndb_filter_get_elements((struct ndb_filter*)a, i);
|
||||||
b_els = ndb_filter_find_elements(b, a_els->field.type);
|
b_els = ndb_filter_find_elements((struct ndb_filter *)b,
|
||||||
|
a_els->field.type);
|
||||||
|
|
||||||
if (b_els == NULL)
|
if (b_els == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!ndb_filter_field_eq(a, a_els, b, b_els))
|
if (!ndb_filter_field_eq((struct ndb_filter*)a, a_els,
|
||||||
|
(struct ndb_filter*)b, b_els))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -497,10 +497,10 @@ int ndb_filter_init(struct ndb_filter *);
|
|||||||
int ndb_filter_add_id_element(struct ndb_filter *, const unsigned char *id);
|
int ndb_filter_add_id_element(struct ndb_filter *, const unsigned char *id);
|
||||||
int ndb_filter_add_int_element(struct ndb_filter *, uint64_t integer);
|
int ndb_filter_add_int_element(struct ndb_filter *, uint64_t integer);
|
||||||
int ndb_filter_add_str_element(struct ndb_filter *, const char *str);
|
int ndb_filter_add_str_element(struct ndb_filter *, const char *str);
|
||||||
int ndb_filter_eq(struct ndb_filter *, struct ndb_filter *);
|
int ndb_filter_eq(const struct ndb_filter *, const struct ndb_filter *);
|
||||||
|
|
||||||
/// is `a` a subset of `b`
|
/// is `a` a subset of `b`
|
||||||
int ndb_filter_is_subset_of(struct ndb_filter *a, struct ndb_filter *b);
|
int ndb_filter_is_subset_of(const struct ndb_filter *a, const struct ndb_filter *b);
|
||||||
|
|
||||||
// filters from json
|
// filters from json
|
||||||
int ndb_filter_from_json(const char *, int len, struct ndb_filter *filter, unsigned char *buf, int bufsize);
|
int ndb_filter_from_json(const char *, int len, struct ndb_filter *filter, unsigned char *buf, int bufsize);
|
||||||
|
|||||||
Reference in New Issue
Block a user