Skip to main content

browser_protocol/domstorage/
mod.rs

1//! Query and modify DOM storage.
2use serde::{Serialize, Deserialize};
3use serde_json::Value as JsonValue;
4
5
6pub type SerializedStorageKey = String;
7
8/// DOM Storage identifier.
9
10#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct StorageId {
13    /// Security origin for the storage.
14
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub securityOrigin: Option<String>,
17    /// Represents a key by which DOM Storage keys its CachedStorageAreas
18
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub storageKey: Option<SerializedStorageKey>,
21    /// Whether the storage is local storage (not session storage).
22
23    pub isLocalStorage: bool,
24}
25
26/// DOM Storage item.
27
28pub type Item = Vec<String>;
29
30
31#[derive(Debug, Clone, Serialize, Deserialize, Default)]
32#[serde(rename_all = "camelCase")]
33pub struct ClearParams {
34
35    pub storageId: StorageId,
36}
37
38impl ClearParams { pub const METHOD: &'static str = "DOMStorage.clear"; }
39
40impl crate::CdpCommand for ClearParams {
41    const METHOD: &'static str = "DOMStorage.clear";
42    type Response = crate::EmptyReturns;
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, Default)]
46pub struct DisableParams {}
47
48impl DisableParams { pub const METHOD: &'static str = "DOMStorage.disable"; }
49
50impl crate::CdpCommand for DisableParams {
51    const METHOD: &'static str = "DOMStorage.disable";
52    type Response = crate::EmptyReturns;
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize, Default)]
56pub struct EnableParams {}
57
58impl EnableParams { pub const METHOD: &'static str = "DOMStorage.enable"; }
59
60impl crate::CdpCommand for EnableParams {
61    const METHOD: &'static str = "DOMStorage.enable";
62    type Response = crate::EmptyReturns;
63}
64
65
66#[derive(Debug, Clone, Serialize, Deserialize, Default)]
67#[serde(rename_all = "camelCase")]
68pub struct GetDOMStorageItemsParams {
69
70    pub storageId: StorageId,
71}
72
73
74#[derive(Debug, Clone, Serialize, Deserialize, Default)]
75#[serde(rename_all = "camelCase")]
76pub struct GetDOMStorageItemsReturns {
77
78    pub entries: Vec<Item>,
79}
80
81impl GetDOMStorageItemsParams { pub const METHOD: &'static str = "DOMStorage.getDOMStorageItems"; }
82
83impl crate::CdpCommand for GetDOMStorageItemsParams {
84    const METHOD: &'static str = "DOMStorage.getDOMStorageItems";
85    type Response = GetDOMStorageItemsReturns;
86}
87
88
89#[derive(Debug, Clone, Serialize, Deserialize, Default)]
90#[serde(rename_all = "camelCase")]
91pub struct RemoveDOMStorageItemParams {
92
93    pub storageId: StorageId,
94
95    pub key: String,
96}
97
98impl RemoveDOMStorageItemParams { pub const METHOD: &'static str = "DOMStorage.removeDOMStorageItem"; }
99
100impl crate::CdpCommand for RemoveDOMStorageItemParams {
101    const METHOD: &'static str = "DOMStorage.removeDOMStorageItem";
102    type Response = crate::EmptyReturns;
103}
104
105
106#[derive(Debug, Clone, Serialize, Deserialize, Default)]
107#[serde(rename_all = "camelCase")]
108pub struct SetDOMStorageItemParams {
109
110    pub storageId: StorageId,
111
112    pub key: String,
113
114    pub value: String,
115}
116
117impl SetDOMStorageItemParams { pub const METHOD: &'static str = "DOMStorage.setDOMStorageItem"; }
118
119impl crate::CdpCommand for SetDOMStorageItemParams {
120    const METHOD: &'static str = "DOMStorage.setDOMStorageItem";
121    type Response = crate::EmptyReturns;
122}