Skip to content

Commit

Permalink
filter: add a few more missing fields
Browse files Browse the repository at this point in the history
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Feb 7, 2024
1 parent 9a9c157 commit 5c3beed
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl Filter {
self.start_field(bindings::ndb_filter_fieldtype_NDB_FILTER_LIMIT);
}

fn start_ids_field(&self) {
self.start_field(bindings::ndb_filter_fieldtype_NDB_FILTER_IDS);
}

fn start_events_field(&self) {
self.start_tags_field('e');
}
Expand All @@ -117,6 +121,33 @@ impl Filter {
unsafe { bindings::ndb_filter_end_field(self.as_mut_ptr()) }
}

pub fn events(self, events: Vec<&[u8; 32]>) -> Filter {
self.start_tag_field('e');
for id in events {
self.add_id_element(id);
}
self.end_field();
self
}

pub fn ids(self, ids: Vec<&[u8; 32]>) -> Filter {
self.start_ids_field();
for id in ids {
self.add_id_element(id);
}
self.end_field();
self
}

pub fn pubkeys(self, pubkeys: Vec<&[u8; 32]>) -> Filter {
self.start_tag_field('p');
for pk in pubkeys {
self.add_id_element(pk);
}
self.end_field();
self
}

pub fn authors(self, authors: Vec<&[u8; 32]>) -> Filter {
self.start_authors_field();
for author in authors {
Expand Down

0 comments on commit 5c3beed

Please sign in to comment.