cdp-protocol 0.3.1

A Rust implementation of the Chrome DevTools Protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
// Auto-generated from Chrome at version 146.0.7680.165 domain: Fetch
#![allow(dead_code)]
use super::io;
use super::network;
#[allow(unused_imports)]
use super::types::*;
#[allow(unused_imports)]
use derive_builder::Builder;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use serde_json::Value as Json;
pub type RequestId = String;
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub enum RequestStage {
    #[serde(rename = "Request")]
    Request,
    #[serde(rename = "Response")]
    Response,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub enum AuthChallengeSource {
    #[serde(rename = "Server")]
    Server,
    #[serde(rename = "Proxy")]
    Proxy,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub enum AuthChallengeResponseResponse {
    #[serde(rename = "Default")]
    Default,
    #[serde(rename = "CancelAuth")]
    CancelAuth,
    #[serde(rename = "ProvideCredentials")]
    ProvideCredentials,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
pub struct RequestPattern {
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "Wildcards (`'*'` -\\> zero or more, `'?'` -\\> exactly one) are allowed. Escape character is\n backslash. Omitting is equivalent to `\"*\"`."]
    pub url_pattern: Option<String>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "If set, only requests for matching resource types will be intercepted."]
    pub resource_type: Option<network::ResourceType>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "Stage at which to begin intercepting requests. Default is Request."]
    pub request_stage: Option<RequestStage>,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Response HTTP header entry"]
pub struct HeaderEntry {
    #[serde(default)]
    pub name: String,
    #[serde(default)]
    pub value: String,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Authorization challenge for HTTP status code 401 or 407."]
pub struct AuthChallenge {
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "Source of the authentication challenge."]
    pub source: Option<AuthChallengeSource>,
    #[serde(default)]
    #[doc = "Origin of the challenger."]
    pub origin: String,
    #[serde(default)]
    #[doc = "The authentication scheme used, such as basic or digest"]
    pub scheme: String,
    #[serde(default)]
    #[doc = "The realm of the challenge. May be empty."]
    pub realm: String,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Response to an AuthChallenge."]
pub struct AuthChallengeResponse {
    #[doc = "The decision on what to do in response to the authorization challenge.  Default means\n deferring to the default behavior of the net stack, which will likely either the Cancel\n authentication or display a popup dialog box."]
    pub response: AuthChallengeResponseResponse,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "The username to provide, possibly empty. Should only be set if response is\n ProvideCredentials."]
    pub username: Option<String>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "The password to provide, possibly empty. Should only be set if response is\n ProvideCredentials."]
    pub password: Option<String>,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub struct Disable(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Enables issuing of requestPaused events. A request will be paused until client\n calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth."]
pub struct Enable {
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "If specified, only requests matching any of these patterns will produce\n fetchRequested event and will be paused until clients response. If not set,\n all requests will be affected."]
    pub patterns: Option<Vec<RequestPattern>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "If true, authRequired events will be issued and requests will be paused\n expecting a call to continueWithAuth."]
    pub handle_auth_requests: Option<bool>,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Causes the request to fail with specified reason."]
pub struct FailRequest {
    #[doc = "An id the client received in requestPaused event."]
    pub request_id: RequestId,
    #[doc = "Causes the request to fail with the given reason."]
    pub error_reason: network::ErrorReason,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Provides response to the request."]
pub struct FulfillRequest {
    #[doc = "An id the client received in requestPaused event."]
    pub request_id: RequestId,
    #[serde(default)]
    #[doc = "An HTTP response code."]
    pub response_code: JsUInt,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "Response headers."]
    pub response_headers: Option<Vec<HeaderEntry>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "Alternative way of specifying response headers as a \\0-separated\n series of name: value pairs. Prefer the above method unless you\n need to represent some non-UTF8 values that can't be transmitted\n over the protocol as text."]
    pub binary_response_headers: Option<Vec<u8>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "A response body. If absent, original response body will be used if\n the request is intercepted at the response stage and empty body\n will be used if the request is intercepted at the request stage."]
    pub body: Option<Vec<u8>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "A textual representation of responseCode.\n If absent, a standard phrase matching responseCode is used."]
    pub response_phrase: Option<String>,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Continues the request, optionally modifying some of its parameters."]
pub struct ContinueRequest {
    #[doc = "An id the client received in requestPaused event."]
    pub request_id: RequestId,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "If set, the request url will be modified in a way that's not observable by page."]
    pub url: Option<String>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "If set, the request method is overridden."]
    pub method: Option<String>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "If set, overrides the post data in the request."]
    pub post_data: Option<Vec<u8>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "If set, overrides the request headers. Note that the overrides do not\n extend to subsequent redirect hops, if a redirect happens. Another override\n may be applied to a different request produced by a redirect."]
    pub headers: Option<Vec<HeaderEntry>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "If set, overrides response interception behavior for this request."]
    pub intercept_response: Option<bool>,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Continues a request supplying authChallengeResponse following authRequired event."]
