Skip to main content

cdp_driver/protocol/
indexed_db.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `IndexedDB` domain.
5//!
6//! Types, command parameters and event payloads for the `IndexedDB`
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
14/// Database with an array of object stores.
15#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
16pub struct DatabaseWithObjectStores {
17    /// Database name.
18    pub name: String,
19    /// Database version (type is not 'integer', as the standard requires the
20    /// version number to be 'unsigned long long')
21    pub version: f64,
22    /// Object stores in this database.
23    #[serde(rename = "objectStores")]
24    pub object_stores: Vec<ObjectStore>,
25}
26
27/// Object store.
28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
29pub struct ObjectStore {
30    /// Object store name.
31    pub name: String,
32    /// Object store key path.
33    #[serde(rename = "keyPath")]
34    pub key_path: KeyPath,
35    /// If true, object store has auto increment flag set.
36    #[serde(rename = "autoIncrement")]
37    pub auto_increment: bool,
38    /// Indexes in this object store.
39    pub indexes: Vec<ObjectStoreIndex>,
40}
41
42/// Object store index.
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
44pub struct ObjectStoreIndex {
45    /// Index name.
46    pub name: String,
47    /// Index key path.
48    #[serde(rename = "keyPath")]
49    pub key_path: KeyPath,
50    /// If true, index is unique.
51    pub unique: bool,
52    /// If true, index allows multiple entries for a key.
53    #[serde(rename = "multiEntry")]
54    pub multi_entry: bool,
55}
56
57/// Key.
58#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
59pub struct Key {
60    /// Key type.
61    pub r#type: KeyType,
62    /// Number value.
63    #[serde(default, skip_serializing_if = "Option::is_none")]
64    pub number: Option<f64>,
65    /// String value.
66    #[serde(default, skip_serializing_if = "Option::is_none")]
67    pub string: Option<String>,
68    /// Date value.
69    #[serde(default, skip_serializing_if = "Option::is_none")]
70    pub date: Option<f64>,
71    /// Array value.
72    #[serde(default, skip_serializing_if = "Option::is_none")]
73    pub array: Option<Vec<Key>>,
74}
75
76/// The values `type` accepts on `Key`.
77#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
78pub enum KeyType {
79    /// `number`
80    #[serde(rename = "number")]
81    Number,
82    /// `string`
83    #[serde(rename = "string")]
84    String,
85    /// `date`
86    #[serde(rename = "date")]
87    Date,
88    /// `array`
89    #[serde(rename = "array")]
90    Array,
91    /// A value this vendored schema does not list. Chrome adds values ahead of
92    /// the published protocol, so an unrecognised one is kept as it arrived
93    /// rather than failing the payload it came in.
94    #[serde(untagged)]
95    Unrecognized(String),
96}
97
98/// Key range.
99#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
100pub struct KeyRange {
101    /// Lower bound.
102    #[serde(default, skip_serializing_if = "Option::is_none")]
103    pub lower: Option<Key>,
104    /// Upper bound.
105    #[serde(default, skip_serializing_if = "Option::is_none")]
106    pub upper: Option<Key>,
107    /// If true lower bound is open.
108    #[serde(rename = "lowerOpen")]
109    pub lower_open: bool,
110    /// If true upper bound is open.
111    #[serde(rename = "upperOpen")]
112    pub upper_open: bool,
113}
114
115/// Data entry.
116#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
117pub struct DataEntry {
118    /// Key object.
119    pub key: crate::protocol::runtime::RemoteObject,
120    /// Primary key object.
121    #[serde(rename = "primaryKey")]
122    pub primary_key: crate::protocol::runtime::RemoteObject,
123    /// Value object.
124    pub value: crate::protocol::runtime::RemoteObject,
125}
126
127/// Key path.
128#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
129pub struct KeyPath {
130    /// Key path type.
131    pub r#type: KeyPathType,
132    /// String value.
133    #[serde(default, skip_serializing_if = "Option::is_none")]
134    pub string: Option<String>,
135    /// Array value.
136    #[serde(default, skip_serializing_if = "Option::is_none")]
137    pub array: Option<Vec<String>>,
138}
139
140/// The values `type` accepts on `KeyPath`.
141#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
142pub enum KeyPathType {
143    /// `null`
144    #[serde(rename = "null")]
145    Null,
146    /// `string`
147    #[serde(rename = "string")]
148    String,
149    /// `array`
150    #[serde(rename = "array")]
151    Array,
152    /// A value this vendored schema does not list. Chrome adds values ahead of
153    /// the published protocol, so an unrecognised one is kept as it arrived
154    /// rather than failing the payload it came in.
155    #[serde(untagged)]
156    Unrecognized(String),
157}
158
159/// Clears all entries from an object store.
160///
161/// Parameters of `IndexedDB.clearObjectStore`.
162#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
163pub struct ClearObjectStoreParams {
164    /// At least and at most one of securityOrigin, storageKey, or storageBucket
165    /// must be specified. Security origin.
166    #[serde(
167        rename = "securityOrigin",
168        default,
169        skip_serializing_if = "Option::is_none"
170    )]
171    pub security_origin: Option<String>,
172    /// Storage key.
173    #[serde(
174        rename = "storageKey",
175        default,
176        skip_serializing_if = "Option::is_none"
177    )]
178    pub storage_key: Option<String>,
179    /// Storage bucket. If not specified, it uses the default bucket.
180    #[serde(
181        rename = "storageBucket",
182        default,
183        skip_serializing_if = "Option::is_none"
184    )]
185    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
186    /// Database name.
187    #[serde(rename = "databaseName")]
188    pub database_name: String,
189    /// Object store name.
190    #[serde(rename = "objectStoreName")]
191    pub object_store_name: String,
192}
193
194impl crate::typed::Command for ClearObjectStoreParams {
195    const METHOD: &'static str = "IndexedDB.clearObjectStore";
196    type Returns = crate::typed::NoReturns;
197}
198
199/// Deletes a database.
200///
201/// Parameters of `IndexedDB.deleteDatabase`.
202#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
203pub struct DeleteDatabaseParams {
204    /// At least and at most one of securityOrigin, storageKey, or storageBucket
205    /// must be specified. Security origin.
206    #[serde(
207        rename = "securityOrigin",
208        default,
209        skip_serializing_if = "Option::is_none"
210    )]
211    pub security_origin: Option<String>,
212    /// Storage key.
213    #[serde(
214        rename = "storageKey",
215        default,
216        skip_serializing_if = "Option::is_none"
217    )]
218    pub storage_key: Option<String>,
219    /// Storage bucket. If not specified, it uses the default bucket.
220    #[serde(
221        rename = "storageBucket",
222        default,
223        skip_serializing_if = "Option::is_none"
224    )]
225    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
226    /// Database name.
227    #[serde(rename = "databaseName")]
228    pub database_name: String,
229}
230
231impl crate::typed::Command for DeleteDatabaseParams {
232    const METHOD: &'static str = "IndexedDB.deleteDatabase";
233    type Returns = crate::typed::NoReturns;
234}
235
236/// Delete a range of entries from an object store
237///
238/// Parameters of `IndexedDB.deleteObjectStoreEntries`.
239#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
240pub struct DeleteObjectStoreEntriesParams {
241    /// At least and at most one of securityOrigin, storageKey, or storageBucket
242    /// must be specified. Security origin.
243    #[serde(
244        rename = "securityOrigin",
245        default,
246        skip_serializing_if = "Option::is_none"
247    )]
248    pub security_origin: Option<String>,
249    /// Storage key.
250    #[serde(
251        rename = "storageKey",
252        default,
253        skip_serializing_if = "Option::is_none"
254    )]
255    pub storage_key: Option<String>,
256    /// Storage bucket. If not specified, it uses the default bucket.
257    #[serde(
258        rename = "storageBucket",
259        default,
260        skip_serializing_if = "Option::is_none"
261    )]
262    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
263    #[serde(rename = "databaseName")]
264    pub database_name: String,
265    #[serde(rename = "objectStoreName")]
266    pub object_store_name: String,
267    /// Range of entry keys to delete
268    #[serde(rename = "keyRange")]
269    pub key_range: KeyRange,
270}
271
272impl crate::typed::Command for DeleteObjectStoreEntriesParams {
273    const METHOD: &'static str = "IndexedDB.deleteObjectStoreEntries";
274    type Returns = crate::typed::NoReturns;
275}
276
277/// Disables events from backend.
278///
279/// Parameters of `IndexedDB.disable`.
280#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
281pub struct DisableParams {}
282
283impl crate::typed::Command for DisableParams {
284    const METHOD: &'static str = "IndexedDB.disable";
285    type Returns = crate::typed::NoReturns;
286}
287
288/// Enables events from backend.
289///
290/// Parameters of `IndexedDB.enable`.
291#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
292pub struct EnableParams {}
293
294impl crate::typed::Command for EnableParams {
295    const METHOD: &'static str = "IndexedDB.enable";
296    type Returns = crate::typed::NoReturns;
297}
298
299/// Requests data from object store or index.
300///
301/// Parameters of `IndexedDB.requestData`.
302#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
303pub struct RequestDataParams {
304    /// At least and at most one of securityOrigin, storageKey, or storageBucket
305    /// must be specified. Security origin.
306    #[serde(
307        rename = "securityOrigin",
308        default,
309        skip_serializing_if = "Option::is_none"
310    )]
311    pub security_origin: Option<String>,
312    /// Storage key.
313    #[serde(
314        rename = "storageKey",
315        default,
316        skip_serializing_if = "Option::is_none"
317    )]
318    pub storage_key: Option<String>,
319    /// Storage bucket. If not specified, it uses the default bucket.
320    #[serde(
321        rename = "storageBucket",
322        default,
323        skip_serializing_if = "Option::is_none"
324    )]
325    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
326    /// Database name.
327    #[serde(rename = "databaseName")]
328    pub database_name: String,
329    /// Object store name.
330    #[serde(rename = "objectStoreName")]
331    pub object_store_name: String,
332    /// Index name. If not specified, it performs an object store data request.
333    #[serde(rename = "indexName", default, skip_serializing_if = "Option::is_none")]
334    pub index_name: Option<String>,
335    /// Number of records to skip.
336    #[serde(rename = "skipCount")]
337    pub skip_count: i64,
338    /// Number of records to fetch.
339    #[serde(rename = "pageSize")]
340    pub page_size: i64,
341    /// Key range.
342    #[serde(rename = "keyRange", default, skip_serializing_if = "Option::is_none")]
343    pub key_range: Option<KeyRange>,
344}
345
346/// What `IndexedDB.requestData` answers with.
347#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
348pub struct RequestDataReturns {
349    /// Array of object store data entries.
350    #[serde(rename = "objectStoreDataEntries")]
351    pub object_store_data_entries: Vec<DataEntry>,
352    /// If true, there are more entries to fetch in the given range.
353    #[serde(rename = "hasMore")]
354    pub has_more: bool,
355}
356
357impl crate::typed::Command for RequestDataParams {
358    const METHOD: &'static str = "IndexedDB.requestData";
359    type Returns = RequestDataReturns;
360}
361
362/// Gets metadata of an object store.
363///
364/// Parameters of `IndexedDB.getMetadata`.
365#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
366pub struct GetMetadataParams {
367    /// At least and at most one of securityOrigin, storageKey, or storageBucket
368    /// must be specified. Security origin.
369    #[serde(
370        rename = "securityOrigin",
371        default,
372        skip_serializing_if = "Option::is_none"
373    )]
374    pub security_origin: Option<String>,
375    /// Storage key.
376    #[serde(
377        rename = "storageKey",
378        default,
379        skip_serializing_if = "Option::is_none"
380    )]
381    pub storage_key: Option<String>,
382    /// Storage bucket. If not specified, it uses the default bucket.
383    #[serde(
384        rename = "storageBucket",
385        default,
386        skip_serializing_if = "Option::is_none"
387    )]
388    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
389    /// Database name.
390    #[serde(rename = "databaseName")]
391    pub database_name: String,
392    /// Object store name.
393    #[serde(rename = "objectStoreName")]
394    pub object_store_name: String,
395}
396
397/// What `IndexedDB.getMetadata` answers with.
398#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
399pub struct GetMetadataReturns {
400    /// the entries count
401    #[serde(rename = "entriesCount")]
402    pub entries_count: f64,
403    /// the current value of key generator, to become the next inserted key into
404    /// the object store. Valid if objectStore.autoIncrement is true.
405    #[serde(rename = "keyGeneratorValue")]
406    pub key_generator_value: f64,
407}
408
409impl crate::typed::Command for GetMetadataParams {
410    const METHOD: &'static str = "IndexedDB.getMetadata";
411    type Returns = GetMetadataReturns;
412}
413
414/// Requests database with given name in given frame.
415///
416/// Parameters of `IndexedDB.requestDatabase`.
417#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
418pub struct RequestDatabaseParams {
419    /// At least and at most one of securityOrigin, storageKey, or storageBucket
420    /// must be specified. Security origin.
421    #[serde(
422        rename = "securityOrigin",
423        default,
424        skip_serializing_if = "Option::is_none"
425    )]
426    pub security_origin: Option<String>,
427    /// Storage key.
428    #[serde(
429        rename = "storageKey",
430        default,
431        skip_serializing_if = "Option::is_none"
432    )]
433    pub storage_key: Option<String>,
434    /// Storage bucket. If not specified, it uses the default bucket.
435    #[serde(
436        rename = "storageBucket",
437        default,
438        skip_serializing_if = "Option::is_none"
439    )]
440    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
441    /// Database name.
442    #[serde(rename = "databaseName")]
443    pub database_name: String,
444}
445
446/// What `IndexedDB.requestDatabase` answers with.
447#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
448pub struct RequestDatabaseReturns {
449    /// Database with an array of object stores.
450    #[serde(rename = "databaseWithObjectStores")]
451    pub database_with_object_stores: DatabaseWithObjectStores,
452}
453
454impl crate::typed::Command for RequestDatabaseParams {
455    const METHOD: &'static str = "IndexedDB.requestDatabase";
456    type Returns = RequestDatabaseReturns;
457}
458
459/// Requests database names for given security origin.
460///
461/// Parameters of `IndexedDB.requestDatabaseNames`.
462#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
463pub struct RequestDatabaseNamesParams {
464    /// At least and at most one of securityOrigin, storageKey, or storageBucket
465    /// must be specified. Security origin.
466    #[serde(
467        rename = "securityOrigin",
468        default,
469        skip_serializing_if = "Option::is_none"
470    )]
471    pub security_origin: Option<String>,
472    /// Storage key.
473    #[serde(
474        rename = "storageKey",
475        default,
476        skip_serializing_if = "Option::is_none"
477    )]
478    pub storage_key: Option<String>,
479    /// Storage bucket. If not specified, it uses the default bucket.
480    #[serde(
481        rename = "storageBucket",
482        default,
483        skip_serializing_if = "Option::is_none"
484    )]
485    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
486}
487
488/// What `IndexedDB.requestDatabaseNames` answers with.
489#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
490pub struct RequestDatabaseNamesReturns {
491    /// Database names for origin.
492    #[serde(rename = "databaseNames")]
493    pub database_names: Vec<String>,
494}
495
496impl crate::typed::Command for RequestDatabaseNamesParams {
497    const METHOD: &'static str = "IndexedDB.requestDatabaseNames";
498    type Returns = RequestDatabaseNamesReturns;
499}