77 trivial_casts,
88 trivial_numeric_casts,
99 unsafe_code,
10- unused_qualifications
10+ unused_qualifications,
11+ deprecated
1112) ]
1213
1314use adblock:: blocker:: BlockerError as RustBlockerError ;
@@ -99,15 +100,15 @@ pub struct BlockerResult {
99100pub error : Option < String > ,
100101}
101102
102- impl Into < BlockerResult > for RustBlockerResult {
103- fn into ( self ) ->BlockerResult {
104- BlockerResult {
105- matched : self . matched ,
106- important : self . important ,
107- redirect : self . redirect ,
108- exception : self . exception ,
109- filter : self . filter ,
110- error : self . error ,
103+ impl From < RustBlockerResult > for BlockerResult {
104+ fn from ( br : RustBlockerResult ) ->Self {
105+ Self {
106+ matched : br . matched ,
107+ important : br . important ,
108+ redirect : br . redirect ,
109+ exception : br . exception ,
110+ filter : br . filter ,
111+ error : br . error ,
111112}
112113}
113114}
@@ -166,27 +167,27 @@ create_exception!(adblock, OptimizedFilterExistence, BlockerException);
166167create_exception ! ( adblock, BadFilterAddUnsupported , BlockerException ) ;
167168create_exception ! ( adblock, FilterExists , BlockerException ) ;
168169
169- impl Into < PyErr > for BlockerError {
170- fn into ( self ) ->PyErr {
171- let msg =format ! ( "{:?}" , self ) ;
172- match self {
173- Self :: SerializationError =>PyErr :: new :: < SerializationError , _ > ( msg) ,
174- Self :: DeserializationError =>PyErr :: new :: < DeserializationError , _ > ( msg) ,
175- Self :: OptimizedFilterExistence =>PyErr :: new :: < OptimizedFilterExistence , _ > ( msg) ,
176- Self :: BadFilterAddUnsupported =>PyErr :: new :: < BadFilterAddUnsupported , _ > ( msg) ,
177- Self :: FilterExists =>PyErr :: new :: < FilterExists , _ > ( msg) ,
170+ impl From < BlockerError > for PyErr {
171+ fn from ( err : BlockerError ) ->Self {
172+ let msg =format ! ( "{:?}" , err ) ;
173+ match err {
174+ BlockerError :: SerializationError =>Self :: new :: < SerializationError , _ > ( msg) ,
175+ BlockerError :: DeserializationError =>Self :: new :: < DeserializationError , _ > ( msg) ,
176+ BlockerError :: OptimizedFilterExistence =>Self :: new :: < OptimizedFilterExistence , _ > ( msg) ,
177+ BlockerError :: BadFilterAddUnsupported =>Self :: new :: < BadFilterAddUnsupported , _ > ( msg) ,
178+ BlockerError :: FilterExists =>Self :: new :: < FilterExists , _ > ( msg) ,
178179}
179180}
180181}
181182
182- impl Into < BlockerError > for RustBlockerError {
183- fn into ( self ) ->BlockerError {
184- match self {
185- Self :: SerializationError =>BlockerError :: SerializationError ,
186- Self :: DeserializationError =>BlockerError :: DeserializationError ,
187- Self :: OptimizedFilterExistence =>BlockerError :: OptimizedFilterExistence ,
188- Self :: BadFilterAddUnsupported =>BlockerError :: BadFilterAddUnsupported ,
189- Self :: FilterExists =>BlockerError :: FilterExists ,
183+ impl From < RustBlockerError > for BlockerError {
184+ fn from ( err : RustBlockerError ) ->Self {
185+ match err {
186+ RustBlockerError :: SerializationError =>Self :: SerializationError ,
187+ RustBlockerError :: DeserializationError =>Self :: DeserializationError ,
188+ RustBlockerError :: OptimizedFilterExistence =>Self :: OptimizedFilterExistence ,
189+ RustBlockerError :: BadFilterAddUnsupported =>Self :: BadFilterAddUnsupported ,
190+ RustBlockerError :: FilterExists =>Self :: FilterExists ,
190191}
191192}
192193}
@@ -206,7 +207,7 @@ fn filter_format_from_string(filter_format: &str) -> PyResult<FilterFormat> {
206207/// created. FilterSet allows assembling a compound list from multiple
207208/// different sources before compiling the rules into an Engine.
208209#[ pyclass]
209- #[ text_signature ="($self, debug)" ]
210+ #[ pyo3 ( text_signature ="($self, debug)" ) ]
210211#[ derive( Clone ) ]
211212pub struct FilterSet {
212213filter_set : RustFilterSet ,
@@ -233,7 +234,7 @@ impl FilterSet {
233234///
234235/// The format is a string containing either "standard" (ABP/uBO-style)
235236/// or "hosts".
236- #[ text_signature ="($self, filter_list, format)" ]
237+ #[ pyo3 ( text_signature ="($self, filter_list, format)" ) ]
237238#[ args( filter_list, format ="\" standard\" " ) ]
238239pub fn add_filter_list ( & mut self , filter_list : & str , format : & str ) ->PyResult < ( ) > {
239240let filter_format =filter_format_from_string ( format) ?;
@@ -246,7 +247,7 @@ impl FilterSet {
246247///
247248/// The format is a string containing either "standard" (ABP/uBO-style)
248249/// or "hosts".
249- #[ text_signature ="($self, filters, format)" ]
250+ #[ pyo3 ( text_signature ="($self, filters, format)" ) ]
250251#[ args( filters, format ="\" standard\" " ) ]
251252pub fn add_filters ( & mut self , filters : Vec < String > , format : & str ) ->PyResult < ( ) > {
252253let filter_format =filter_format_from_string ( format) ?;
@@ -291,14 +292,14 @@ pub struct UrlSpecificResources {
291292pub generichide : bool ,
292293}
293294
294- impl Into < UrlSpecificResources > for RustUrlSpecificResources {
295- fn into ( self ) ->UrlSpecificResources {
296- UrlSpecificResources {
297- hide_selectors : self . hide_selectors ,
298- style_selectors : self . style_selectors ,
299- exceptions : self . exceptions ,
300- injected_script : self . injected_script ,
301- generichide : self . generichide ,
295+ impl From < RustUrlSpecificResources > for UrlSpecificResources {
296+ fn from ( r : RustUrlSpecificResources ) ->Self {
297+ Self {
298+ hide_selectors : r . hide_selectors ,
299+ style_selectors : r . style_selectors ,
300+ exceptions : r . exceptions ,
301+ injected_script : r . injected_script ,
302+ generichide : r . generichide ,
302303}
303304}
304305}
@@ -337,7 +338,7 @@ impl PyObjectProtocol for UrlSpecificResources {
337338///
338339/// [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType
339340#[ pyclass]
340- #[ text_signature ="($self, filter_set, optimize)" ]
341+ #[ pyo3 ( text_signature ="($self, filter_set, optimize)" ) ]
341342pub struct Engine {
342343engine : RustEngine ,
343344optimize : bool ,
@@ -361,7 +362,7 @@ impl Engine {
361362/// * `url` - The URL of the request to check
362363/// * `source_url` - The URL from where the request is made
363364/// * `request_type` - The resource type that the request points to
364- #[ text_signature ="($self, url, source_url, request_type)" ]
365+ #[ pyo3 ( text_signature ="($self, url, source_url, request_type)" ) ]
365366pub fn check_network_urls (
366367& self ,
367368url : & str ,
@@ -384,7 +385,9 @@ impl Engine {
384385/// * `third_party_request` - Is the given request to a third-party? Here,
385386/// `None` can be given and the engine will figure it out based on the
386387/// `hostname` and `source_hostname`.
387- #[ text_signature ="($self, url, hostname, source_hostname, requsest_type, third_party_request)" ]
388+ #[ pyo3(
389+ text_signature ="($self, url, hostname, source_hostname, requsest_type, third_party_request)"
390+ ) ]
388391pub fn check_network_urls_with_hostnames (
389392& self ,
390393url : & str ,
@@ -416,8 +419,10 @@ impl Engine {
416419/// * `previously_matched_rule` - Return a match as long as there are no
417420/// exceptions
418421/// * `force_check_exceptions` - Check exceptions even if no other rule matches
419- #[ text_signature ="($self, url, hostname, source_hostname, request_type,\
420- third_party_request, previously_matched_rule, force_check_exceptions)"]
422+ #[ pyo3(
423+ text_signature ="($self, url, hostname, source_hostname, request_type,\
424+ third_party_request, previously_matched_rule, force_check_exceptions)"
425+ ) ]
421426#[ allow( clippy:: too_many_arguments) ]
422427pub fn check_network_urls_with_hostnames_subset (
423428& self ,
@@ -443,7 +448,7 @@ impl Engine {
443448
444449/// Serialize this blocking engine to bytes. They can then be deserialized
445450/// using `deserialize()` to get the same engine again.
446- #[ text_signature ="($self)" ]
451+ #[ pyo3 ( text_signature ="($self)" ) ]
447452pub fn serialize < ' p > ( & mut self , py : Python < ' p > ) ->PyResult < & ' p PyBytes > {
448453let bytes =self . serialize_inner ( ) ?;
449454let py_bytes =PyBytes :: new ( py, & bytes) ;
@@ -464,7 +469,7 @@ impl Engine {
464469/// Serialize this blocking engine to a file. The file can then be
465470/// deserialized using `deserialize_from_file()` to get the same engine
466471/// again.
467- #[ text_signature ="($self, file)" ]
472+ #[ pyo3 ( text_signature ="($self, file)" ) ]
468473pub fn serialize_to_file ( & mut self , file : & str ) ->PyResult < ( ) > {
469474let data =self . serialize_inner ( ) ?;
470475let mut fd = fs:: OpenOptions :: new ( )
@@ -477,7 +482,7 @@ impl Engine {
477482}
478483
479484/// Deserialize a blocking engine from bytes produced with `serialize()`.
480- #[ text_signature ="($self, serialized)" ]
485+ #[ pyo3 ( text_signature ="($self, serialized)" ) ]
481486pub fn deserialize ( & mut self , serialized : & [ u8 ] ) ->PyResult < ( ) > {
482487let result =self . engine . deserialize ( serialized) ;
483488match result{
@@ -491,7 +496,7 @@ impl Engine {
491496
492497/// Deserialize a blocking engine from file produced with
493498/// `serialize_to_file()`.
494- #[ text_signature ="($self, file)" ]
499+ #[ pyo3 ( text_signature ="($self, file)" ) ]
495500pub fn deserialize_from_file ( & mut self , file : & str ) ->PyResult < ( ) > {
496501let mut fd = fs:: File :: open ( file) ?;
497502let mut data: Vec < u8 > =Vec :: new ( ) ;
@@ -500,7 +505,7 @@ impl Engine {
500505}
501506
502507/// Checks if the given filter exists in the blocking engine.
503- #[ text_signature ="($self, filter)" ]
508+ #[ pyo3 ( text_signature ="($self, filter)" ) ]
504509pub fn filter_exists ( & self , filter : & str ) ->bool {
505510self . engine . filter_exists ( filter)
506511}
@@ -509,7 +514,7 @@ impl Engine {
509514///
510515/// Tags can be used to cheaply enable or disable network rules with a
511516/// corresponding $tag option.
512- #[ text_signature ="($self, tags)" ]
517+ #[ pyo3 ( text_signature ="($self, tags)" ) ]
513518pub fn use_tags ( & mut self , tags : Vec < & str > ) {
514519self . engine . use_tags ( & tags) ;
515520}
@@ -519,7 +524,7 @@ impl Engine {
519524///
520525/// Tags can be used to cheaply enable or disable network rules with a
521526/// corresponding $tag option.
522- #[ text_signature ="($self, tags)" ]
527+ #[ pyo3 ( text_signature ="($self, tags)" ) ]
523528pub fn enable_tags ( & mut self , tags : Vec < & str > ) {
524529self . engine . enable_tags ( & tags) ;
525530}
@@ -529,7 +534,7 @@ impl Engine {
529534///
530535/// Tags can be used to cheaply enable or disable network rules with a
531536/// corresponding $tag option.
532- #[ text_signature ="($self, tags)" ]
537+ #[ pyo3 ( text_signature ="($self, tags)" ) ]
533538pub fn disable_tags ( & mut self , tags : Vec < & str > ) {
534539self . engine . disable_tags ( & tags) ;
535540}
@@ -538,7 +543,7 @@ impl Engine {
538543///
539544/// Tags can be used to cheaply enable or disable network rules with a
540545/// corresponding $tag option.
541- #[ text_signature ="($self, tag)" ]
546+ #[ pyo3 ( text_signature ="($self, tag)" ) ]
542547pub fn tag_exists ( & self , tag : & str ) ->bool {
543548self . engine . tag_exists ( tag)
544549}
@@ -547,7 +552,7 @@ impl Engine {
547552/// url. Once this has been called, all CSS ids and classes on a
548553/// page should be passed to hidden_class_id_selectors to obtain any
549554/// stylesheets consisting of generic rules.
550- #[ text_signature ="($self, url)" ]
555+ #[ pyo3 ( text_signature ="($self, url)" ) ]
551556pub fn url_cosmetic_resources ( & self , url : & str ) ->UrlSpecificResources {
552557self . engine . url_cosmetic_resources ( url) . into ( )
553558}
@@ -559,7 +564,7 @@ impl Engine {
559564/// are not excepted.
560565///
561566/// Exceptions should be passed directly from UrlSpecificResources.
562- #[ text_signature ="($self, classes, ids, exceptions)" ]
567+ #[ pyo3 ( text_signature ="($self, classes, ids, exceptions)" ) ]
563568pub fn hidden_class_id_selectors (
564569& self ,
565570classes : Vec < String > ,