summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fc837b8..bef0fb2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -45,11 +45,6 @@ fn adblock(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
45pub struct BlockerResult { 45pub struct BlockerResult {
46 #[pyo3(get)] 46 #[pyo3(get)]
47 pub matched: bool, 47 pub matched: bool,
48 /// Normally, Brave Browser returns `200 OK` with an empty body when
49 /// `matched` is `True`, except if `explicit_cancel` is also `True`, in
50 /// which case the request is cancelled.
51 #[pyo3(get)]
52 pub explicit_cancel: bool,
53 /// Important is used to signal that a rule with the `important` option 48 /// Important is used to signal that a rule with the `important` option
54 /// matched. An `important` match means that exceptions should not apply 49 /// matched. An `important` match means that exceptions should not apply
55 /// and no further checking is neccesary--the request should be blocked 50 /// and no further checking is neccesary--the request should be blocked
@@ -91,7 +86,6 @@ impl Into<BlockerResult> for RustBlockerResult {
91 fn into(self) -> BlockerResult { 86 fn into(self) -> BlockerResult {
92 BlockerResult { 87 BlockerResult {
93 matched: self.matched, 88 matched: self.matched,
94 explicit_cancel: self.explicit_cancel,
95 important: self.important, 89 important: self.important,
96 redirect: self.redirect, 90 redirect: self.redirect,
97 exception: self.exception, 91 exception: self.exception,
@@ -105,14 +99,8 @@ impl Into<BlockerResult> for RustBlockerResult {
105impl PyObjectProtocol for BlockerResult { 99impl PyObjectProtocol for BlockerResult {
106 fn __repr__(&self) -> PyResult<String> { 100 fn __repr__(&self) -> PyResult<String> {
107 Ok(format!( 101 Ok(format!(
108 "BlockerResult({}, {}, {}, {:?}, {:?}, {:?}, {:?})", 102 "BlockerResult({}, {}, {:?}, {:?}, {:?}, {:?})",
109 self.matched, 103 self.matched, self.important, self.redirect, self.exception, self.filter, self.error
110 self.explicit_cancel,
111 self.important,
112 self.redirect,
113 self.exception,
114 self.filter,
115 self.error
116 )) 104 ))
117 } 105 }
118} 106}
@@ -249,6 +237,11 @@ pub struct UrlSpecificResources {
249 /// page. 237 /// page.
250 #[pyo3(get)] 238 #[pyo3(get)]
251 pub injected_script: String, 239 pub injected_script: String,
240 /// `generichide` is set to `True` if there is a corresponding
241 /// `$generichide` exception network filter. If so, the page should not
242 /// query for additional generic rules using hidden_class_id_selectors.
243 #[pyo3(get)]
244 pub generichide: bool,
252} 245}
253 246
254impl Into<UrlSpecificResources> for RustUrlSpecificResources { 247impl Into<UrlSpecificResources> for RustUrlSpecificResources {
@@ -258,6 +251,7 @@ impl Into<UrlSpecificResources> for RustUrlSpecificResources {
258 style_selectors: self.style_selectors, 251 style_selectors: self.style_selectors,
259 exceptions: self.exceptions, 252 exceptions: self.exceptions,
260 injected_script: self.injected_script, 253 injected_script: self.injected_script,
254 generichide: self.generichide,
261 } 255 }
262 } 256 }
263} 257}
@@ -266,11 +260,12 @@ impl Into<UrlSpecificResources> for RustUrlSpecificResources {
266impl PyObjectProtocol for UrlSpecificResources { 260impl PyObjectProtocol for UrlSpecificResources {
267 fn __repr__(&self) -> PyResult<String> { 261 fn __repr__(&self) -> PyResult<String> {
268 Ok(format!( 262 Ok(format!(
269 "UrlSpecificResources<{} hide selectors, {} style selectors, {} exceptions, injected_javascript={:?}>", 263 "UrlSpecificResources<{} hide selectors, {} style selectors, {} exceptions, injected_javascript={:?}, generichide={}>",
270 self.hide_selectors.len(), 264 self.hide_selectors.len(),
271 self.style_selectors.len(), 265 self.style_selectors.len(),
272 self.exceptions.len(), 266 self.exceptions.len(),
273 self.injected_script, 267 self.injected_script,
268 self.generichide,
274 )) 269 ))
275 } 270 }
276} 271}