summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1036c6d..af486ed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -212,6 +212,7 @@ impl PyObjectProtocol for HostnameSpecificResources {
212} 212}
213 213
214#[pyclass] 214#[pyclass]
215#[text_signature = "($self, network_filters)"]
215pub struct Engine { 216pub struct Engine {
216 engine: RustEngine, 217 engine: RustEngine,
217} 218}
@@ -235,6 +236,7 @@ impl Engine {
235 /// * `script` 236 /// * `script`
236 /// * `stylesheet` 237 /// * `stylesheet`
237 /// * and et cetera... 238 /// * and et cetera...
239 #[text_signature = "($self, url, source_url, request_type)"]
238 pub fn check_network_urls( 240 pub fn check_network_urls(
239 &self, 241 &self,
240 url: &str, 242 url: &str,
@@ -247,6 +249,7 @@ impl Engine {
247 blocker_result.into() 249 blocker_result.into()
248 } 250 }
249 251
252 #[text_signature = "($self, url, hostname, source_hostname, requsest_type, third_party_request)"]
250 pub fn check_network_urls_with_hostnames( 253 pub fn check_network_urls_with_hostnames(
251 &self, 254 &self,
252 url: &str, 255 url: &str,
@@ -265,6 +268,8 @@ impl Engine {
265 blocker_result.into() 268 blocker_result.into()
266 } 269 }
267 270
271 #[text_signature = "($self, url, hostname, source_hostname, request_type, \
272 third_party_request, previously_matched_rule, force_check_exceptions)"]
268 #[allow(clippy::too_many_arguments)] 273 #[allow(clippy::too_many_arguments)]
269 pub fn check_network_urls_with_hostnames_subset( 274 pub fn check_network_urls_with_hostnames_subset(
270 &self, 275 &self,
@@ -290,6 +295,7 @@ impl Engine {
290 295
291 /// Serialize this blocking engine to bytes. They can then be deserialized 296 /// Serialize this blocking engine to bytes. They can then be deserialized
292 /// using `deserialize()` to get the same engine again. 297 /// using `deserialize()` to get the same engine again.
298 #[text_signature = "($self)"]
293 pub fn serialize(&mut self) -> PyResult<Vec<u8>> { 299 pub fn serialize(&mut self) -> PyResult<Vec<u8>> {
294 let result = self.engine.serialize(); 300 let result = self.engine.serialize();
295 match result { 301 match result {
@@ -304,6 +310,7 @@ impl Engine {
304 /// Serialize this blocking engine to a file. The file can then be 310 /// Serialize this blocking engine to a file. The file can then be
305 /// deserialized using `deserialize_from_file()` to get the same engine 311 /// deserialized using `deserialize_from_file()` to get the same engine
306 /// again. 312 /// again.
313 #[text_signature = "($self, file)"]
307 pub fn serialize_to_file(&mut self, file: &str) -> PyResult<()> { 314 pub fn serialize_to_file(&mut self, file: &str) -> PyResult<()> {
308 let data = self.serialize()?; 315 let data = self.serialize()?;
309 let mut fd = fs::OpenOptions::new() 316 let mut fd = fs::OpenOptions::new()
@@ -316,6 +323,7 @@ impl Engine {
316 } 323 }
317 324
318 /// Deserialize a blocking engine from bytes produced with `serialize()`. 325 /// Deserialize a blocking engine from bytes produced with `serialize()`.
326 #[text_signature = "($self, serialized)"]
319 pub fn deserialize(&mut self, serialized: &[u8]) -> PyResult<()> { 327 pub fn deserialize(&mut self, serialized: &[u8]) -> PyResult<()> {
320 let result = self.engine.deserialize(serialized); 328 let result = self.engine.deserialize(serialized);
321 match result { 329 match result {
@@ -329,6 +337,7 @@ impl Engine {
329 337
330 /// Deserialize a blocking engine from file produced with 338 /// Deserialize a blocking engine from file produced with
331 /// `serialize_to_file()`. 339 /// `serialize_to_file()`.
340 #[text_signature = "($self, file)"]
332 pub fn deserialize_from_file(&mut self, file: &str) -> PyResult<()> { 341 pub fn deserialize_from_file(&mut self, file: &str) -> PyResult<()> {
333 let mut fd = fs::File::open(file)?; 342 let mut fd = fs::File::open(file)?;
334 let mut data: Vec<u8> = Vec::new(); 343 let mut data: Vec<u8> = Vec::new();
@@ -337,23 +346,28 @@ impl Engine {
337 } 346 }
338 347
339 /// Add the contents of a block list file to the blocking engine. 348 /// Add the contents of a block list file to the blocking engine.
349 #[text_signature = "($self, filter_list)"]
340 pub fn add_filter_list(&mut self, filter_list: &str) { 350 pub fn add_filter_list(&mut self, filter_list: &str) {
341 self.engine.add_filter_list(filter_list); 351 self.engine.add_filter_list(filter_list);
342 } 352 }
343 353
344 /// Checks if the given filter exists in the blocking engine. 354 /// Checks if the given filter exists in the blocking engine.
355 #[text_signature = "($self, filter)"]
345 pub fn filter_exists(&self, filter: &str) -> bool { 356 pub fn filter_exists(&self, filter: &str) -> bool {
346 self.engine.filter_exists(filter) 357 self.engine.filter_exists(filter)
347 } 358 }
348 359
360 #[text_signature = "($self, tags)"]
349 pub fn tags_enable(&mut self, tags: Vec<&str>) { 361 pub fn tags_enable(&mut self, tags: Vec<&str>) {
350 self.engine.tags_enable(&tags); 362 self.engine.tags_enable(&tags);
351 } 363 }
352 364
365 #[text_signature = "($self, tags)"]
353 pub fn tags_disable(&mut self, tags: Vec<&str>) { 366 pub fn tags_disable(&mut self, tags: Vec<&str>) {
354 self.engine.tags_disable(&tags); 367 self.engine.tags_disable(&tags);
355 } 368 }
356 369
370 #[text_signature = "($self, tag)"]
357 pub fn tag_exists(&self, tag: &str) -> bool { 371 pub fn tag_exists(&self, tag: &str) -> bool {
358 self.engine.tag_exists(tag) 372 self.engine.tag_exists(tag)
359 } 373 }
@@ -362,6 +376,7 @@ impl Engine {
362 /// hostname. Once this has been called, all CSS ids and classes on a 376 /// hostname. Once this has been called, all CSS ids and classes on a
363 /// page should be passed to hidden_class_id_selectors to obtain any 377 /// page should be passed to hidden_class_id_selectors to obtain any
364 /// stylesheets consisting of generic rules. 378 /// stylesheets consisting of generic rules.
379 #[text_signature = "($self, hostname)"]
365 pub fn hostname_cosmetic_resources(&self, hostname: &str) -> HostnameSpecificResources { 380 pub fn hostname_cosmetic_resources(&self, hostname: &str) -> HostnameSpecificResources {
366 self.engine.hostname_cosmetic_resources(hostname).into() 381 self.engine.hostname_cosmetic_resources(hostname).into()
367 } 382 }
@@ -377,6 +392,7 @@ impl Engine {
377 /// ## Note 392 /// ## Note
378 /// The `exceptions` field will be changed to a set, once a new version of 393 /// The `exceptions` field will be changed to a set, once a new version of
379 /// PyO3 is released. 394 /// PyO3 is released.
395 #[text_signature = "($self, classes, ids, exceptions)"]
380 pub fn hidden_class_id_selectors( 396 pub fn hidden_class_id_selectors(
381 &self, 397 &self,
382 classes: Vec<String>, 398 classes: Vec<String>,