Skip to main content

rustenium_cdp_definitions/browser_protocol/event_breakpoints/
command_builders.rs

1use super::commands::*;
2impl SetInstrumentationBreakpoint {
3    pub fn builder() -> SetInstrumentationBreakpointBuilder {
4        <SetInstrumentationBreakpointBuilder as Default>::default()
5    }
6}
7#[derive(Default, Clone)]
8pub struct SetInstrumentationBreakpointBuilder {
9    event_name: Option<String>,
10}
11impl SetInstrumentationBreakpointBuilder {
12    pub fn event_name(mut self, event_name: impl Into<String>) -> Self {
13        self.event_name = Some(event_name.into());
14        self
15    }
16    pub fn build(self) -> Result<SetInstrumentationBreakpoint, String> {
17        Ok(SetInstrumentationBreakpoint {
18            method: SetInstrumentationBreakpointMethod::SetInstrumentationBreakpoint,
19            params: SetInstrumentationBreakpointParams {
20                event_name: self.event_name.ok_or_else(|| {
21                    format!("Field `{}` is mandatory.", std::stringify!(event_name))
22                })?,
23            },
24        })
25    }
26}
27impl RemoveInstrumentationBreakpoint {
28    pub fn builder() -> RemoveInstrumentationBreakpointBuilder {
29        <RemoveInstrumentationBreakpointBuilder as Default>::default()
30    }
31}
32#[derive(Default, Clone)]
33pub struct RemoveInstrumentationBreakpointBuilder {
34    event_name: Option<String>,
35}
36impl RemoveInstrumentationBreakpointBuilder {
37    pub fn event_name(mut self, event_name: impl Into<String>) -> Self {
38        self.event_name = Some(event_name.into());
39        self
40    }
41    pub fn build(self) -> Result<RemoveInstrumentationBreakpoint, String> {
42        Ok(RemoveInstrumentationBreakpoint {
43            method: RemoveInstrumentationBreakpointMethod::RemoveInstrumentationBreakpoint,
44            params: RemoveInstrumentationBreakpointParams {
45                event_name: self.event_name.ok_or_else(|| {
46                    format!("Field `{}` is mandatory.", std::stringify!(event_name))
47                })?,
48            },
49        })
50    }
51}
52#[derive(Debug, Clone, Default)]
53pub struct DisableBuilder;
54impl DisableBuilder {
55    pub fn new() -> Self {
56        Self
57    }
58    pub fn build(self) -> Disable {
59        Disable {
60            method: DisableMethod::Disable,
61            params: DisableParams {},
62        }
63    }
64}
65impl Disable {
66    pub fn builder() -> DisableBuilder {
67        DisableBuilder
68    }
69}