Skip to main content

browser_protocol/eventbreakpoints/
mod.rs

1//! EventBreakpoints permits setting JavaScript breakpoints on operations and events
2//! occurring in native code invoked from JavaScript. Once breakpoint is hit, it is
3//! reported through Debugger domain, similarly to regular breakpoints being hit.
4
5
6use serde::{Serialize, Deserialize};
7use serde_json::Value as JsonValue;
8use std::borrow::Cow;
9
10/// Sets breakpoint on particular native event.
11
12#[derive(Debug, Clone, Serialize, Deserialize, Default)]
13#[serde(rename_all = "camelCase")]
14pub struct SetInstrumentationBreakpointParams<'a> {
15    /// Instrumentation name to stop on.
16    #[serde(rename = "eventName")]
17    event_name: Cow<'a, str>,
18}
19
20impl<'a> SetInstrumentationBreakpointParams<'a> {
21    /// Creates a builder for this type with the required parameters:
22    /// * `event_name`: Instrumentation name to stop on.
23    pub fn builder(event_name: impl Into<Cow<'a, str>>) -> SetInstrumentationBreakpointParamsBuilder<'a> {
24        SetInstrumentationBreakpointParamsBuilder {
25            event_name: event_name.into(),
26        }
27    }
28    /// Instrumentation name to stop on.
29    pub fn event_name(&self) -> &str { self.event_name.as_ref() }
30}
31
32
33pub struct SetInstrumentationBreakpointParamsBuilder<'a> {
34    event_name: Cow<'a, str>,
35}
36
37impl<'a> SetInstrumentationBreakpointParamsBuilder<'a> {
38    pub fn build(self) -> SetInstrumentationBreakpointParams<'a> {
39        SetInstrumentationBreakpointParams {
40            event_name: self.event_name,
41        }
42    }
43}
44
45impl<'a> SetInstrumentationBreakpointParams<'a> { pub const METHOD: &'static str = "EventBreakpoints.setInstrumentationBreakpoint"; }
46
47impl<'a> crate::CdpCommand<'a> for SetInstrumentationBreakpointParams<'a> {
48    const METHOD: &'static str = "EventBreakpoints.setInstrumentationBreakpoint";
49    type Response = crate::EmptyReturns;
50}
51
52/// Removes breakpoint on particular native event.
53
54#[derive(Debug, Clone, Serialize, Deserialize, Default)]
55#[serde(rename_all = "camelCase")]
56pub struct RemoveInstrumentationBreakpointParams<'a> {
57    /// Instrumentation name to stop on.
58    #[serde(rename = "eventName")]
59    event_name: Cow<'a, str>,
60}
61
62impl<'a> RemoveInstrumentationBreakpointParams<'a> {
63    /// Creates a builder for this type with the required parameters:
64    /// * `event_name`: Instrumentation name to stop on.
65    pub fn builder(event_name: impl Into<Cow<'a, str>>) -> RemoveInstrumentationBreakpointParamsBuilder<'a> {
66        RemoveInstrumentationBreakpointParamsBuilder {
67            event_name: event_name.into(),
68        }
69    }
70    /// Instrumentation name to stop on.
71    pub fn event_name(&self) -> &str { self.event_name.as_ref() }
72}
73
74
75pub struct RemoveInstrumentationBreakpointParamsBuilder<'a> {
76    event_name: Cow<'a, str>,
77}
78
79impl<'a> RemoveInstrumentationBreakpointParamsBuilder<'a> {
80    pub fn build(self) -> RemoveInstrumentationBreakpointParams<'a> {
81        RemoveInstrumentationBreakpointParams {
82            event_name: self.event_name,
83        }
84    }
85}
86
87impl<'a> RemoveInstrumentationBreakpointParams<'a> { pub const METHOD: &'static str = "EventBreakpoints.removeInstrumentationBreakpoint"; }
88
89impl<'a> crate::CdpCommand<'a> for RemoveInstrumentationBreakpointParams<'a> {
90    const METHOD: &'static str = "EventBreakpoints.removeInstrumentationBreakpoint";
91    type Response = crate::EmptyReturns;
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize, Default)]
95pub struct DisableParams {}
96
97impl DisableParams { pub const METHOD: &'static str = "EventBreakpoints.disable"; }
98
99impl<'a> crate::CdpCommand<'a> for DisableParams {
100    const METHOD: &'static str = "EventBreakpoints.disable";
101    type Response = crate::EmptyReturns;
102}