Skip to main content

cdp_driver/protocol/
dom_storage.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! Query and modify DOM storage.
5//!
6//! Types, command parameters and event payloads for the `DOMStorage`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9//!
10//! This domain is experimental and may change without notice.
11
12use serde::{Deserialize, Serialize};
13
14pub type SerializedStorageKey = String;
15
16/// DOM Storage identifier.
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
18pub struct StorageId {
19    /// Security origin for the storage.
20    #[serde(
21        rename = "securityOrigin",
22        default,
23        skip_serializing_if = "Option::is_none"
24    )]
25    pub security_origin: Option<String>,
26    /// Represents a key by which DOM Storage keys its CachedStorageAreas
27    #[serde(
28        rename = "storageKey",
29        default,
30        skip_serializing_if = "Option::is_none"
31    )]
32    pub storage_key: Option<SerializedStorageKey>,
33    /// Whether the storage is local storage (not session storage).
34    #[serde(rename = "isLocalStorage")]
35    pub is_local_storage: bool,
36}
37
38/// DOM Storage item.
39pub type Item = Vec<String>;
40
41/// Parameters of `DOMStorage.clear`.
42#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
43pub struct ClearParams {
44    #[serde(rename = "storageId")]
45    pub storage_id: StorageId,
46}
47
48impl crate::typed::Command for ClearParams {
49    const METHOD: &'static str = "DOMStorage.clear";
50    type Returns = crate::typed::NoReturns;
51}
52
53/// Disables storage tracking, prevents storage events from being sent to the
54/// client.
55///
56/// Parameters of `DOMStorage.disable`.
57#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
58pub struct DisableParams {}
59
60impl crate::typed::Command for DisableParams {
61    const METHOD: &'static str = "DOMStorage.disable";
62    type Returns = crate::typed::NoReturns;
63}
64
65/// Enables storage tracking, storage events will now be delivered to the
66/// client.
67///
68/// Parameters of `DOMStorage.enable`.
69#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
70pub struct EnableParams {}
71
72impl crate::typed::Command for EnableParams {
73    const METHOD: &'static str = "DOMStorage.enable";
74    type Returns = crate::typed::NoReturns;
75}
76
77/// Parameters of `DOMStorage.getDOMStorageItems`.
78#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
79pub struct GetDomStorageItemsParams {
80    #[serde(rename = "storageId")]
81    pub storage_id: StorageId,
82}
83
84/// What `DOMStorage.getDOMStorageItems` answers with.
85#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
86pub struct GetDomStorageItemsReturns {
87    pub entries: Vec<Item>,
88}
89
90impl crate::typed::Command for GetDomStorageItemsParams {
91    const METHOD: &'static str = "DOMStorage.getDOMStorageItems";
92    type Returns = GetDomStorageItemsReturns;
93}
94
95/// Parameters of `DOMStorage.removeDOMStorageItem`.
96#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
97pub struct RemoveDomStorageItemParams {
98    #[serde(rename = "storageId")]
99    pub storage_id: StorageId,
100    pub key: String,
101}
102
103impl crate::typed::Command for RemoveDomStorageItemParams {
104    const METHOD: &'static str = "DOMStorage.removeDOMStorageItem";
105    type Returns = crate::typed::NoReturns;
106}
107
108/// Parameters of `DOMStorage.setDOMStorageItem`.
109#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
110pub struct SetDomStorageItemParams {
111    #[serde(rename = "storageId")]
112    pub storage_id: StorageId,
113    pub key: String,
114    pub value: String,
115}
116
117impl crate::typed::Command for SetDomStorageItemParams {
118    const METHOD: &'static str = "DOMStorage.setDOMStorageItem";
119    type Returns = crate::typed::NoReturns;
120}
121
122/// Payload of the `DOMStorage.domStorageItemAdded` event.
123#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
124pub struct DomStorageItemAddedEvent {
125    #[serde(rename = "storageId")]
126    pub storage_id: StorageId,
127    pub key: String,
128    #[serde(rename = "newValue")]
129    pub new_value: String,
130}
131
132impl crate::typed::Event for DomStorageItemAddedEvent {
133    const METHOD: &'static str = "DOMStorage.domStorageItemAdded";
134}
135
136/// Payload of the `DOMStorage.domStorageItemRemoved` event.
137#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
138pub struct DomStorageItemRemovedEvent {
139    #[serde(rename = "storageId")]
140    pub storage_id: StorageId,
141    pub key: String,
142}
143
144impl crate::typed::Event for DomStorageItemRemovedEvent {
145    const METHOD: &'static str = "DOMStorage.domStorageItemRemoved";
146}
147
148/// Payload of the `DOMStorage.domStorageItemUpdated` event.
149#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
150pub struct DomStorageItemUpdatedEvent {
151    #[serde(rename = "storageId")]
152    pub storage_id: StorageId,
153    pub key: String,
154    #[serde(rename = "oldValue")]
155    pub old_value: String,
156    #[serde(rename = "newValue")]
157    pub new_value: String,
158}
159
160impl crate::typed::Event for DomStorageItemUpdatedEvent {
161    const METHOD: &'static str = "DOMStorage.domStorageItemUpdated";
162}
163
164/// Payload of the `DOMStorage.domStorageItemsCleared` event.
165#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
166pub struct DomStorageItemsClearedEvent {
167    #[serde(rename = "storageId")]
168    pub storage_id: StorageId,
169}
170
171impl crate::typed::Event for DomStorageItemsClearedEvent {
172    const METHOD: &'static str = "DOMStorage.domStorageItemsCleared";
173}