rustenium_cdp_definitions/browser_protocol/tethering/
command_builders.rs1use super::commands::*;
2impl Bind {
3 pub fn builder() -> BindBuilder {
4 <BindBuilder as Default>::default()
5 }
6}
7#[derive(Default, Clone)]
8pub struct BindBuilder {
9 port: Option<i64>,
10}
11impl BindBuilder {
12 pub fn port(mut self, port: impl Into<i64>) -> Self {
13 self.port = Some(port.into());
14 self
15 }
16 pub fn build(self) -> Result<Bind, String> {
17 Ok(Bind {
18 method: BindMethod::Bind,
19 params: BindParams {
20 port: self
21 .port
22 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(port)))?,
23 },
24 })
25 }
26}
27impl Unbind {
28 pub fn builder() -> UnbindBuilder {
29 <UnbindBuilder as Default>::default()
30 }
31}
32#[derive(Default, Clone)]
33pub struct UnbindBuilder {
34 port: Option<i64>,
35}
36impl UnbindBuilder {
37 pub fn port(mut self, port: impl Into<i64>) -> Self {
38 self.port = Some(port.into());
39 self
40 }
41 pub fn build(self) -> Result<Unbind, String> {
42 Ok(Unbind {
43 method: UnbindMethod::Unbind,
44 params: UnbindParams {
45 port: self
46 .port
47 .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(port)))?,
48 },
49 })
50 }
51}