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    eventName: Cow<'a, str>,
17}
18
19impl<'a> SetInstrumentationBreakpointParams<'a> {
20    pub fn builder(eventName: impl Into<Cow<'a, str>>) -> SetInstrumentationBreakpointParamsBuilder<'a> {
21        SetInstrumentationBreakpointParamsBuilder {
22            eventName: eventName.into(),
23        }
24    }
25    pub fn eventName(&self) -> &str { self.eventName.as_ref() }
26}
27
28
29pub struct SetInstrumentationBreakpointParamsBuilder<'a> {
30    eventName: Cow<'a, str>,
31}
32
33impl<'a> SetInstrumentationBreakpointParamsBuilder<'a> {
34    pub fn build(self) -> SetInstrumentationBreakpointParams<'a> {
35        SetInstrumentationBreakpointParams {
36            eventName: self.eventName,
37        }
38    }
39}
40
41impl<'a> SetInstrumentationBreakpointParams<'a> { pub const METHOD: &'static str = "EventBreakpoints.setInstrumentationBreakpoint"; }
42
43impl<'a> crate::CdpCommand<'a> for SetInstrumentationBreakpointParams<'a> {
44    const METHOD: &'static str = "EventBreakpoints.setInstrumentationBreakpoint";
45    type Response = crate::EmptyReturns;
46}
47
48/// Removes breakpoint on particular native event.
49
50#[derive(Debug, Clone, Serialize, Deserialize, Default)]
51#[serde(rename_all = "camelCase")]
52pub struct RemoveInstrumentationBreakpointParams<'a> {
53    /// Instrumentation name to stop on.
54    eventName: Cow<'a, str>,
55}
56
57impl<'a> RemoveInstrumentationBreakpointParams<'a> {
58    pub fn builder(eventName: impl Into<Cow<'a, str>>) -> RemoveInstrumentationBreakpointParamsBuilder<'a> {
59        RemoveInstrumentationBreakpointParamsBuilder {
60            eventName: eventName.into(),
61        }
62    }
63    pub fn eventName(&self) -> &str { self.eventName.as_ref() }
64}
65
66
67pub struct RemoveInstrumentationBreakpointParamsBuilder<'a> {
68    eventName: Cow<'a, str>,
69}
70
71impl<'a> RemoveInstrumentationBreakpointParamsBuilder<'a> {
72    pub fn build(self) -> RemoveInstrumentationBreakpointParams<'a> {
73        RemoveInstrumentationBreakpointParams {
74            eventName: self.eventName,
75        }
76    }
77}
78
79impl<'a> RemoveInstrumentationBreakpointParams<'a> { pub const METHOD: &'static str = "EventBreakpoints.removeInstrumentationBreakpoint"; }
80
81impl<'a> crate::CdpCommand<'a> for RemoveInstrumentationBreakpointParams<'a> {
82    const METHOD: &'static str = "EventBreakpoints.removeInstrumentationBreakpoint";
83    type Response = crate::EmptyReturns;
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, Default)]
87pub struct DisableParams {}
88
89impl DisableParams { pub const METHOD: &'static str = "EventBreakpoints.disable"; }
90
91impl<'a> crate::CdpCommand<'a> for DisableParams {
92    const METHOD: &'static str = "EventBreakpoints.disable";
93    type Response = crate::EmptyReturns;
94}