zendriver_interception/lib.rs
1//! Network interception via the `Fetch` CDP domain.
2//!
3//! See the [Interception chapter](https://turtiesocks.github.io/zendriver-rs/interception.html)
4//! of the [zendriver-rs user guide](https://turtiesocks.github.io/zendriver-rs/)
5//! for narrative examples, glob/regex pattern semantics, and streaming-mode
6//! recipes.
7//!
8//! Two entry points, both built off [`InterceptBuilder`]:
9//!
10//! - **Rule-based** — chain
11//! [`block`](builder::InterceptBuilder::block) /
12//! [`redirect`](builder::InterceptBuilder::redirect) /
13//! [`respond`](builder::InterceptBuilder::respond) /
14//! [`modify_request`](builder::InterceptBuilder::modify_request) and call
15//! [`start`](builder::InterceptBuilder::start). The returned
16//! [`InterceptHandle`] tears the actor down on drop.
17//! - **Stream** — call
18//! [`subscribe`](builder::InterceptBuilder::subscribe) to get a `Stream` of
19//! [`PausedRequest`]; release each pause by calling one of
20//! [`continue_`](PausedRequest::continue_), [`abort`](PausedRequest::abort),
21//! [`respond`](PausedRequest::respond), or
22//! [`modify_and_continue`](PausedRequest::modify_and_continue).
23//!
24//! ```no_run
25//! # async fn ex(tab: &zendriver_transport::SessionHandle)
26//! # -> Result<(), zendriver_interception::InterceptionError> {
27//! use zendriver_interception::InterceptBuilder;
28//!
29//! let _handle = InterceptBuilder::new(tab)
30//! .block("*/ads/*")?
31//! .redirect("*/old/*", "https://example.com/new/")?
32//! .start();
33//! // _handle stays in scope -> interception live.
34//! # Ok(()) }
35//! ```
36
37pub mod actor;
38pub mod builder;
39pub mod error;
40pub mod paused;
41pub mod rule;
42pub mod types;
43pub mod url_pattern;
44
45pub use actor::InterceptHandle;
46pub use builder::{InterceptBuilder, RequestPattern};
47pub use error::InterceptionError;
48pub use paused::PausedRequest;
49pub use rule::Rule;
50pub use types::{
51 AbortReason, RequestInfo, RequestOverrides, RequestStage, ResourceType, ResponseInfo,
52 ResponseOverrides,
53};