Skip to main content

browser_commander/playwright/protocol/
debug_controller.rs

1// @generated by scripts/generate-playwright-protocol.mjs from
2// rust/protocol/playwright/*.yml. Do not edit by hand.
3
4#![allow(clippy::all, missing_docs, unused_imports)]
5
6use serde::{Deserialize, Serialize};
7
8use super::*;
9use crate::playwright::connection::{
10    Binary, Channel, ChannelType, ObjectRef, ProtocolError, ProtocolEvent, Ref,
11};
12
13/// Initializer the driver sends when it creates a `DebugController`.
14#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
15pub struct DebugControllerInitializer {}
16
17/// Parameters of `DebugController.initialize`.
18#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
19pub struct DebugControllerInitializeParams {
20    #[serde(rename = "codegenId")]
21    pub codegen_id: String,
22    #[serde(rename = "sdkLanguage")]
23    pub sdk_language: SDKLanguage,
24}
25
26/// Parameters of `DebugController.setReportStateChanged`.
27#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
28pub struct DebugControllerSetReportStateChangedParams {
29    #[serde(rename = "enabled")]
30    pub enabled: bool,
31}
32
33#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
34pub enum DebugControllerSetRecorderModeParamsMode {
35    #[default]
36    #[serde(rename = "inspecting")]
37    Inspecting,
38    #[serde(rename = "recording")]
39    Recording,
40    #[serde(rename = "none")]
41    None,
42}
43
44/// Parameters of `DebugController.setRecorderMode`.
45#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
46pub struct DebugControllerSetRecorderModeParams {
47    #[serde(rename = "mode")]
48    pub mode: DebugControllerSetRecorderModeParamsMode,
49    #[serde(rename = "testIdAttributeName", default, skip_serializing_if = "Option::is_none")]
50    pub test_id_attribute_name: Option<String>,
51    #[serde(rename = "generateAutoExpect", default, skip_serializing_if = "Option::is_none")]
52    pub generate_auto_expect: Option<bool>,
53}
54
55/// Parameters of `DebugController.highlight`.
56#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
57pub struct DebugControllerHighlightParams {
58    #[serde(rename = "selector", default, skip_serializing_if = "Option::is_none")]
59    pub selector: Option<String>,
60    #[serde(rename = "ariaTemplate", default, skip_serializing_if = "Option::is_none")]
61    pub aria_template: Option<String>,
62}
63
64/// Payload of the `DebugController.inspectRequested` event.
65#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
66pub struct DebugControllerInspectRequestedEventParams {
67    #[serde(rename = "selector")]
68    pub selector: String,
69    #[serde(rename = "locator")]
70    pub locator: String,
71    #[serde(rename = "ariaSnapshot")]
72    pub aria_snapshot: String,
73}
74
75/// Payload of the `DebugController.setModeRequested` event.
76#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
77pub struct DebugControllerSetModeRequestedEventParams {
78    #[serde(rename = "mode")]
79    pub mode: String,
80}
81
82/// Payload of the `DebugController.stateChanged` event.
83#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
84pub struct DebugControllerStateChangedEventParams {
85    #[serde(rename = "pageCount")]
86    pub page_count: i64,
87}
88
89/// Payload of the `DebugController.sourceChanged` event.
90#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
91pub struct DebugControllerSourceChangedEventParams {
92    #[serde(rename = "text")]
93    pub text: String,
94    #[serde(rename = "header", default, skip_serializing_if = "Option::is_none")]
95    pub header: Option<String>,
96    #[serde(rename = "footer", default, skip_serializing_if = "Option::is_none")]
97    pub footer: Option<String>,
98    #[serde(rename = "actions", default, skip_serializing_if = "Option::is_none")]
99    pub actions: Option<Vec<String>>,
100}
101
102/// Payload of the `DebugController.paused` event.
103#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
104pub struct DebugControllerPausedEventParams {
105    #[serde(rename = "paused")]
106    pub paused: bool,
107}
108
109/// Events a `DebugController` channel can emit.
110#[derive(Debug, Clone, PartialEq)]
111pub enum DebugControllerEvent {
112    /// `DebugController.inspectRequested`
113    InspectRequested(DebugControllerInspectRequestedEventParams),
114    /// `DebugController.setModeRequested`
115    SetModeRequested(DebugControllerSetModeRequestedEventParams),
116    /// `DebugController.stateChanged`
117    StateChanged(DebugControllerStateChangedEventParams),
118    /// `DebugController.sourceChanged`
119    SourceChanged(DebugControllerSourceChangedEventParams),
120    /// `DebugController.paused`
121    Paused(DebugControllerPausedEventParams),
122    /// An event this binding does not know (a newer driver).
123    Unknown {
124        /// Event name.
125        method: String,
126        /// Raw event parameters.
127        params: serde_json::Value,
128    },
129}
130
131impl ProtocolEvent for DebugControllerEvent {
132    fn parse(method: &str, params: serde_json::Value) -> Result<Self, serde_json::Error> {
133        match method {
134            "inspectRequested" => Ok(Self::InspectRequested(serde_json::from_value(params)?)),
135            "setModeRequested" => Ok(Self::SetModeRequested(serde_json::from_value(params)?)),
136            "stateChanged" => Ok(Self::StateChanged(serde_json::from_value(params)?)),
137            "sourceChanged" => Ok(Self::SourceChanged(serde_json::from_value(params)?)),
138            "paused" => Ok(Self::Paused(serde_json::from_value(params)?)),
139            _ => Ok(Self::Unknown { method: method.to_string(), params }),
140        }
141    }
142}
143
144/// Channel for the `DebugController` interface (`playwright.yml`).
145#[derive(Debug, Clone)]
146pub struct DebugController {
147    channel: Channel,
148}
149
150impl ChannelType for DebugController {
151    const INTERFACE: &'static str = "DebugController";
152    type Initializer = DebugControllerInitializer;
153    type Event = DebugControllerEvent;
154
155    fn accepts(interface: &str) -> bool {
156        matches!(interface, "DebugController")
157    }
158
159    fn from_channel(channel: Channel) -> Self {
160        Self { channel }
161    }
162
163    fn channel(&self) -> &Channel {
164        &self.channel
165    }
166}
167
168impl DebugController {
169    /// `DebugController.initialize` (internal).
170    pub async fn initialize(&self, params: DebugControllerInitializeParams) -> Result<(), ProtocolError> {
171        self.channel.send_no_result("initialize", &params).await
172    }
173
174    /// `DebugController.setReportStateChanged` (internal).
175    pub async fn set_report_state_changed(&self, params: DebugControllerSetReportStateChangedParams) -> Result<(), ProtocolError> {
176        self.channel.send_no_result("setReportStateChanged", &params).await
177    }
178
179    /// `DebugController.setRecorderMode` (internal).
180    pub async fn set_recorder_mode(&self, params: DebugControllerSetRecorderModeParams) -> Result<(), ProtocolError> {
181        self.channel.send_no_result("setRecorderMode", &params).await
182    }
183
184    /// `DebugController.highlight` (internal).
185    pub async fn highlight(&self, params: DebugControllerHighlightParams) -> Result<(), ProtocolError> {
186        self.channel.send_no_result("highlight", &params).await
187    }
188
189    /// `DebugController.hideHighlight` (internal).
190    pub async fn hide_highlight(&self) -> Result<(), ProtocolError> {
191        self.channel.send_no_result("hideHighlight", &serde_json::json!({})).await
192    }
193
194    /// `DebugController.resume` (internal).
195    pub async fn resume(&self) -> Result<(), ProtocolError> {
196        self.channel.send_no_result("resume", &serde_json::json!({})).await
197    }
198
199    /// `DebugController.kill` (internal).
200    pub async fn kill(&self) -> Result<(), ProtocolError> {
201        self.channel.send_no_result("kill", &serde_json::json!({})).await
202    }
203}