Skip to main content

cdp_driver/protocol/
cache_storage.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `CacheStorage` domain.
5//!
6//! Types, command parameters and event payloads for the `CacheStorage`
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/// Unique identifier of the Cache object.
15pub type CacheId = String;
16
17/// type of HTTP response cached
18#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
19pub enum CachedResponseType {
20    /// `basic`
21    #[serde(rename = "basic")]
22    Basic,
23    /// `cors`
24    #[serde(rename = "cors")]
25    Cors,
26    /// `default`
27    #[serde(rename = "default")]
28    Default,
29    /// `error`
30    #[serde(rename = "error")]
31    Error,
32    /// `opaqueResponse`
33    #[serde(rename = "opaqueResponse")]
34    OpaqueResponse,
35    /// `opaqueRedirect`
36    #[serde(rename = "opaqueRedirect")]
37    OpaqueRedirect,
38    /// A value this vendored schema does not list. Chrome adds values ahead of
39    /// the published protocol, so an unrecognised one is kept as it arrived
40    /// rather than failing the payload it came in.
41    #[serde(untagged)]
42    Unrecognized(String),
43}
44
45/// Data entry.
46#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
47pub struct DataEntry {
48    /// Request URL.
49    #[serde(rename = "requestURL")]
50    pub request_url: String,
51    /// Request method.
52    #[serde(rename = "requestMethod")]
53    pub request_method: String,
54    /// Request headers
55    #[serde(rename = "requestHeaders")]
56    pub request_headers: Vec<Header>,
57    /// Number of seconds since epoch.
58    #[serde(rename = "responseTime")]
59    pub response_time: f64,
60    /// HTTP response status code.
61    #[serde(rename = "responseStatus")]
62    pub response_status: i64,
63    /// HTTP response status text.
64    #[serde(rename = "responseStatusText")]
65    pub response_status_text: String,
66    /// HTTP response type
67    #[serde(rename = "responseType")]
68    pub response_type: CachedResponseType,
69    /// Response headers
70    #[serde(rename = "responseHeaders")]
71    pub response_headers: Vec<Header>,
72}
73
74/// Cache identifier.
75#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
76pub struct Cache {
77    /// An opaque unique id of the cache.
78    #[serde(rename = "cacheId")]
79    pub cache_id: CacheId,
80    /// Security origin of the cache.
81    #[serde(rename = "securityOrigin")]
82    pub security_origin: String,
83    /// Storage key of the cache.
84    #[serde(rename = "storageKey")]
85    pub storage_key: String,
86    /// Storage bucket of the cache.
87    #[serde(
88        rename = "storageBucket",
89        default,
90        skip_serializing_if = "Option::is_none"
91    )]
92    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
93    /// The name of the cache.
94    #[serde(rename = "cacheName")]
95    pub cache_name: String,
96}
97
98#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
99pub struct Header {
100    pub name: String,
101    pub value: String,
102}
103
104/// Cached response
105#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
106pub struct CachedResponse {
107    /// Entry content, base64-encoded. (Encoded as a base64 string when passed
108    /// over JSON)
109    pub body: String,
110}
111
112/// Deletes a cache.
113///
114/// Parameters of `CacheStorage.deleteCache`.
115#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
116pub struct DeleteCacheParams {
117    /// Id of cache for deletion.
118    #[serde(rename = "cacheId")]
119    pub cache_id: CacheId,
120}
121
122impl crate::typed::Command for DeleteCacheParams {
123    const METHOD: &'static str = "CacheStorage.deleteCache";
124    type Returns = crate::typed::NoReturns;
125}
126
127/// Deletes a cache entry.
128///
129/// Parameters of `CacheStorage.deleteEntry`.
130#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
131pub struct DeleteEntryParams {
132    /// Id of cache where the entry will be deleted.
133    #[serde(rename = "cacheId")]
134    pub cache_id: CacheId,
135    /// URL spec of the request.
136    pub request: String,
137}
138
139impl crate::typed::Command for DeleteEntryParams {
140    const METHOD: &'static str = "CacheStorage.deleteEntry";
141    type Returns = crate::typed::NoReturns;
142}
143
144/// Requests cache names.
145///
146/// Parameters of `CacheStorage.requestCacheNames`.
147#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
148pub struct RequestCacheNamesParams {
149    /// At least and at most one of securityOrigin, storageKey, storageBucket must
150    /// be specified. Security origin.
151    #[serde(
152        rename = "securityOrigin",
153        default,
154        skip_serializing_if = "Option::is_none"
155    )]
156    pub security_origin: Option<String>,
157    /// Storage key.
158    #[serde(
159        rename = "storageKey",
160        default,
161        skip_serializing_if = "Option::is_none"
162    )]
163    pub storage_key: Option<String>,
164    /// Storage bucket. If not specified, it uses the default bucket.
165    #[serde(
166        rename = "storageBucket",
167        default,
168        skip_serializing_if = "Option::is_none"
169    )]
170    pub storage_bucket: Option<crate::protocol::storage::StorageBucket>,
171}
172
173/// What `CacheStorage.requestCacheNames` answers with.
174#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
175pub struct RequestCacheNamesReturns {
176    /// Caches for the security origin.
177    pub caches: Vec<Cache>,
178}
179
180impl crate::typed::Command for RequestCacheNamesParams {
181    const METHOD: &'static str = "CacheStorage.requestCacheNames";
182    type Returns = RequestCacheNamesReturns;
183}
184
185/// Fetches cache entry.
186///
187/// Parameters of `CacheStorage.requestCachedResponse`.
188#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
189pub struct RequestCachedResponseParams {
190    /// Id of cache that contains the entry.
191    #[serde(rename = "cacheId")]
192    pub cache_id: CacheId,
193    /// URL spec of the request.
194    #[serde(rename = "requestURL")]
195    pub request_url: String,
196    /// headers of the request.
197    #[serde(rename = "requestHeaders")]
198    pub request_headers: Vec<Header>,
199}
200
201/// What `CacheStorage.requestCachedResponse` answers with.
202#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
203pub struct RequestCachedResponseReturns {
204    /// Response read from the cache.
205    pub response: CachedResponse,
206}
207
208impl crate::typed::Command for RequestCachedResponseParams {
209    const METHOD: &'static str = "CacheStorage.requestCachedResponse";
210    type Returns = RequestCachedResponseReturns;
211}
212
213/// Requests data from cache.
214///
215/// Parameters of `CacheStorage.requestEntries`.
216#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
217pub struct RequestEntriesParams {
218    /// ID of cache to get entries from.
219    #[serde(rename = "cacheId")]
220    pub cache_id: CacheId,
221    /// Number of records to skip.
222    #[serde(rename = "skipCount", default, skip_serializing_if = "Option::is_none")]
223    pub skip_count: Option<i64>,
224    /// Number of records to fetch.
225    #[serde(rename = "pageSize", default, skip_serializing_if = "Option::is_none")]
226    pub page_size: Option<i64>,
227    /// If present, only return the entries containing this substring in the path
228    #[serde(
229        rename = "pathFilter",
230        default,
231        skip_serializing_if = "Option::is_none"
232    )]
233    pub path_filter: Option<String>,
234}
235
236/// What `CacheStorage.requestEntries` answers with.
237#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
238pub struct RequestEntriesReturns {
239    /// Array of object store data entries.
240    #[serde(rename = "cacheDataEntries")]
241    pub cache_data_entries: Vec<DataEntry>,
242    /// Count of returned entries from this storage. If pathFilter is empty, it is
243    /// the count of all entries from this storage.
244    #[serde(rename = "returnCount")]
245    pub return_count: f64,
246}
247
248impl crate::typed::Command for RequestEntriesParams {
249    const METHOD: &'static str = "CacheStorage.requestEntries";
250    type Returns = RequestEntriesReturns;
251}