Skip to main content

browser_control/cdp/
protocol.rs

1//! CDP JSON-RPC framing types.
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Serialize)]
7pub struct Request<'a> {
8    pub id: u64,
9    pub method: &'a str,
10    #[serde(skip_serializing_if = "Value::is_null")]
11    pub params: Value,
12    #[serde(rename = "sessionId", skip_serializing_if = "Option::is_none")]
13    pub session_id: Option<String>,
14}
15
16#[derive(Debug, Deserialize)]
17pub struct Response {
18    pub id: Option<u64>,
19    #[serde(default)]
20    pub result: Value,
21    #[serde(default)]
22    pub error: Option<CdpError>,
23    pub method: Option<String>,
24    #[serde(default)]
25    pub params: Value,
26    #[serde(rename = "sessionId")]
27    pub session_id: Option<String>,
28}
29
30#[derive(Debug, Deserialize, thiserror::Error)]
31#[error("CDP error {code}: {message}")]
32pub struct CdpError {
33    pub code: i64,
34    pub message: String,
35}