use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum DOMBreakpointType {
#[default]
#[serde(rename = "subtree-modified")]
SubtreeModified,
#[serde(rename = "attribute-modified")]
AttributeModified,
#[serde(rename = "node-removed")]
NodeRemoved,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum CSPViolationType {
#[default]
#[serde(rename = "trustedtype-sink-violation")]
TrustedtypeSinkViolation,
#[serde(rename = "trustedtype-policy-violation")]
TrustedtypePolicyViolation,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct EventListener<'a> {
#[serde(rename = "type")]
type_: Cow<'a, str>,
#[serde(rename = "useCapture")]
use_capture: bool,
passive: bool,
once: bool,
#[serde(rename = "scriptId")]
script_id: crate::runtime::ScriptId<'a>,
#[serde(rename = "lineNumber")]
line_number: i64,
#[serde(rename = "columnNumber")]
column_number: i64,
#[serde(skip_serializing_if = "Option::is_none")]
handler: Option<crate::runtime::RemoteObject>,
#[serde(skip_serializing_if = "Option::is_none", rename = "originalHandler")]
original_handler: Option<crate::runtime::RemoteObject>,
#[serde(skip_serializing_if = "Option::is_none", rename = "backendNodeId")]
backend_node_id: Option<crate::dom::BackendNodeId>,
}
impl<'a> EventListener<'a> {
pub fn builder(type_: impl Into<Cow<'a, str>>, use_capture: bool, passive: bool, once: bool, script_id: crate::runtime::ScriptId<'a>, line_number: i64, column_number: i64) -> EventListenerBuilder<'a> {
EventListenerBuilder {
type_: type_.into(),
use_capture: use_capture,
passive: passive,
once: once,
script_id: script_id,
line_number: line_number,
column_number: column_number,
handler: None,
original_handler: None,
backend_node_id: None,
}
}
pub fn type_(&self) -> &str { self.type_.as_ref() }
pub fn use_capture(&self) -> bool { self.use_capture }
pub fn passive(&self) -> bool { self.passive }
pub fn once(&self) -> bool { self.once }
pub fn script_id(&self) -> &crate::runtime::ScriptId<'a> { &self.script_id }
pub fn line_number(&self) -> i64 { self.line_number }
pub fn column_number(&self) -> i64 { self.column_number }
pub fn handler(&self) -> Option<&crate::runtime::RemoteObject> { self.handler.as_ref() }
pub fn original_handler(&self) -> Option<&crate::runtime::RemoteObject> { self.original_handler.as_ref() }
pub fn backend_node_id(&self) -> Option<&crate::dom::BackendNodeId> { self.backend_node_id.as_ref() }
}
pub struct EventListenerBuilder<'a> {
type_: Cow<'a, str>,
use_capture: bool,
passive: bool,
once: bool,
script_id: crate::runtime::ScriptId<'a>,
line_number: i64,
column_number: i64,
handler: Option<crate::runtime::RemoteObject>,
original_handler: Option<crate::runtime::RemoteObject>,
backend_node_id: Option<crate::dom::BackendNodeId>,
}
impl<'a> EventListenerBuilder<'a> {
pub fn handler(mut self, handler: crate::runtime::RemoteObject) -> Self { self.handler = Some(handler); self }
pub fn original_handler(mut self, original_handler: crate::runtime::RemoteObject) -> Self { self.original_handler = Some(original_handler); self }
pub fn backend_node_id(mut self, backend_node_id: crate::dom::BackendNodeId) -> Self { self.backend_node_id = Some(backend_node_id); self }
pub fn build(self) -> EventListener<'a> {
EventListener {
type_: self.type_,
use_capture: self.use_capture,
passive: self.passive,
once: self.once,
script_id: self.script_id,
line_number: self.line_number,
column_number: self.column_number,
handler: self.handler,
original_handler: self.original_handler,
backend_node_id: self.backend_node_id,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetEventListenersParams<'a> {
#[serde(rename = "objectId")]
object_id: crate::runtime::RemoteObjectId<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
depth: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pierce: Option<bool>,
}
impl<'a> GetEventListenersParams<'a> {
pub fn builder(object_id: crate::runtime::RemoteObjectId<'a>) -> GetEventListenersParamsBuilder<'a> {
GetEventListenersParamsBuilder {
object_id: object_id,
depth: None,
pierce: None,
}
}
pub fn object_id(&self) -> &crate::runtime::RemoteObjectId<'a> { &self.object_id }
pub fn depth(&self) -> Option<i64> { self.depth }
pub fn pierce(&self) -> Option<bool> { self.pierce }
}
pub struct GetEventListenersParamsBuilder<'a> {
object_id: crate::runtime::RemoteObjectId<'a>,
depth: Option<i64>,
pierce: Option<bool>,
}
impl<'a> GetEventListenersParamsBuilder<'a> {
pub fn depth(mut self, depth: i64) -> Self { self.depth = Some(depth); self }
pub fn pierce(mut self, pierce: bool) -> Self { self.pierce = Some(pierce); self }
pub fn build(self) -> GetEventListenersParams<'a> {
GetEventListenersParams {
object_id: self.object_id,
depth: self.depth,
pierce: self.pierce,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetEventListenersReturns<'a> {
listeners: Vec<EventListener<'a>>,
}
impl<'a> GetEventListenersReturns<'a> {
pub fn builder(listeners: Vec<EventListener<'a>>) -> GetEventListenersReturnsBuilder<'a> {
GetEventListenersReturnsBuilder {
listeners: listeners,
}
}
pub fn listeners(&self) -> &[EventListener<'a>] { &self.listeners }
}
pub struct GetEventListenersReturnsBuilder<'a> {
listeners: Vec<EventListener<'a>>,
}
impl<'a> GetEventListenersReturnsBuilder<'a> {
pub fn build(self) -> GetEventListenersReturns<'a> {
GetEventListenersReturns {
listeners: self.listeners,
}
}
}
impl<'a> GetEventListenersParams<'a> { pub const METHOD: &'static str = "DOMDebugger.getEventListeners"; }
impl<'a> crate::CdpCommand<'a> for GetEventListenersParams<'a> {
const METHOD: &'static str = "DOMDebugger.getEventListeners";
type Response = GetEventListenersReturns<'a>;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveDOMBreakpointParams {
#[serde(rename = "nodeId")]
node_id: crate::dom::NodeId,
#[serde(rename = "type")]
type_: DOMBreakpointType,
}
impl RemoveDOMBreakpointParams {
pub fn builder(node_id: crate::dom::NodeId, type_: impl Into<DOMBreakpointType>) -> RemoveDOMBreakpointParamsBuilder {
RemoveDOMBreakpointParamsBuilder {
node_id: node_id,
type_: type_.into(),
}
}
pub fn node_id(&self) -> &crate::dom::NodeId { &self.node_id }
pub fn type_(&self) -> &DOMBreakpointType { &self.type_ }
}
pub struct RemoveDOMBreakpointParamsBuilder {
node_id: crate::dom::NodeId,
type_: DOMBreakpointType,
}
impl RemoveDOMBreakpointParamsBuilder {
pub fn build(self) -> RemoveDOMBreakpointParams {
RemoveDOMBreakpointParams {
node_id: self.node_id,
type_: self.type_,
}
}
}
impl RemoveDOMBreakpointParams { pub const METHOD: &'static str = "DOMDebugger.removeDOMBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for RemoveDOMBreakpointParams {
const METHOD: &'static str = "DOMDebugger.removeDOMBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveEventListenerBreakpointParams<'a> {
#[serde(rename = "eventName")]
event_name: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none", rename = "targetName")]
target_name: Option<Cow<'a, str>>,
}
impl<'a> RemoveEventListenerBreakpointParams<'a> {
pub fn builder(event_name: impl Into<Cow<'a, str>>) -> RemoveEventListenerBreakpointParamsBuilder<'a> {
RemoveEventListenerBreakpointParamsBuilder {
event_name: event_name.into(),
target_name: None,
}
}
pub fn event_name(&self) -> &str { self.event_name.as_ref() }
pub fn target_name(&self) -> Option<&str> { self.target_name.as_deref() }
}
pub struct RemoveEventListenerBreakpointParamsBuilder<'a> {
event_name: Cow<'a, str>,
target_name: Option<Cow<'a, str>>,
}
impl<'a> RemoveEventListenerBreakpointParamsBuilder<'a> {
pub fn target_name(mut self, target_name: impl Into<Cow<'a, str>>) -> Self { self.target_name = Some(target_name.into()); self }
pub fn build(self) -> RemoveEventListenerBreakpointParams<'a> {
RemoveEventListenerBreakpointParams {
event_name: self.event_name,
target_name: self.target_name,
}
}
}
impl<'a> RemoveEventListenerBreakpointParams<'a> { pub const METHOD: &'static str = "DOMDebugger.removeEventListenerBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for RemoveEventListenerBreakpointParams<'a> {
const METHOD: &'static str = "DOMDebugger.removeEventListenerBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveInstrumentationBreakpointParams<'a> {
#[serde(rename = "eventName")]
event_name: Cow<'a, str>,
}
impl<'a> RemoveInstrumentationBreakpointParams<'a> {
pub fn builder(event_name: impl Into<Cow<'a, str>>) -> RemoveInstrumentationBreakpointParamsBuilder<'a> {
RemoveInstrumentationBreakpointParamsBuilder {
event_name: event_name.into(),
}
}
pub fn event_name(&self) -> &str { self.event_name.as_ref() }
}
pub struct RemoveInstrumentationBreakpointParamsBuilder<'a> {
event_name: Cow<'a, str>,
}
impl<'a> RemoveInstrumentationBreakpointParamsBuilder<'a> {
pub fn build(self) -> RemoveInstrumentationBreakpointParams<'a> {
RemoveInstrumentationBreakpointParams {
event_name: self.event_name,
}
}
}
impl<'a> RemoveInstrumentationBreakpointParams<'a> { pub const METHOD: &'static str = "DOMDebugger.removeInstrumentationBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for RemoveInstrumentationBreakpointParams<'a> {
const METHOD: &'static str = "DOMDebugger.removeInstrumentationBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveXHRBreakpointParams<'a> {
url: Cow<'a, str>,
}
impl<'a> RemoveXHRBreakpointParams<'a> {
pub fn builder(url: impl Into<Cow<'a, str>>) -> RemoveXHRBreakpointParamsBuilder<'a> {
RemoveXHRBreakpointParamsBuilder {
url: url.into(),
}
}
pub fn url(&self) -> &str { self.url.as_ref() }
}
pub struct RemoveXHRBreakpointParamsBuilder<'a> {
url: Cow<'a, str>,
}
impl<'a> RemoveXHRBreakpointParamsBuilder<'a> {
pub fn build(self) -> RemoveXHRBreakpointParams<'a> {
RemoveXHRBreakpointParams {
url: self.url,
}
}
}
impl<'a> RemoveXHRBreakpointParams<'a> { pub const METHOD: &'static str = "DOMDebugger.removeXHRBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for RemoveXHRBreakpointParams<'a> {
const METHOD: &'static str = "DOMDebugger.removeXHRBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetBreakOnCSPViolationParams {
#[serde(rename = "violationTypes")]
violation_types: Vec<CSPViolationType>,
}
impl SetBreakOnCSPViolationParams {
pub fn builder(violation_types: Vec<CSPViolationType>) -> SetBreakOnCSPViolationParamsBuilder {
SetBreakOnCSPViolationParamsBuilder {
violation_types: violation_types,
}
}
pub fn violation_types(&self) -> &[CSPViolationType] { &self.violation_types }
}
pub struct SetBreakOnCSPViolationParamsBuilder {
violation_types: Vec<CSPViolationType>,
}
impl SetBreakOnCSPViolationParamsBuilder {
pub fn build(self) -> SetBreakOnCSPViolationParams {
SetBreakOnCSPViolationParams {
violation_types: self.violation_types,
}
}
}
impl SetBreakOnCSPViolationParams { pub const METHOD: &'static str = "DOMDebugger.setBreakOnCSPViolation"; }
impl<'a> crate::CdpCommand<'a> for SetBreakOnCSPViolationParams {
const METHOD: &'static str = "DOMDebugger.setBreakOnCSPViolation";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetDOMBreakpointParams {
#[serde(rename = "nodeId")]
node_id: crate::dom::NodeId,
#[serde(rename = "type")]
type_: DOMBreakpointType,
}
impl SetDOMBreakpointParams {
pub fn builder(node_id: crate::dom::NodeId, type_: impl Into<DOMBreakpointType>) -> SetDOMBreakpointParamsBuilder {
SetDOMBreakpointParamsBuilder {
node_id: node_id,
type_: type_.into(),
}
}
pub fn node_id(&self) -> &crate::dom::NodeId { &self.node_id }
pub fn type_(&self) -> &DOMBreakpointType { &self.type_ }
}
pub struct SetDOMBreakpointParamsBuilder {
node_id: crate::dom::NodeId,
type_: DOMBreakpointType,
}
impl SetDOMBreakpointParamsBuilder {
pub fn build(self) -> SetDOMBreakpointParams {
SetDOMBreakpointParams {
node_id: self.node_id,
type_: self.type_,
}
}
}
impl SetDOMBreakpointParams { pub const METHOD: &'static str = "DOMDebugger.setDOMBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for SetDOMBreakpointParams {
const METHOD: &'static str = "DOMDebugger.setDOMBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetEventListenerBreakpointParams<'a> {
#[serde(rename = "eventName")]
event_name: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none", rename = "targetName")]
target_name: Option<Cow<'a, str>>,
}
impl<'a> SetEventListenerBreakpointParams<'a> {
pub fn builder(event_name: impl Into<Cow<'a, str>>) -> SetEventListenerBreakpointParamsBuilder<'a> {
SetEventListenerBreakpointParamsBuilder {
event_name: event_name.into(),
target_name: None,
}
}
pub fn event_name(&self) -> &str { self.event_name.as_ref() }
pub fn target_name(&self) -> Option<&str> { self.target_name.as_deref() }
}
pub struct SetEventListenerBreakpointParamsBuilder<'a> {
event_name: Cow<'a, str>,
target_name: Option<Cow<'a, str>>,
}
impl<'a> SetEventListenerBreakpointParamsBuilder<'a> {
pub fn target_name(mut self, target_name: impl Into<Cow<'a, str>>) -> Self { self.target_name = Some(target_name.into()); self }
pub fn build(self) -> SetEventListenerBreakpointParams<'a> {
SetEventListenerBreakpointParams {
event_name: self.event_name,
target_name: self.target_name,
}
}
}
impl<'a> SetEventListenerBreakpointParams<'a> { pub const METHOD: &'static str = "DOMDebugger.setEventListenerBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for SetEventListenerBreakpointParams<'a> {
const METHOD: &'static str = "DOMDebugger.setEventListenerBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetInstrumentationBreakpointParams<'a> {
#[serde(rename = "eventName")]
event_name: Cow<'a, str>,
}
impl<'a> SetInstrumentationBreakpointParams<'a> {
pub fn builder(event_name: impl Into<Cow<'a, str>>) -> SetInstrumentationBreakpointParamsBuilder<'a> {
SetInstrumentationBreakpointParamsBuilder {
event_name: event_name.into(),
}
}
pub fn event_name(&self) -> &str { self.event_name.as_ref() }
}
pub struct SetInstrumentationBreakpointParamsBuilder<'a> {
event_name: Cow<'a, str>,
}
impl<'a> SetInstrumentationBreakpointParamsBuilder<'a> {
pub fn build(self) -> SetInstrumentationBreakpointParams<'a> {
SetInstrumentationBreakpointParams {
event_name: self.event_name,
}
}
}
impl<'a> SetInstrumentationBreakpointParams<'a> { pub const METHOD: &'static str = "DOMDebugger.setInstrumentationBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for SetInstrumentationBreakpointParams<'a> {
const METHOD: &'static str = "DOMDebugger.setInstrumentationBreakpoint";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetXHRBreakpointParams<'a> {
url: Cow<'a, str>,
}
impl<'a> SetXHRBreakpointParams<'a> {
pub fn builder(url: impl Into<Cow<'a, str>>) -> SetXHRBreakpointParamsBuilder<'a> {
SetXHRBreakpointParamsBuilder {
url: url.into(),
}
}
pub fn url(&self) -> &str { self.url.as_ref() }
}
pub struct SetXHRBreakpointParamsBuilder<'a> {
url: Cow<'a, str>,
}
impl<'a> SetXHRBreakpointParamsBuilder<'a> {
pub fn build(self) -> SetXHRBreakpointParams<'a> {
SetXHRBreakpointParams {
url: self.url,
}
}
}
impl<'a> SetXHRBreakpointParams<'a> { pub const METHOD: &'static str = "DOMDebugger.setXHRBreakpoint"; }
impl<'a> crate::CdpCommand<'a> for SetXHRBreakpointParams<'a> {
const METHOD: &'static str = "DOMDebugger.setXHRBreakpoint";
type Response = crate::EmptyReturns;
}