cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! The `Preload` domain.
//!
//! Types, command parameters and event payloads for the `Preload`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.

use serde::{Deserialize, Serialize};

/// Unique id
pub type RuleSetId = String;

/// Corresponds to SpeculationRuleSet
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RuleSet {
    pub id: RuleSetId,
    /// Identifies a document which the rule set is associated with.
    #[serde(rename = "loaderId")]
    pub loader_id: crate::protocol::network::LoaderId,
    /// Source text of JSON representing the rule set. If it comes from
    /// `\<script\>` tag, it is the textContent of the node. Note that it is a
    /// JSON for valid case. See also: -
    /// <https://wicg.github.io/nav-speculation/speculation-rules.html> -
    /// <https://github.com/WICG/nav-speculation/blob/main/triggers.md>
    #[serde(rename = "sourceText")]
    pub source_text: String,
    /// A speculation rule set is either added through an inline `\<script\>` tag
    /// or through an external resource via the 'Speculation-Rules' HTTP header.
    /// For the first case, we include the BackendNodeId of the relevant
    /// `\<script\>` tag. For the second case, we include the external URL where
    /// the rule set was loaded from, and also RequestId if Network domain is
    /// enabled. See also: -
    /// <https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-script>
    /// -
    /// <https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-header>
    #[serde(
        rename = "backendNodeId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub backend_node_id: Option<crate::protocol::dom::BackendNodeId>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(rename = "requestId", default, skip_serializing_if = "Option::is_none")]
    pub request_id: Option<crate::protocol::network::RequestId>,
    /// Error information `errorMessage` is null iff `errorType` is null.
    #[serde(rename = "errorType", default, skip_serializing_if = "Option::is_none")]
    pub error_type: Option<RuleSetErrorType>,
    /// TODO(<https://crbug.com/1425354>): Replace this property with structured
    /// error.
    ///
    /// Deprecated in the protocol.
    #[serde(
        rename = "errorMessage",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub error_message: Option<String>,
    /// For more details, see:
    /// <https://github.com/WICG/nav-speculation/blob/main/speculation-rules-tags.md>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tag: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RuleSetErrorType {
    /// `SourceIsNotJsonObject`
    SourceIsNotJsonObject,
    /// `InvalidRulesSkipped`
    InvalidRulesSkipped,
    /// `InvalidRulesetLevelTag`
    InvalidRulesetLevelTag,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// The type of preloading attempted. It corresponds to
/// mojom::SpeculationAction (although PrefetchWithSubresources is omitted as
/// it isn't being used by clients).
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SpeculationAction {
    /// `Prefetch`
    Prefetch,
    /// `Prerender`
    Prerender,
    /// `PrerenderUntilScript`
    PrerenderUntilScript,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Corresponds to mojom::SpeculationTargetHint. See
/// <https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints>
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SpeculationTargetHint {
    /// `Blank`
    Blank,
    /// `Self`
    #[serde(rename = "Self")]
    Self_,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// A key that identifies a preloading attempt. The url used is the url
/// specified by the trigger (i.e. the initial URL), and not the final url
/// that is navigated to. For example, prerendering allows same-origin main
/// frame navigations during the attempt, but the attempt is still keyed with
/// the initial URL.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PreloadingAttemptKey {
    #[serde(rename = "loaderId")]
    pub loader_id: crate::protocol::network::LoaderId,
    pub action: SpeculationAction,
    pub url: String,
    #[serde(
        rename = "formSubmission",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub form_submission: Option<bool>,
    #[serde(
        rename = "targetHint",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub target_hint: Option<SpeculationTargetHint>,
}

/// Lists sources for a preloading attempt, specifically the ids of rule sets
/// that had a speculation rule that triggered the attempt, and the
/// BackendNodeIds of \<a href\> or \<area href\> elements that triggered the
/// attempt (in the case of attempts triggered by a document rule). It is
/// possible for multiple rule sets and links to trigger a single attempt.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PreloadingAttemptSource {
    pub key: PreloadingAttemptKey,
    #[serde(rename = "ruleSetIds")]
    pub rule_set_ids: Vec<RuleSetId>,
    #[serde(rename = "nodeIds")]
    pub node_ids: Vec<crate::protocol::dom::BackendNodeId>,
}

/// Chrome manages different types of preloads together using a concept of
/// preloading pipeline. For example, if a site uses a SpeculationRules for
/// prerender, Chrome first starts a prefetch and then upgrades it to
/// prerender. CDP events for them are emitted separately but they share
/// `PreloadPipelineId`.
pub type PreloadPipelineId = String;

/// List of FinalStatus reasons for Prerender2.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PrerenderFinalStatus {
    /// `Activated`
    Activated,
    /// `Destroyed`
    Destroyed,
    /// `LowEndDevice`
    LowEndDevice,
    /// `InvalidSchemeRedirect`
    InvalidSchemeRedirect,
    /// `InvalidSchemeNavigation`
    InvalidSchemeNavigation,
    /// `NavigationRequestBlockedByCsp`
    NavigationRequestBlockedByCsp,
    /// `MojoBinderPolicy`
    MojoBinderPolicy,
    /// `RendererProcessCrashed`
    RendererProcessCrashed,
    /// `RendererProcessKilled`
    RendererProcessKilled,
    /// `Download`
    Download,
    /// `TriggerDestroyed`
    TriggerDestroyed,
    /// `NavigationNotCommitted`
    NavigationNotCommitted,
    /// `NavigationBadHttpStatus`
    NavigationBadHttpStatus,
    /// `ClientCertRequested`
    ClientCertRequested,
    /// `NavigationRequestNetworkError`
    NavigationRequestNetworkError,
    /// `CancelAllHostsForTesting`
    CancelAllHostsForTesting,
    /// `DidFailLoad`
    DidFailLoad,
    /// `Stop`
    Stop,
    /// `SslCertificateError`
    SslCertificateError,
    /// `LoginAuthRequested`
    LoginAuthRequested,
    /// `UaChangeRequiresReload`
    UaChangeRequiresReload,
    /// `BlockedByClient`
    BlockedByClient,
    /// `AudioOutputDeviceRequested`
    AudioOutputDeviceRequested,
    /// `MixedContent`
    MixedContent,
    /// `TriggerBackgrounded`
    TriggerBackgrounded,
    /// `MemoryLimitExceeded`
    MemoryLimitExceeded,
    /// `DataSaverEnabled`
    DataSaverEnabled,
    /// `TriggerUrlHasEffectiveUrl`
    TriggerUrlHasEffectiveUrl,
    /// `ActivatedBeforeStarted`
    ActivatedBeforeStarted,
    /// `InactivePageRestriction`
    InactivePageRestriction,
    /// `StartFailed`
    StartFailed,
    /// `TimeoutBackgrounded`
    TimeoutBackgrounded,
    /// `CrossSiteRedirectInInitialNavigation`
    CrossSiteRedirectInInitialNavigation,
    /// `CrossSiteNavigationInInitialNavigation`
    CrossSiteNavigationInInitialNavigation,
    /// `SameSiteCrossOriginRedirectNotOptInInInitialNavigation`
    SameSiteCrossOriginRedirectNotOptInInInitialNavigation,
    /// `SameSiteCrossOriginNavigationNotOptInInInitialNavigation`
    SameSiteCrossOriginNavigationNotOptInInInitialNavigation,
    /// `ActivationNavigationParameterMismatch`
    ActivationNavigationParameterMismatch,
    /// `ActivatedInBackground`
    ActivatedInBackground,
    /// `EmbedderHostDisallowed`
    EmbedderHostDisallowed,
    /// `ActivationNavigationDestroyedBeforeSuccess`
    ActivationNavigationDestroyedBeforeSuccess,
    /// `TabClosedByUserGesture`
    TabClosedByUserGesture,
    /// `TabClosedWithoutUserGesture`
    TabClosedWithoutUserGesture,
    /// `PrimaryMainFrameRendererProcessCrashed`
    PrimaryMainFrameRendererProcessCrashed,
    /// `PrimaryMainFrameRendererProcessKilled`
    PrimaryMainFrameRendererProcessKilled,
    /// `ActivationFramePolicyNotCompatible`
    ActivationFramePolicyNotCompatible,
    /// `PreloadingDisabled`
    PreloadingDisabled,
    /// `BatterySaverEnabled`
    BatterySaverEnabled,
    /// `ActivatedDuringMainFrameNavigation`
    ActivatedDuringMainFrameNavigation,
    /// `PreloadingUnsupportedByWebContents`
    PreloadingUnsupportedByWebContents,
    /// `CrossSiteRedirectInMainFrameNavigation`
    CrossSiteRedirectInMainFrameNavigation,
    /// `CrossSiteNavigationInMainFrameNavigation`
    CrossSiteNavigationInMainFrameNavigation,
    /// `SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation`
    SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation,
    /// `SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation`
    SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation,
    /// `MemoryPressureOnTrigger`
    MemoryPressureOnTrigger,
    /// `MemoryPressureAfterTriggered`
    MemoryPressureAfterTriggered,
    /// `PrerenderingDisabledByDevTools`
    PrerenderingDisabledByDevTools,
    /// `SpeculationRuleRemoved`
    SpeculationRuleRemoved,
    /// `ActivatedWithAuxiliaryBrowsingContexts`
    ActivatedWithAuxiliaryBrowsingContexts,
    /// `MaxNumOfRunningEagerPrerendersExceeded`
    MaxNumOfRunningEagerPrerendersExceeded,
    /// `MaxNumOfRunningNonEagerPrerendersExceeded`
    MaxNumOfRunningNonEagerPrerendersExceeded,
    /// `MaxNumOfRunningEmbedderPrerendersExceeded`
    MaxNumOfRunningEmbedderPrerendersExceeded,
    /// `PrerenderingUrlHasEffectiveUrl`
    PrerenderingUrlHasEffectiveUrl,
    /// `RedirectedPrerenderingUrlHasEffectiveUrl`
    RedirectedPrerenderingUrlHasEffectiveUrl,
    /// `ActivationUrlHasEffectiveUrl`
    ActivationUrlHasEffectiveUrl,
    /// `JavaScriptInterfaceAdded`
    JavaScriptInterfaceAdded,
    /// `JavaScriptInterfaceRemoved`
    JavaScriptInterfaceRemoved,
    /// `AllPrerenderingCanceled`
    AllPrerenderingCanceled,
    /// `WindowClosed`
    WindowClosed,
    /// `SlowNetwork`
    SlowNetwork,
    /// `OtherPrerenderedPageActivated`
    OtherPrerenderedPageActivated,
    /// `V8OptimizerDisabled`
    V8OptimizerDisabled,
    /// `PrerenderFailedDuringPrefetch`
    PrerenderFailedDuringPrefetch,
    /// `BrowsingDataRemoved`
    BrowsingDataRemoved,
    /// `PrerenderHostReused`
    PrerenderHostReused,
    /// `FormSubmitWhenPrerendering`
    FormSubmitWhenPrerendering,
    /// `CrossDocumentRestart`
    CrossDocumentRestart,
    /// `PrefetchFailedCrossOriginSubframe`
    PrefetchFailedCrossOriginSubframe,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Preloading status values, see also PreloadingTriggeringOutcome. This
/// status is shared by prefetchStatusUpdated and prerenderStatusUpdated.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PreloadingStatus {
    /// `Pending`
    Pending,
    /// `Running`
    Running,
    /// `Ready`
    Ready,
    /// `Success`
    Success,
    /// `Failure`
    Failure,
    /// `NotSupported`
    NotSupported,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// TODO(<https://crbug.com/1384419>): revisit the list of PrefetchStatus and
/// filter out the ones that aren't necessary to the developers.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PrefetchStatus {
    /// `PrefetchAllowed`
    PrefetchAllowed,
    /// `PrefetchFailedIneligibleRedirect`
    PrefetchFailedIneligibleRedirect,
    /// `PrefetchFailedInvalidRedirect`
    PrefetchFailedInvalidRedirect,
    /// `PrefetchFailedMIMENotSupported`
    #[serde(rename = "PrefetchFailedMIMENotSupported")]
    PrefetchFailedMimeNotSupported,
    /// `PrefetchFailedNetError`
    PrefetchFailedNetError,
    /// `PrefetchFailedNon2XX`
    #[serde(rename = "PrefetchFailedNon2XX")]
    PrefetchFailedNon2Xx,
    /// `PrefetchEvictedAfterBrowsingDataRemoved`
    PrefetchEvictedAfterBrowsingDataRemoved,
    /// `PrefetchEvictedAfterCandidateRemoved`
    PrefetchEvictedAfterCandidateRemoved,
    /// `PrefetchEvictedForNewerPrefetch`
    PrefetchEvictedForNewerPrefetch,
    /// `PrefetchHeldback`
    PrefetchHeldback,
    /// `PrefetchIneligibleRetryAfter`
    PrefetchIneligibleRetryAfter,
    /// `PrefetchIsPrivacyDecoy`
    PrefetchIsPrivacyDecoy,
    /// `PrefetchIsStale`
    PrefetchIsStale,
    /// `PrefetchNotEligibleBlockedByConnectionAllowlist`
    PrefetchNotEligibleBlockedByConnectionAllowlist,
    /// `PrefetchNotEligibleBrowserContextOffTheRecord`
    PrefetchNotEligibleBrowserContextOffTheRecord,
    /// `PrefetchNotEligibleCrossOrigin`
    PrefetchNotEligibleCrossOrigin,
    /// `PrefetchNotEligibleDataSaverEnabled`
    PrefetchNotEligibleDataSaverEnabled,
    /// `PrefetchNotEligibleExistingProxy`
    PrefetchNotEligibleExistingProxy,
    /// `PrefetchNotEligibleHostIsNonUnique`
    PrefetchNotEligibleHostIsNonUnique,
    /// `PrefetchNotEligibleNonDefaultStoragePartition`
    PrefetchNotEligibleNonDefaultStoragePartition,
    /// `PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy`
    PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy,
    /// `PrefetchNotEligibleSchemeIsNotHttps`
    PrefetchNotEligibleSchemeIsNotHttps,
    /// `PrefetchNotEligibleUserHasCookies`
    PrefetchNotEligibleUserHasCookies,
    /// `PrefetchNotEligibleUserHasServiceWorker`
    PrefetchNotEligibleUserHasServiceWorker,
    /// `PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler`
    PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler,
    /// `PrefetchNotEligibleRedirectFromServiceWorker`
    PrefetchNotEligibleRedirectFromServiceWorker,
    /// `PrefetchNotEligibleRedirectToServiceWorker`
    PrefetchNotEligibleRedirectToServiceWorker,
    /// `PrefetchNotEligibleBatterySaverEnabled`
    PrefetchNotEligibleBatterySaverEnabled,
    /// `PrefetchNotEligiblePreloadingDisabled`
    PrefetchNotEligiblePreloadingDisabled,
    /// `PrefetchNotFinishedInTime`
    PrefetchNotFinishedInTime,
    /// `PrefetchNotStarted`
    PrefetchNotStarted,
    /// `PrefetchNotUsedCookiesChanged`
    PrefetchNotUsedCookiesChanged,
    /// `PrefetchProxyNotAvailable`
    PrefetchProxyNotAvailable,
    /// `PrefetchResponseUsed`
    PrefetchResponseUsed,
    /// `PrefetchSuccessfulButNotUsed`
    PrefetchSuccessfulButNotUsed,
    /// `PrefetchNotUsedProbeFailed`
    PrefetchNotUsedProbeFailed,
    /// `PrefetchCancelledOnUserNavigation`
    PrefetchCancelledOnUserNavigation,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Information of headers to be displayed when the header mismatch occurred.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PrerenderMismatchedHeaders {
    #[serde(rename = "headerName")]
    pub header_name: String,
    #[serde(
        rename = "initialValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub initial_value: Option<String>,
    #[serde(
        rename = "activationValue",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub activation_value: Option<String>,
}

/// Parameters of `Preload.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}

impl crate::typed::Command for EnableParams {
    const METHOD: &'static str = "Preload.enable";
    type Returns = crate::typed::NoReturns;
}

/// Parameters of `Preload.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}

impl crate::typed::Command for DisableParams {
    const METHOD: &'static str = "Preload.disable";
    type Returns = crate::typed::NoReturns;
}

/// Upsert. Currently, it is only emitted when a rule set added.
///
/// Payload of the `Preload.ruleSetUpdated` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RuleSetUpdatedEvent {
    #[serde(rename = "ruleSet")]
    pub rule_set: RuleSet,
}

