config.rs (1205B)
1 use std::path::{Path, PathBuf}; 2 3 #[derive(Debug, Clone, Eq, PartialEq)] 4 pub struct RadrootsNostrNdbConfig { 5 db_dir: PathBuf, 6 mapsize_bytes: Option<usize>, 7 ingester_threads: Option<i32>, 8 skip_validation: bool, 9 } 10 11 impl RadrootsNostrNdbConfig { 12 pub fn new(db_dir: impl Into<PathBuf>) -> Self { 13 Self { 14 db_dir: db_dir.into(), 15 mapsize_bytes: None, 16 ingester_threads: None, 17 skip_validation: false, 18 } 19 } 20 21 pub fn db_dir(&self) -> &Path { 22 &self.db_dir 23 } 24 25 pub fn mapsize_bytes(&self) -> Option<usize> { 26 self.mapsize_bytes 27 } 28 29 pub fn ingester_threads(&self) -> Option<i32> { 30 self.ingester_threads 31 } 32 33 pub fn skip_validation(&self) -> bool { 34 self.skip_validation 35 } 36 37 pub fn with_mapsize_bytes(mut self, bytes: usize) -> Self { 38 self.mapsize_bytes = Some(bytes); 39 self 40 } 41 42 pub fn with_ingester_threads(mut self, threads: i32) -> Self { 43 self.ingester_threads = Some(threads); 44 self 45 } 46 47 pub fn with_skip_validation(mut self, skip_validation: bool) -> Self { 48 self.skip_validation = skip_validation; 49 self 50 } 51 }