Skip to content

Commit

Permalink
filter: make a few low level functions public
Browse files Browse the repository at this point in the history
I think the friendly ones are not that ergonomic. Maybe we should
fix those.

Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Jul 16, 2024
1 parent c870c70 commit a503cb2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ impl FilterBuilder {
unsafe { bindings::ndb_filter_add_int_element(self.as_mut_ptr(), i) };
}

fn add_str_element(&mut self, s: &str) {
pub fn add_str_element(&mut self, s: &str) {
let c_str = CString::new(s).expect("string to cstring conversion failed");
unsafe {
bindings::ndb_filter_add_str_element(self.as_mut_ptr(), c_str.as_ptr());
};
}

fn add_id_element(&mut self, id: &[u8; 32]) {
pub fn add_id_element(&mut self, id: &[u8; 32]) {
let ptr: *const ::std::os::raw::c_uchar = id.as_ptr() as *const ::std::os::raw::c_uchar;
unsafe {
bindings::ndb_filter_add_id_element(self.as_mut_ptr(), ptr);
Expand All @@ -133,7 +133,7 @@ impl FilterBuilder {
unsafe { bindings::ndb_filter_start_field(self.as_mut_ptr(), field) };
}

fn start_tags_field(&mut self, tag: char) {
pub fn start_tags_field(&mut self, tag: char) {
unsafe { bindings::ndb_filter_start_tag_field(self.as_mut_ptr(), tag as u8 as c_char) };
}

Expand Down Expand Up @@ -170,11 +170,11 @@ impl FilterBuilder {
self.start_tags_field('p');
}

fn start_tag_field(&mut self, tag: char) {
pub fn start_tag_field(&mut self, tag: char) {
unsafe { bindings::ndb_filter_start_tag_field(self.as_mut_ptr(), tag as u8 as c_char) };
}

fn end_field(&mut self) {
pub fn end_field(&mut self) {
unsafe { bindings::ndb_filter_end_field(self.as_mut_ptr()) }
}

Expand Down

0 comments on commit a503cb2

Please sign in to comment.