pub struct ContinueWithAuth {
    #[doc = "An id the client received in authRequired event."]
    pub request_id: RequestId,
    #[doc = "Response to  with an authChallenge."]
    pub auth_challenge_response: AuthChallengeResponse,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Continues loading of the paused response, optionally modifying the\n response headers. If either responseCode or headers are modified, all of them\n must be present."]
pub struct ContinueResponse {
    #[doc = "An id the client received in requestPaused event."]
    pub request_id: RequestId,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "An HTTP response code. If absent, original response code will be used."]
    pub response_code: Option<JsUInt>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[doc = "A textual representation of responseCode.\n If absent, a standard phrase matching responseCode is used."]
    pub response_phrase: Option<String>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "Response headers. If absent, original response headers will be used."]
    pub response_headers: Option<Vec<HeaderEntry>>,
    #[builder(default)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[doc = "Alternative way of specifying response headers as a \\0-separated\n series of name: value pairs. Prefer the above method unless you\n need to represent some non-UTF8 values that can't be transmitted\n over the protocol as text."]
    pub binary_response_headers: Option<Vec<u8>>,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Causes the body of the response to be received from the server and\n returned as a single string. May only be issued for a request that\n is paused in the Response stage and is mutually exclusive with\n takeResponseBodyForInterceptionAsStream. Calling other methods that\n affect the request or disabling fetch domain before body is received\n results in an undefined behavior.\n Note that the response body is not available for redirects. Requests\n paused in the _redirect received_ state may be differentiated by\n `responseCode` and presence of `location` response header, see\n comments to `requestPaused` for details."]
