Skip to main content

rustenium_cdp_definitions/browser_protocol/cast/
command_builders.rs

1use super::commands::*;
2impl Enable {
3    pub fn builder() -> EnableBuilder {
4        <EnableBuilder as Default>::default()
5    }
6}
7#[derive(Default, Clone)]
8pub struct EnableBuilder {
9    presentation_url: Option<String>,
10}
11impl EnableBuilder {
12    pub fn presentation_url(mut self, presentation_url: impl Into<String>) -> Self {
13        self.presentation_url = Some(presentation_url.into());
14        self
15    }
16    pub fn build(self) -> Enable {
17        Enable {
18            method: EnableMethod::Enable,
19            params: EnableParams {
20                presentation_url: self.presentation_url,
21            },
22        }
23    }
24}
25#[derive(Debug, Clone, Default)]
26pub struct DisableBuilder;
27impl DisableBuilder {
28    pub fn new() -> Self {
29        Self
30    }
31    pub fn build(self) -> Disable {
32        Disable {
33            method: DisableMethod::Disable,
34            params: DisableParams {},
35        }
36    }
37}
38impl Disable {
39    pub fn builder() -> DisableBuilder {
40        DisableBuilder
41    }
42}
43impl SetSinkToUse {
44    pub fn builder() -> SetSinkToUseBuilder {
45        <SetSinkToUseBuilder as Default>::default()
46    }
47}
48#[derive(Default, Clone)]
49pub struct SetSinkToUseBuilder {
50    sink_name: Option<String>,
51}
52impl SetSinkToUseBuilder {
53    pub fn sink_name(mut self, sink_name: impl Into<String>) -> Self {
54        self.sink_name = Some(sink_name.into());
55        self
56    }
57    pub fn build(self) -> Result<SetSinkToUse, String> {
58        Ok(SetSinkToUse {
59            method: SetSinkToUseMethod::SetSinkToUse,
60            params: SetSinkToUseParams {
61                sink_name: self.sink_name.ok_or_else(|| {
62                    format!("Field `{}` is mandatory.", std::stringify!(sink_name))
63                })?,
64            },
65        })
66    }
67}
68impl StartDesktopMirroring {
69    pub fn builder() -> StartDesktopMirroringBuilder {
70        <StartDesktopMirroringBuilder as Default>::default()
71    }
72}
73#[derive(Default, Clone)]
74pub struct StartDesktopMirroringBuilder {
75    sink_name: Option<String>,
76}
77impl StartDesktopMirroringBuilder {
78    pub fn sink_name(mut self, sink_name: impl Into<String>) -> Self {
79        self.sink_name = Some(sink_name.into());
80        self
81    }
82    pub fn build(self) -> Result<StartDesktopMirroring, String> {
83        Ok(StartDesktopMirroring {
84            method: StartDesktopMirroringMethod::StartDesktopMirroring,
85            params: StartDesktopMirroringParams {
86                sink_name: self.sink_name.ok_or_else(|| {
87                    format!("Field `{}` is mandatory.", std::stringify!(sink_name))
88                })?,
89            },
90        })
91    }
92}
93impl StartTabMirroring {
94    pub fn builder() -> StartTabMirroringBuilder {
95        <StartTabMirroringBuilder as Default>::default()
96    }
97}
98#[derive(Default, Clone)]
99pub struct StartTabMirroringBuilder {
100    sink_name: Option<String>,
101}
102impl StartTabMirroringBuilder {
103    pub fn sink_name(mut self, sink_name: impl Into<String>) -> Self {
104        self.sink_name = Some(sink_name.into());
105        self
106    }
107    pub fn build(self) -> Result<StartTabMirroring, String> {
108        Ok(StartTabMirroring {
109            method: StartTabMirroringMethod::StartTabMirroring,
110            params: StartTabMirroringParams {
111                sink_name: self.sink_name.ok_or_else(|| {
112                    format!("Field `{}` is mandatory.", std::stringify!(sink_name))
113                })?,
114            },
115        })
116    }
117}
118impl StopCasting {
119    pub fn builder() -> StopCastingBuilder {
120        <StopCastingBuilder as Default>::default()
121    }
122}
123#[derive(Default, Clone)]
124pub struct StopCastingBuilder {
125    sink_name: Option<String>,
126}
127impl StopCastingBuilder {
128    pub fn sink_name(mut self, sink_name: impl Into<String>) -> Self {
129        self.sink_name = Some(sink_name.into());
130        self
131    }
132    pub fn build(self) -> Result<StopCasting, String> {
133        Ok(StopCasting {
134            method: StopCastingMethod::StopCasting,
135            params: StopCastingParams {
136                sink_name: self.sink_name.ok_or_else(|| {
137                    format!("Field `{}` is mandatory.", std::stringify!(sink_name))
138                })?,
139            },
140        })
141    }
142}