#![allow(clippy::all, missing_docs, unused_imports)]
use serde::{Deserialize, Serialize};
use super::*;
use crate::playwright::connection::{
Binary, Channel, ChannelType, ObjectRef, ProtocolError, ProtocolEvent, Ref,
};
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerInitializer {}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerRunToParamsLocation {
#[serde(rename = "file")]
pub file: String,
#[serde(rename = "line", default, skip_serializing_if = "Option::is_none")]
pub line: Option<i64>,
#[serde(rename = "column", default, skip_serializing_if = "Option::is_none")]
pub column: Option<i64>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerRunToParams {
#[serde(rename = "location")]
pub location: DebuggerRunToParamsLocation,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerPausedStateChangedEventParamsPausedDetailsLocation {
#[serde(rename = "file")]
pub file: String,
#[serde(rename = "line", default, skip_serializing_if = "Option::is_none")]
pub line: Option<i64>,
#[serde(rename = "column", default, skip_serializing_if = "Option::is_none")]
pub column: Option<i64>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerPausedStateChangedEventParamsPausedDetails {
#[serde(rename = "location")]
pub location: DebuggerPausedStateChangedEventParamsPausedDetailsLocation,
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "stack", default, skip_serializing_if = "Option::is_none")]
pub stack: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerPausedStateChangedEventParams {
#[serde(rename = "pausedDetails", default, skip_serializing_if = "Option::is_none")]
pub paused_details: Option<DebuggerPausedStateChangedEventParamsPausedDetails>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerApiCallsUpdatedEventParamsApiCallsLocation {
#[serde(rename = "file")]
pub file: String,
#[serde(rename = "line", default, skip_serializing_if = "Option::is_none")]
pub line: Option<i64>,
#[serde(rename = "column", default, skip_serializing_if = "Option::is_none")]
pub column: Option<i64>,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DebuggerApiCallsUpdatedEventParamsApiCallsStatus {
#[default]
#[serde(rename = "running")]
Running,
#[serde(rename = "success")]
Success,
#[serde(rename = "error")]
Error,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerApiCallsUpdatedEventParamsApiCalls {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "location", default, skip_serializing_if = "Option::is_none")]
pub location: Option<DebuggerApiCallsUpdatedEventParamsApiCallsLocation>,
#[serde(rename = "newLogEntries")]
pub new_log_entries: Vec<String>,
#[serde(rename = "actionPoint", default, skip_serializing_if = "Option::is_none")]
pub action_point: Option<Point>,
#[serde(rename = "status")]
pub status: DebuggerApiCallsUpdatedEventParamsApiCallsStatus,
#[serde(rename = "error", default, skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DebuggerApiCallsUpdatedEventParams {
#[serde(rename = "apiCalls")]
pub api_calls: Vec<DebuggerApiCallsUpdatedEventParamsApiCalls>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum DebuggerEvent {
PausedStateChanged(DebuggerPausedStateChangedEventParams),
ApiCallsUpdated(DebuggerApiCallsUpdatedEventParams),
Unknown {
method: String,
params: serde_json::Value,
},
}
impl ProtocolEvent for DebuggerEvent {
fn parse(method: &str, params: serde_json::Value) -> Result<Self, serde_json::Error> {
match method {
"pausedStateChanged" => Ok(Self::PausedStateChanged(serde_json::from_value(params)?)),
"apiCallsUpdated" => Ok(Self::ApiCallsUpdated(serde_json::from_value(params)?)),
_ => Ok(Self::Unknown { method: method.to_string(), params }),
}
}
}
#[derive(Debug, Clone)]
pub struct Debugger {
channel: Channel,
}
impl ChannelType for Debugger {
const INTERFACE: &'static str = "Debugger";
type Initializer = DebuggerInitializer;
type Event = DebuggerEvent;
fn accepts(interface: &str) -> bool {
matches!(interface, "Debugger")
}
fn from_channel(channel: Channel) -> Self {
Self { channel }
}
fn channel(&self) -> &Channel {
&self.channel
}
}
impl Debugger {
pub async fn request_pause(&self) -> Result<(), ProtocolError> {
self.channel.send_no_result("requestPause", &serde_json::json!({})).await
}
pub async fn resume(&self) -> Result<(), ProtocolError> {
self.channel.send_no_result("resume", &serde_json::json!({})).await
}
pub async fn next(&self) -> Result<(), ProtocolError> {
self.channel.send_no_result("next", &serde_json::json!({})).await
}
pub async fn run_to(&self, params: DebuggerRunToParams) -> Result<(), ProtocolError> {
self.channel.send_no_result("runTo", ¶ms).await
}
pub async fn enable(&self) -> Result<(), ProtocolError> {
self.channel.send_no_result("enable", &serde_json::json!({})).await
}
}