pub struct GetResponseBody {
    #[doc = "Identifier for the intercepted request to get body for."]
    pub request_id: RequestId,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[builder(setter(into, strip_option))]
#[serde(rename_all = "camelCase")]
#[doc = "Returns a handle to the stream representing the response body.\n The request must be paused in the HeadersReceived stage.\n Note that after this command the request can't be continued\n as is -- client either needs to cancel it or to provide the\n response body.\n The stream only supports sequential read, IO.read will fail if the position\n is specified.\n This method is mutually exclusive with getResponseBody.\n Calling other methods that affect the request or disabling fetch\n domain before body is received results in an undefined behavior."]
pub struct TakeResponseBodyAsStream {
    pub request_id: RequestId,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Disables the fetch domain."]
pub struct DisableReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Enables issuing of requestPaused events. A request will be paused until client\n calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth."]
pub struct EnableReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Causes the request to fail with specified reason."]
pub struct FailRequestReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Provides response to the request."]
pub struct FulfillRequestReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Continues the request, optionally modifying some of its parameters."]
pub struct ContinueRequestReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Continues a request supplying authChallengeResponse following authRequired event."]
pub struct ContinueWithAuthReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[doc = "Continues loading of the paused response, optionally modifying the\n response headers. If either responseCode or headers are modified, all of them\n must be present."]
pub struct ContinueResponseReturnObject(pub Option<Json>);
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[serde(rename_all = "camelCase")]
#[doc = "Causes the body of the response to be received from the server and\n returned as a single string. May only be issued for a request that\n is paused in the Response stage and is mutually exclusive with\n takeResponseBodyForInterceptionAsStream. Calling other methods that\n affect the request or disabling fetch domain before body is received\n results in an undefined behavior.\n Note that the response body is not available for redirects. Requests\n paused in the _redirect received_ state may be differentiated by\n `responseCode` and presence of `location` response header, see\n comments to `requestPaused` for details."]
pub struct GetResponseBodyReturnObject {
    #[serde(default)]
    #[doc = "Response body."]
    pub body: String,
    #[serde(default)]
    #[doc = "True, if content was sent as base64."]
    pub base_64_encoded: bool,
}
#[allow(deprecated)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
#[serde(rename_all = "camelCase")]
#[doc = "Returns a handle to the stream representing the response body.\n The request must be paused in the HeadersReceived stage.\n Note that after this command the request can't be continued\n as is -- client either needs to cancel it or to provide the\n response body.\n The stream only supports sequential read, IO.read will fail if the position\n is specified.\n This method is mutually exclusive with getResponseBody.\n Calling other methods that affect the request or disabling fetch\n domain before body is received results in an undefined behavior."]
pub struct TakeResponseBodyAsStreamReturnObject {
    pub stream: io::StreamHandle,
}
#[allow(deprecated)]
impl Method for Disable {
    const NAME: &'static str = "Fetch.disable";
    type ReturnObject = DisableReturnObject;
}
#[allow(deprecated)]
impl Method for Enable {
    const NAME: &'static str = "Fetch.enable";
    type ReturnObject = EnableReturnObject;
}
#[allow(deprecated)]
impl Method for FailRequest {
    const NAME: &'static str = "Fetch.failRequest";
    type ReturnObject = FailRequestReturnObject;
}
#[allow(deprecated)]
impl Method for FulfillRequest {
    const NAME: &'static str = "Fetch.fulfillRequest";
    type ReturnObject = FulfillRequestReturnObject;
}
#[allow(deprecated)]
impl Method for ContinueRequest {
    const NAME: &'static str = "Fetch.continueRequest";
    type ReturnObject = ContinueRequestReturnObject;
}
#[allow(deprecated)]
impl Method for ContinueWithAuth {
    const NAME: &'static str = "Fetch.continueWithAuth";
    type ReturnObject = ContinueWithAuthReturnObject;
}
#[allow(deprecated)]
impl Method for ContinueResponse {
    const NAME: &'static str = "Fetch.continueResponse";
    type ReturnObject = ContinueResponseReturnObject;
}
#[allow(deprecated)]
impl Method for GetResponseBody {
    const NAME: &'static str = "Fetch.getResponseBody";
    type ReturnObject = GetResponseBodyReturnObject;
}
#[allow(deprecated)]
impl Method for TakeResponseBodyAsStream {
    const NAME: &'static str = "Fetch.takeResponseBodyAsStream";
    type ReturnObject = TakeResponseBodyAsStreamReturnObject;
}
#[allow(dead_code)]
pub mod events {
    #[allow(unused_imports)]
    use super::super::types::*;
    #[allow(unused_imports)]
    use derive_builder::Builder;
    #[allow(unused_imports)]
    use serde::{Deserialize, Serialize};
    #[allow(unused_imports)]
    use serde_json::Value as Json;
    #[allow(deprecated)]
    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
    pub struct RequestPausedEvent {
        pub params: RequestPausedEventParams,
    }
    #[allow(deprecated)]
    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
    #[serde(rename_all = "camelCase")]
    pub struct RequestPausedEventParams {
        #[doc = "Each request the page makes will have a unique id."]
        pub request_id: super::RequestId,
        #[doc = "The details of the request."]
        pub request: super::super::network::Request,
        #[doc = "The id of the frame that initiated the request."]
        pub frame_id: super::super::page::FrameId,
        #[doc = "How the requested resource will be used."]
        pub resource_type: super::super::network::ResourceType,
        #[builder(default)]
        #[serde(skip_serializing_if = "Option::is_none")]
        #[doc = "Response error if intercepted at response stage."]
        pub response_error_reason: Option<super::super::network::ErrorReason>,
        #[builder(default)]
        #[serde(skip_serializing_if = "Option::is_none")]
        #[serde(default)]
        #[doc = "Response code if intercepted at response stage."]
        pub response_status_code: Option<JsUInt>,
        #[builder(default)]
        #[serde(skip_serializing_if = "Option::is_none")]
        #[serde(default)]
        #[doc = "Response status text if intercepted at response stage."]
        pub response_status_text: Option<String>,
        #[builder(default)]
        #[serde(skip_serializing_if = "Option::is_none")]
        #[doc = "Response headers if intercepted at the response stage."]
        pub response_headers: Option<Vec<super::HeaderEntry>>,
        #[builder(default)]
        #[serde(skip_serializing_if = "Option::is_none")]
        #[doc = "If the intercepted request had a corresponding Network.requestWillBeSent event fired for it,\n then this networkId will be the same as the requestId present in the requestWillBeSent event."]
        pub network_id: Option<super::super::network::RequestId>,
        #[builder(default)]
        #[serde(skip_serializing_if = "Option::is_none")]
        #[doc = "If the request is due to a redirect response from the server, the id of the request that\n has caused the redirect."]
        pub redirected_request_id: Option<super::RequestId>,
    }
    #[allow(deprecated)]
    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
    pub struct AuthRequiredEvent {
        pub params: AuthRequiredEventParams,
    }
    #[allow(deprecated)]
    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
    #[serde(rename_all = "camelCase")]
    pub struct AuthRequiredEventParams {
        #[doc = "Each request the page makes will have a unique id."]
        pub request_id: super::RequestId,
        #[doc = "The details of the request."]
        pub request: super::super::network::Request,
        #[doc = "The id of the frame that initiated the request."]
        pub frame_id: super::super::page::FrameId,
        #[doc = "How the requested resource will be used."]
        pub resource_type: super::super::network::ResourceType,
        #[doc = "Details of the Authorization Challenge encountered.\n If this is set, client should respond with continueRequest that\n contains AuthChallengeResponse."]
        pub auth_challenge: super::AuthChallenge,
    }
}