diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 19 |
1 files changed, 16 insertions, 3 deletions
| @@ -230,7 +230,7 @@ impl PyObjectProtocol for HostnameSpecificResources { | |||
| 230 | /// | 230 | /// |
| 231 | /// [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType | 231 | /// [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType |
| 232 | #[pyclass] | 232 | #[pyclass] |
| 233 | #[text_signature = "($self, network_filters)"] | 233 | #[text_signature = "($self, network_filters=None, load_network=True, load_cosmetic=False, debug=False)"] |
| 234 | pub struct Engine { | 234 | pub struct Engine { |
| 235 | engine: RustEngine, | 235 | engine: RustEngine, |
| 236 | } | 236 | } |
| @@ -239,8 +239,21 @@ pub struct Engine { | |||
| 239 | impl Engine { | 239 | impl Engine { |
| 240 | /// Create a new adblocking engine | 240 | /// Create a new adblocking engine |
| 241 | #[new] | 241 | #[new] |
| 242 | pub fn from_rules(network_filters: Vec<String>) -> Self { | 242 | #[args(network_filters="None", load_network=true, load_cosmetic=false, debug=false)] |
| 243 | let engine = RustEngine::from_rules(&network_filters); | 243 | pub fn new( |
| 244 | network_filters: Option<Vec<String>>, | ||
| 245 | load_network: bool, | ||
| 246 | load_cosmetic: bool, | ||
| 247 | debug: bool, | ||
| 248 | ) -> Self { | ||
| 249 | let filters = network_filters.unwrap_or(Vec::new()); | ||
| 250 | let engine = RustEngine::from_rules_parametrised( | ||
| 251 | &filters, | ||
| 252 | load_network, | ||
| 253 | load_cosmetic, | ||
| 254 | debug, | ||
| 255 | true, | ||
| 256 | ); | ||
| 244 | Self { engine } | 257 | Self { engine } |
| 245 | } | 258 | } |
| 246 | 259 | ||