impl crate::typed::Event for RuleSetUpdatedEvent {
    const METHOD: &'static str = "Preload.ruleSetUpdated";
}

/// Payload of the `Preload.ruleSetRemoved` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RuleSetRemovedEvent {
    pub id: RuleSetId,
}

impl crate::typed::Event for RuleSetRemovedEvent {
    const METHOD: &'static str = "Preload.ruleSetRemoved";
}

/// Fired when a preload enabled state is updated.
///
/// Payload of the `Preload.preloadEnabledStateUpdated` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PreloadEnabledStateUpdatedEvent {
    #[serde(rename = "disabledByPreference")]
    pub disabled_by_preference: bool,
    #[serde(rename = "disabledByDataSaver")]
    pub disabled_by_data_saver: bool,
    #[serde(rename = "disabledByBatterySaver")]
    pub disabled_by_battery_saver: bool,
    #[serde(rename = "disabledByHoldbackPrefetchSpeculationRules")]
    pub disabled_by_holdback_prefetch_speculation_rules: bool,
    #[serde(rename = "disabledByHoldbackPrerenderSpeculationRules")]
    pub disabled_by_holdback_prerender_speculation_rules: bool,
}

impl crate::typed::Event for PreloadEnabledStateUpdatedEvent {
    const METHOD: &'static str = "Preload.preloadEnabledStateUpdated";
}

