pub struct NetworkCollector { /* private fields */ }Expand description
Drains Network.* events into a NetworkLog. Optionally tracks
matching entries for body capture via [take_finished] and collects
WebSocket frames / SSE events when capture_ws / capture_sse are set.
Implementations§
Source§impl NetworkCollector
impl NetworkCollector
pub fn start( conn: &Connection, redact_headers: bool, capture_ws: bool, capture_sse: bool, ) -> Self
Sourcepub async fn take_ws_frames(&self) -> HashMap<String, Vec<Value>>
pub async fn take_ws_frames(&self) -> HashMap<String, Vec<Value>>
Return all collected WebSocket frames, keyed by requestId.
Sourcepub async fn take_sse_events(&self) -> HashMap<String, Vec<Value>>
pub async fn take_sse_events(&self) -> HashMap<String, Vec<Value>>
Return all collected SSE events, keyed by requestId.
Sourcepub async fn wait_for_main_status(
&self,
timeout: Duration,
) -> Option<NetworkEntry>
pub async fn wait_for_main_status( &self, timeout: Duration, ) -> Option<NetworkEntry>
Wait until the main-document entry has a status or failure, or
until timeout elapses. Returns whatever main_entry is at that
point (possibly None if the navigation never produced a Document
resource — e.g. data: URLs).
Sourcepub async fn take_finished(&self) -> Vec<String>
pub async fn take_finished(&self) -> Vec<String>
Return request_ids whose Network.loadingFinished event has been
observed since the last call. The internal “finished” buffer is
drained.
Sourcepub async fn entry(&self, request_id: &str) -> Option<NetworkEntry>
pub async fn entry(&self, request_id: &str) -> Option<NetworkEntry>
Look up the current state of an entry by request_id (e.g. to read
resource_type or mime_type before issuing
Network.getResponseBody).
pub async fn main_request_id(&self) -> Option<String>
pub async fn main_entry(&self) -> Option<NetworkEntry>
Sourcepub async fn quiet_snapshot(&self, idle: Duration) -> NetworkQuietSnapshot
pub async fn quiet_snapshot(&self, idle: Duration) -> NetworkQuietSnapshot
Mechanical network quiet signal for readiness: no pending/responded
requests, and no Network.* activity for at least idle.
Sourcepub async fn set_body_file(&self, request_id: &str, path: PathBuf)
pub async fn set_body_file(&self, request_id: &str, path: PathBuf)
Attach a captured body file path to the entry.
Sourcepub async fn set_hint(&self, request_id: &str, key: &str, value: Value)
pub async fn set_hint(&self, request_id: &str, key: &str, value: Value)
Stamp a free-form hint onto an entry.
Sourcepub async fn finish(self) -> NetworkLog
pub async fn finish(self) -> NetworkLog
Drain the aggregate. Entries are returned sorted by request_id
for deterministic output. The background task is aborted.