browser_protocol/deviceaccess/
mod.rs1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5pub type RequestId<'a> = Cow<'a, str>;
8
9pub type DeviceId<'a> = Cow<'a, str>;
12
13#[derive(Debug, Clone, Serialize, Deserialize, Default)]
16#[serde(rename_all = "camelCase")]
17pub struct PromptDevice<'a> {
18 id: DeviceId<'a>,
19 name: Cow<'a, str>,
21}
22
23impl<'a> PromptDevice<'a> {
24 pub fn builder(id: impl Into<DeviceId<'a>>, name: impl Into<Cow<'a, str>>) -> PromptDeviceBuilder<'a> {
28 PromptDeviceBuilder {
29 id: id.into(),
30 name: name.into(),
31 }
32 }
33 pub fn id(&self) -> &DeviceId<'a> { &self.id }
34 pub fn name(&self) -> &str { self.name.as_ref() }
36}
37
38
39pub struct PromptDeviceBuilder<'a> {
40 id: DeviceId<'a>,
41 name: Cow<'a, str>,
42}
43
44impl<'a> PromptDeviceBuilder<'a> {
45 pub fn build(self) -> PromptDevice<'a> {
46 PromptDevice {
47 id: self.id,
48 name: self.name,
49 }
50 }
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize, Default)]
54pub struct EnableParams {}
55
56impl EnableParams { pub const METHOD: &'static str = "DeviceAccess.enable"; }
57
58impl<'a> crate::CdpCommand<'a> for EnableParams {
59 const METHOD: &'static str = "DeviceAccess.enable";
60 type Response = crate::EmptyReturns;
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize, Default)]
64pub struct DisableParams {}
65
66impl DisableParams { pub const METHOD: &'static str = "DeviceAccess.disable"; }
67
68impl<'a> crate::CdpCommand<'a> for DisableParams {
69 const METHOD: &'static str = "DeviceAccess.disable";
70 type Response = crate::EmptyReturns;
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize, Default)]
76#[serde(rename_all = "camelCase")]
77pub struct SelectPromptParams<'a> {
78 id: RequestId<'a>,
79 #[serde(rename = "deviceId")]
80 device_id: DeviceId<'a>,
81}
82
83impl<'a> SelectPromptParams<'a> {
84 pub fn builder(id: impl Into<RequestId<'a>>, device_id: impl Into<DeviceId<'a>>) -> SelectPromptParamsBuilder<'a> {
88 SelectPromptParamsBuilder {
89 id: id.into(),
90 device_id: device_id.into(),
91 }
92 }
93 pub fn id(&self) -> &RequestId<'a> { &self.id }
94 pub fn device_id(&self) -> &DeviceId<'a> { &self.device_id }
95}
96
97
98pub struct SelectPromptParamsBuilder<'a> {
99 id: RequestId<'a>,
100 device_id: DeviceId<'a>,
101}
102
103impl<'a> SelectPromptParamsBuilder<'a> {
104 pub fn build(self) -> SelectPromptParams<'a> {
105 SelectPromptParams {
106 id: self.id,
107 device_id: self.device_id,
108 }
109 }
110}
111
112impl<'a> SelectPromptParams<'a> { pub const METHOD: &'static str = "DeviceAccess.selectPrompt"; }
113
114impl<'a> crate::CdpCommand<'a> for SelectPromptParams<'a> {
115 const METHOD: &'static str = "DeviceAccess.selectPrompt";
116 type Response = crate::EmptyReturns;
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize, Default)]
122#[serde(rename_all = "camelCase")]
123pub struct CancelPromptParams<'a> {
124 id: RequestId<'a>,
125}
126
127impl<'a> CancelPromptParams<'a> {
128 pub fn builder(id: impl Into<RequestId<'a>>) -> CancelPromptParamsBuilder<'a> {
131 CancelPromptParamsBuilder {
132 id: id.into(),
133 }
134 }
135 pub fn id(&self) -> &RequestId<'a> { &self.id }
136}
137
138
139pub struct CancelPromptParamsBuilder<'a> {
140 id: RequestId<'a>,
141}
142
143impl<'a> CancelPromptParamsBuilder<'a> {
144 pub fn build(self) -> CancelPromptParams<'a> {
145 CancelPromptParams {
146 id: self.id,
147 }
148 }
149}
150
151impl<'a> CancelPromptParams<'a> { pub const METHOD: &'static str = "DeviceAccess.cancelPrompt"; }
152
153impl<'a> crate::CdpCommand<'a> for CancelPromptParams<'a> {
154 const METHOD: &'static str = "DeviceAccess.cancelPrompt";
155 type Response = crate::EmptyReturns;
156}