summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 35d8519..579e6ed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,8 +19,10 @@ use pyo3::exceptions::ValueError as PyValueError;
19use pyo3::prelude::*; 19use pyo3::prelude::*;
20use pyo3::PyErr; 20use pyo3::PyErr;
21 21
22use std::collections::HashSet;
22use std::fs; 23use std::fs;
23use std::io::{Read, Write}; 24use std::io::{Read, Write};
25use std::iter::FromIterator;
24 26
25/// Brave's adblocking library in Python! 27/// Brave's adblocking library in Python!
26#[pymodule] 28#[pymodule]
@@ -246,18 +248,26 @@ impl Engine {
246 self.engine.tag_exists(tag) 248 self.engine.tag_exists(tag)
247 } 249 }
248 250
249 // pub fn hidden_class_id_selectors( 251 /// If any of the provided CSS classes or ids could cause a certain generic
250 // &self, 252 /// CSS hide rule (i.e. `{ display: none !important; }`) to be required, this
251 // classes: Vec<String>, 253 /// method will return a list of CSS selectors corresponding to rules
252 // ids: Vec<String>, 254 /// referencing those classes or ids, provided that the corresponding rules
253 // exceptions: &PySet, 255 /// are not excepted.
254 // ) -> PyResult<Vec<String>> { 256 ///
255 // let mut exception_hashset: HashSet<String> = HashSet::new(); 257 /// Exceptions should be passed directly from HostnameSpecificResources.
256 // for exception in exceptions.iter() { 258 ///
257 // let exception_pystr = PyString::from(exception); 259 /// ## Note
258 // exception_hashset.insert(exception.to_string()); 260 /// The `exceptions` field will be changed to a set, once a new version of
259 // } 261 /// PyO3 is released.
260 // Ok(self.engine 262 pub fn hidden_class_id_selectors(
261 // .hidden_class_id_selectors(&classes, &ids, &exception_hashset)) 263 &self,
262 // } 264 classes: Vec<String>,
265 ids: Vec<String>,
266 exceptions: Vec<String>,
267 ) -> PyResult<Vec<String>> {
268 let exception_hashset: HashSet<String> = HashSet::from_iter(exceptions);
269 Ok(self
270 .engine
271 .hidden_class_id_selectors(&classes, &ids, &exception_hashset))
272 }
263} 273}