Skip to content

Commit

Permalink
Simplify Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
c3rb3ru5d3d53c committed Dec 20, 2024
1 parent 4307641 commit 5f13af3
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 6 deletions.
120 changes: 120 additions & 0 deletions src/bindings/python/src/global/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ impl ConfigChromosomesHashingTLSH {
inner.chromosomes.hashing.tlsh.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.chromosomes.hashing.tlsh.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.chromosomes.hashing.tlsh.threshold = value;
}

#[getter]
pub fn get_minimum_byte_size(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -434,6 +446,18 @@ impl ConfigChromosomesHashingMinhash {
inner.chromosomes.hashing.minhash.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.chromosomes.hashing.minhash.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.chromosomes.hashing.minhash.threshold = value;
}

#[getter]
pub fn get_number_of_hashes(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -670,6 +694,18 @@ impl ConfigFunctionsHashingTLSH {
inner.functions.hashing.tlsh.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.functions.hashing.tlsh.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.functions.hashing.tlsh.threshold = value;
}

#[getter]
pub fn get_minimum_byte_size(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -703,6 +739,18 @@ impl ConfigFunctionsHashingMinhash {
inner.functions.hashing.minhash.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.functions.hashing.minhash.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.functions.hashing.minhash.threshold = value;
}

#[getter]
pub fn get_number_of_hashes(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -1103,6 +1151,18 @@ impl ConfigInstructionsHashingTLSH {
inner.instructions.hashing.tlsh.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.instructions.hashing.tlsh.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.instructions.hashing.tlsh.threshold = value;
}

#[getter]
pub fn get_minimum_byte_size(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -1135,6 +1195,18 @@ impl ConfigInstructionsHashingMinhash {
inner.instructions.hashing.minhash.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.instructions.hashing.minhash.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.instructions.hashing.minhash.threshold = value;
}

#[getter]
pub fn get_number_of_hashes(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -1215,6 +1287,18 @@ impl ConfigBlocksHashingTLSH {
inner.blocks.hashing.tlsh.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.blocks.hashing.tlsh.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.blocks.hashing.tlsh.threshold = value;
}

#[getter]
pub fn get_minimum_byte_size(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -1248,6 +1332,18 @@ impl ConfigBlocksHashingMinhash {
inner.blocks.hashing.minhash.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.blocks.hashing.minhash.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.blocks.hashing.minhash.threshold = value;
}

#[getter]
pub fn get_number_of_hashes(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -1480,6 +1576,18 @@ impl ConfigFormatsFileHashingTLSH {
inner.formats.file.hashing.tlsh.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.formats.file.hashing.tlsh.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.formats.file.hashing.tlsh.threshold = value;
}

#[getter]
pub fn get_minimum_byte_size(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down Expand Up @@ -1513,6 +1621,18 @@ impl ConfigFormatsFileHashingMinhash {
inner.formats.file.hashing.minhash.enabled = value;
}

#[getter]
pub fn get_threshold(&self) -> f64 {
let inner = self.inner.lock().unwrap();
inner.formats.file.hashing.minhash.threshold
}

#[setter]
pub fn set_threshold(&mut self, value: f64) {
let mut inner = self.inner.lock().unwrap();
inner.formats.file.hashing.minhash.threshold = value;
}

#[getter]
pub fn get_number_of_hashes(&self) -> usize {
let inner = self.inner.lock().unwrap();
Expand Down
12 changes: 6 additions & 6 deletions src/global/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ pub struct ConfigMinhash {
pub struct ConfigTLSH {
pub enabled: bool,
pub minimum_byte_size: usize,
pub threshold: usize,
pub threshold: f64,
}

#[derive(Serialize, Deserialize, Clone)]
Expand All @@ -367,7 +367,7 @@ impl Config {
tlsh: ConfigTLSH {
enabled: true,
minimum_byte_size: 50,
threshold: 200,
threshold: 200.0,
},
minhash: ConfigMinhash {
enabled: true,
Expand Down Expand Up @@ -398,7 +398,7 @@ impl Config {
tlsh: ConfigTLSH {
enabled: true,
minimum_byte_size: 50,
threshold: 200,
threshold: 200.0,
},
minhash: ConfigMinhash {
enabled: true,
Expand Down Expand Up @@ -431,7 +431,7 @@ impl Config {
tlsh: ConfigTLSH {
enabled: true,
minimum_byte_size: 50,
threshold: 200,
threshold: 200.0,
},
minhash: ConfigMinhash {
enabled: true,
Expand Down Expand Up @@ -464,7 +464,7 @@ impl Config {
tlsh: ConfigTLSH {
enabled: true,
minimum_byte_size: 50,
threshold: 200,
threshold: 200.0,
},
minhash: ConfigMinhash {
enabled: true,
Expand Down Expand Up @@ -493,7 +493,7 @@ impl Config {
tlsh: ConfigTLSH {
enabled: true,
minimum_byte_size: 50,
threshold: 200,
threshold: 200.0,
},
minhash: ConfigMinhash {
enabled: true,
Expand Down

0 comments on commit 5f13af3

Please sign in to comment.