/// Fired when a prefetch attempt is updated.
///
/// Payload of the `Preload.prefetchStatusUpdated` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PrefetchStatusUpdatedEvent {
    pub key: PreloadingAttemptKey,
    #[serde(rename = "pipelineId")]
    pub pipeline_id: PreloadPipelineId,
    /// The frame id of the frame initiating prefetch.
    #[serde(rename = "initiatingFrameId")]
    pub initiating_frame_id: crate::protocol::page::FrameId,
    #[serde(rename = "prefetchUrl")]
    pub prefetch_url: String,
    pub status: PreloadingStatus,
    #[serde(rename = "prefetchStatus")]
    pub prefetch_status: PrefetchStatus,
    #[serde(rename = "requestId")]
    pub request_id: crate::protocol::network::RequestId,
}

impl crate::typed::Event for PrefetchStatusUpdatedEvent {
    const METHOD: &'static str = "Preload.prefetchStatusUpdated";
}

/// Fired when a prerender attempt is updated.
///
/// Payload of the `Preload.prerenderStatusUpdated` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PrerenderStatusUpdatedEvent {
    pub key: PreloadingAttemptKey,
    #[serde(rename = "pipelineId")]
    pub pipeline_id: PreloadPipelineId,
    pub status: PreloadingStatus,
    /// The action currently performed by this attempt. This differs from
    /// `key.action` after a prerender-until-script attempt is upgraded in place
    /// to a full prerender.
    #[serde(
        rename = "effectiveAction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub effective_action: Option<SpeculationAction>,
    #[serde(
        rename = "prerenderStatus",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub prerender_status: Option<PrerenderFinalStatus>,
    /// This is used to give users more information about the name of Mojo
    /// interface that is incompatible with prerender and has caused the
    /// cancellation of the attempt.
    #[serde(
        rename = "disallowedMojoInterface",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub disallowed_mojo_interface: Option<String>,
    #[serde(
        rename = "mismatchedHeaders",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub mismatched_headers: Option<Vec<PrerenderMismatchedHeaders>>,
}

impl crate::typed::Event for PrerenderStatusUpdatedEvent {
    const METHOD: &'static str = "Preload.prerenderStatusUpdated";
}

/// Send a list of sources for all preloading attempts in a document.
///
/// Payload of the `Preload.preloadingAttemptSourcesUpdated` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PreloadingAttemptSourcesUpdatedEvent {
    #[serde(rename = "loaderId")]
    pub loader_id: crate::protocol::network::LoaderId,
    #[serde(rename = "preloadingAttemptSources")]
    pub preloading_attempt_sources: Vec<PreloadingAttemptSource>,
}

impl crate::typed::Event for PreloadingAttemptSourcesUpdatedEvent {
    const METHOD: &'static str = "Preload.preloadingAttemptSourcesUpdated";
}