nostrdb-rs

nostrdb in rust!
git clone git://jb55.com/nostrdb-rs
Log | Files | Refs | Submodules | README | LICENSE

commit 5c3beed3cfefdf786923dd2f2114b24b543f17c3
parent 9a9c15709b8287ad2e08575c5b3b2c7143b49df1
Author: William Casarin <jb55@jb55.com>
Date:   Wed,  7 Feb 2024 14:24:05 -0800

filter: add a few more missing fields

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/filter.rs | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/filter.rs b/src/filter.rs @@ -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'); } @@ -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 {