Skip to main content

browser_protocol/deviceaccess/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3
4/// Device request id.
5
6pub type RequestId = String;
7
8/// A device id.
9
10pub type DeviceId = String;
11
12/// Device information displayed in a user prompt to select a device.
13
14#[derive(Debug, Clone, Serialize, Deserialize, Default)]
15#[serde(rename_all = "camelCase")]
16pub struct PromptDevice {
17
18    pub id: DeviceId,
19    /// Display name as it appears in a device request user prompt.
20
21    pub name: String,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize, Default)]
25pub struct EnableParams {}
26
27impl EnableParams { pub const METHOD: &'static str = "DeviceAccess.enable"; }
28
29impl crate::CdpCommand for EnableParams {
30    const METHOD: &'static str = "DeviceAccess.enable";
31    type Response = crate::EmptyReturns;
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize, Default)]
35pub struct DisableParams {}
36
37impl DisableParams { pub const METHOD: &'static str = "DeviceAccess.disable"; }
38
39impl crate::CdpCommand for DisableParams {
40    const METHOD: &'static str = "DeviceAccess.disable";
41    type Response = crate::EmptyReturns;
42}
43
44/// Select a device in response to a DeviceAccess.deviceRequestPrompted event.
45
46#[derive(Debug, Clone, Serialize, Deserialize, Default)]
47#[serde(rename_all = "camelCase")]
48pub struct SelectPromptParams {
49
50    pub id: RequestId,
51
52    pub deviceId: DeviceId,
53}
54
55impl SelectPromptParams { pub const METHOD: &'static str = "DeviceAccess.selectPrompt"; }
56
57impl crate::CdpCommand for SelectPromptParams {
58    const METHOD: &'static str = "DeviceAccess.selectPrompt";
59    type Response = crate::EmptyReturns;
60}
61
62/// Cancel a prompt in response to a DeviceAccess.deviceRequestPrompted event.
63
64#[derive(Debug, Clone, Serialize, Deserialize, Default)]
65#[serde(rename_all = "camelCase")]
66pub struct CancelPromptParams {
67
68    pub id: RequestId,
69}
70
71impl CancelPromptParams { pub const METHOD: &'static str = "DeviceAccess.cancelPrompt"; }
72
73impl crate::CdpCommand for CancelPromptParams {
74    const METHOD: &'static str = "DeviceAccess.cancelPrompt";
75    type Response = crate::EmptyReturns;
76}