nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

config.rs (1010B)


      1 use crate::bindings;
      2 
      3 // The Rust wrapper for ndb_config
      4 pub struct NdbConfig {
      5     pub config: bindings::ndb_config,
      6 }
      7 
      8 impl NdbConfig {
      9     // Constructor
     10     pub fn new() -> Self {
     11         let mut config = bindings::ndb_config {
     12             filter_context: std::ptr::null_mut(),
     13             ingest_filter: None,
     14             flags: 0,
     15             ingester_threads: 0,
     16             mapsize: 0,
     17         };
     18 
     19         unsafe {
     20             bindings::ndb_default_config(&mut config);
     21         }
     22 
     23         NdbConfig { config }
     24     }
     25 
     26     // Example setter methods
     27     pub fn set_flags(&mut self, flags: i32) -> &mut Self {
     28         self.config.flags = flags;
     29         self
     30     }
     31 
     32     pub fn set_ingester_threads(&mut self, threads: i32) -> &mut Self {
     33         self.config.ingester_threads = threads;
     34         self
     35     }
     36 
     37     // Add other setter methods as needed
     38 
     39     // Internal method to get a raw pointer to the config, used in Ndb
     40     pub fn as_ptr(&self) -> *const bindings::ndb_config {
     41         &self.config
     42     }
     43 }