Skip to main content

rustenium_cdp_definitions/browser_protocol/log/
command_builders.rs

1use super::commands::*;
2#[derive(Debug, Clone, Default)]
3pub struct ClearBuilder;
4impl ClearBuilder {
5    pub fn new() -> Self {
6        Self
7    }
8    pub fn build(self) -> Clear {
9        Clear {
10            method: ClearMethod::Clear,
11            params: ClearParams {},
12        }
13    }
14}
15impl Clear {
16    pub fn builder() -> ClearBuilder {
17        ClearBuilder
18    }
19}
20#[derive(Debug, Clone, Default)]
21pub struct DisableBuilder;
22impl DisableBuilder {
23    pub fn new() -> Self {
24        Self
25    }
26    pub fn build(self) -> Disable {
27        Disable {
28            method: DisableMethod::Disable,
29            params: DisableParams {},
30        }
31    }
32}
33impl Disable {
34    pub fn builder() -> DisableBuilder {
35        DisableBuilder
36    }
37}
38#[derive(Debug, Clone, Default)]
39pub struct EnableBuilder;
40impl EnableBuilder {
41    pub fn new() -> Self {
42        Self
43    }
44    pub fn build(self) -> Enable {
45        Enable {
46            method: EnableMethod::Enable,
47            params: EnableParams {},
48        }
49    }
50}
51impl Enable {
52    pub fn builder() -> EnableBuilder {
53        EnableBuilder
54    }
55}
56impl StartViolationsReport {
57    pub fn builder() -> StartViolationsReportBuilder {
58        <StartViolationsReportBuilder as Default>::default()
59    }
60}
61#[derive(Default, Clone)]
62pub struct StartViolationsReportBuilder {
63    config: Option<Vec<super::types::ViolationSetting>>,
64}
65impl StartViolationsReportBuilder {
66    pub fn config(mut self, config: impl Into<super::types::ViolationSetting>) -> Self {
67        let v = self.config.get_or_insert(Vec::new());
68        v.push(config.into());
69        self
70    }
71    pub fn configs<I, S>(mut self, configs: I) -> Self
72    where
73        I: IntoIterator<Item = S>,
74        S: Into<super::types::ViolationSetting>,
75    {
76        let v = self.config.get_or_insert(Vec::new());
77        for val in configs {
78            v.push(val.into());
79        }
80        self
81    }
82    pub fn build(self) -> Result<StartViolationsReport, String> {
83        Ok(StartViolationsReport {
84            method: StartViolationsReportMethod::StartViolationsReport,
85            params: StartViolationsReportParams {
86                config: self
87                    .config
88                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(config)))?,
89            },
90        })
91    }
92}
93#[derive(Debug, Clone, Default)]
94pub struct StopViolationsReportBuilder;
95impl StopViolationsReportBuilder {
96    pub fn new() -> Self {
97        Self
98    }
99    pub fn build(self) -> StopViolationsReport {
100        StopViolationsReport {
101            method: StopViolationsReportMethod::StopViolationsReport,
102            params: StopViolationsReportParams {},
103        }
104    }
105}
106impl StopViolationsReport {
107    pub fn builder() -> StopViolationsReportBuilder {
108        StopViolationsReportBuilder
109    }
110}