pub struct MonitorBuilder { /* private fields */ }monitor only.Expand description
Builder for a NetworkMonitor. Configure an optional URL filter, then
call Self::start to spawn the correlator task.
Obtained via crate::Tab::monitor.
Implementations§
Source§impl MonitorBuilder
impl MonitorBuilder
Sourcepub fn url_pattern(self, pattern: impl Into<UrlMatcher>) -> Self
pub fn url_pattern(self, pattern: impl Into<UrlMatcher>) -> Self
Restrict emitted events to those whose URL matches pattern.
Accepts anything convertible into a UrlMatcher: a &str / String
(substring match) or a regex::Regex. For HTTP exchanges the request
URL is matched; for WebSocket / EventSource events the connection URL
observed at open time is matched.
§Examples
// Only surface requests whose URL contains "/api/".
let monitor = tab.monitor().url_pattern("/api/").start().await?;Sourcepub async fn start(self) -> Result<NetworkMonitor>
pub async fn start(self) -> Result<NetworkMonitor>
Spawn the correlator task and return a live NetworkMonitor.
The task subscribes to the session’s raw CDP event stream and runs
until the monitor is dropped or NetworkMonitor::stop is called.
§Errors
Currently infallible, but returns crate::Result so future setup
(e.g. an explicit Network.enable round-trip) can surface errors
without an API break.