browser-protocol 0.1.3

Generated Rust types and commands for the Chrome DevTools Protocol (browser-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
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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;

/// Unique Layer identifier.

pub type LayerId<'a> = Cow<'a, str>;

/// Unique snapshot identifier.

pub type SnapshotId<'a> = Cow<'a, str>;

/// Rectangle where scrolling happens on the main thread.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ScrollRect<'a> {
    /// Rectangle itself.
    rect: crate::dom::Rect,
    /// Reason for rectangle to force scrolling on the main thread
    #[serde(rename = "type")]
    type_: Cow<'a, str>,
}

impl<'a> ScrollRect<'a> {
    pub fn builder(rect: crate::dom::Rect, type_: impl Into<Cow<'a, str>>) -> ScrollRectBuilder<'a> {
        ScrollRectBuilder {
            rect: rect,
            type_: type_.into(),
        }
    }
    pub fn rect(&self) -> &crate::dom::Rect { &self.rect }
    pub fn type_(&self) -> &str { self.type_.as_ref() }
}


pub struct ScrollRectBuilder<'a> {
    rect: crate::dom::Rect,
    type_: Cow<'a, str>,
}

impl<'a> ScrollRectBuilder<'a> {
    pub fn build(self) -> ScrollRect<'a> {
        ScrollRect {
            rect: self.rect,
            type_: self.type_,
        }
    }
}

/// Sticky position constraints.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct StickyPositionConstraint<'a> {
    /// Layout rectangle of the sticky element before being shifted
    stickyBoxRect: crate::dom::Rect,
    /// Layout rectangle of the containing block of the sticky element
    containingBlockRect: crate::dom::Rect,
    /// The nearest sticky layer that shifts the sticky box
    #[serde(skip_serializing_if = "Option::is_none")]
    nearestLayerShiftingStickyBox: Option<LayerId<'a>>,
    /// The nearest sticky layer that shifts the containing block
    #[serde(skip_serializing_if = "Option::is_none")]
    nearestLayerShiftingContainingBlock: Option<LayerId<'a>>,
}

impl<'a> StickyPositionConstraint<'a> {
    pub fn builder(stickyBoxRect: crate::dom::Rect, containingBlockRect: crate::dom::Rect) -> StickyPositionConstraintBuilder<'a> {
        StickyPositionConstraintBuilder {
            stickyBoxRect: stickyBoxRect,
            containingBlockRect: containingBlockRect,
            nearestLayerShiftingStickyBox: None,
            nearestLayerShiftingContainingBlock: None,
        }
    }
    pub fn stickyBoxRect(&self) -> &crate::dom::Rect { &self.stickyBoxRect }
    pub fn containingBlockRect(&self) -> &crate::dom::Rect { &self.containingBlockRect }
    pub fn nearestLayerShiftingStickyBox(&self) -> Option<&LayerId<'a>> { self.nearestLayerShiftingStickyBox.as_ref() }
    pub fn nearestLayerShiftingContainingBlock(&self) -> Option<&LayerId<'a>> { self.nearestLayerShiftingContainingBlock.as_ref() }
}


pub struct StickyPositionConstraintBuilder<'a> {
    stickyBoxRect: crate::dom::Rect,
    containingBlockRect: crate::dom::Rect,
    nearestLayerShiftingStickyBox: Option<LayerId<'a>>,
    nearestLayerShiftingContainingBlock: Option<LayerId<'a>>,
}

impl<'a> StickyPositionConstraintBuilder<'a> {
    /// The nearest sticky layer that shifts the sticky box
    pub fn nearestLayerShiftingStickyBox(mut self, nearestLayerShiftingStickyBox: LayerId<'a>) -> Self { self.nearestLayerShiftingStickyBox = Some(nearestLayerShiftingStickyBox); self }
    /// The nearest sticky layer that shifts the containing block
    pub fn nearestLayerShiftingContainingBlock(mut self, nearestLayerShiftingContainingBlock: LayerId<'a>) -> Self { self.nearestLayerShiftingContainingBlock = Some(nearestLayerShiftingContainingBlock); self }
    pub fn build(self) -> StickyPositionConstraint<'a> {
        StickyPositionConstraint {
            stickyBoxRect: self.stickyBoxRect,
            containingBlockRect: self.containingBlockRect,
            nearestLayerShiftingStickyBox: self.nearestLayerShiftingStickyBox,
            nearestLayerShiftingContainingBlock: self.nearestLayerShiftingContainingBlock,
        }
    }
}

/// Serialized fragment of layer picture along with its offset within the layer.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct PictureTile<'a> {
    /// Offset from owning layer left boundary
    x: f64,
    /// Offset from owning layer top boundary
    y: f64,
    /// Base64-encoded snapshot data. (Encoded as a base64 string when passed over JSON)
    picture: Cow<'a, str>,
}

impl<'a> PictureTile<'a> {
    pub fn builder(x: f64, y: f64, picture: impl Into<Cow<'a, str>>) -> PictureTileBuilder<'a> {
        PictureTileBuilder {
            x: x,
            y: y,
            picture: picture.into(),
        }
    }
    pub fn x(&self) -> f64 { self.x }
    pub fn y(&self) -> f64 { self.y }
    pub fn picture(&self) -> &str { self.picture.as_ref() }
}


pub struct PictureTileBuilder<'a> {
    x: f64,
    y: f64,
    picture: Cow<'a, str>,
}

impl<'a> PictureTileBuilder<'a> {
    pub fn build(self) -> PictureTile<'a> {
        PictureTile {
            x: self.x,
            y: self.y,
            picture: self.picture,
        }
    }
}

/// Information about a compositing layer.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Layer<'a> {
    /// The unique id for this layer.
    layerId: LayerId<'a>,
    /// The id of parent (not present for root).
    #[serde(skip_serializing_if = "Option::is_none")]
    parentLayerId: Option<LayerId<'a>>,
    /// The backend id for the node associated with this layer.
    #[serde(skip_serializing_if = "Option::is_none")]
    backendNodeId: Option<crate::dom::BackendNodeId>,
    /// Offset from parent layer, X coordinate.
    offsetX: f64,
    /// Offset from parent layer, Y coordinate.
    offsetY: f64,
    /// Layer width.
    width: f64,
    /// Layer height.
    height: f64,
    /// Transformation matrix for layer, default is identity matrix
    #[serde(skip_serializing_if = "Option::is_none")]
    transform: Option<Vec<f64>>,
    /// Transform anchor point X, absent if no transform specified
    #[serde(skip_serializing_if = "Option::is_none")]
    anchorX: Option<f64>,
    /// Transform anchor point Y, absent if no transform specified
    #[serde(skip_serializing_if = "Option::is_none")]
    anchorY: Option<f64>,
    /// Transform anchor point Z, absent if no transform specified
    #[serde(skip_serializing_if = "Option::is_none")]
    anchorZ: Option<f64>,
    /// Indicates how many time this layer has painted.
    paintCount: u64,
    /// Indicates whether this layer hosts any content, rather than being used for
    /// transform/scrolling purposes only.
    drawsContent: bool,
    /// Set if layer is not visible.
    #[serde(skip_serializing_if = "Option::is_none")]
    invisible: Option<bool>,
    /// Rectangles scrolling on main thread only.
    #[serde(skip_serializing_if = "Option::is_none")]
    scrollRects: Option<Vec<ScrollRect<'a>>>,
    /// Sticky position constraint information
    #[serde(skip_serializing_if = "Option::is_none")]
    stickyPositionConstraint: Option<StickyPositionConstraint<'a>>,
}

impl<'a> Layer<'a> {
    pub fn builder(layerId: LayerId<'a>, offsetX: f64, offsetY: f64, width: f64, height: f64, paintCount: u64, drawsContent: bool) -> LayerBuilder<'a> {
        LayerBuilder {
            layerId: layerId,
            parentLayerId: None,
            backendNodeId: None,
            offsetX: offsetX,
            offsetY: offsetY,
            width: width,
            height: height,
            transform: None,
            anchorX: None,
            anchorY: None,
            anchorZ: None,
            paintCount: paintCount,
            drawsContent: drawsContent,
            invisible: None,
            scrollRects: None,
            stickyPositionConstraint: None,
        }
    }
    pub fn layerId(&self) -> &LayerId<'a> { &self.layerId }
    pub fn parentLayerId(&self) -> Option<&LayerId<'a>> { self.parentLayerId.as_ref() }
    pub fn backendNodeId(&self) -> Option<&crate::dom::BackendNodeId> { self.backendNodeId.as_ref() }
    pub fn offsetX(&self) -> f64 { self.offsetX }
    pub fn offsetY(&self) -> f64 { self.offsetY }
    pub fn width(&self) -> f64 { self.width }
    pub fn height(&self) -> f64 { self.height }
    pub fn transform(&self) -> Option<&[f64]> { self.transform.as_deref() }
    pub fn anchorX(&self) -> Option<f64> { self.anchorX }
    pub fn anchorY(&self) -> Option<f64> { self.anchorY }
    pub fn anchorZ(&self) -> Option<f64> { self.anchorZ }
    pub fn paintCount(&self) -> u64 { self.paintCount }
    pub fn drawsContent(&self) -> bool { self.drawsContent }
    pub fn invisible(&self) -> Option<bool> { self.invisible }
    pub fn scrollRects(&self) -> Option<&[ScrollRect<'a>]> { self.scrollRects.as_deref() }
    pub fn stickyPositionConstraint(&self) -> Option<&StickyPositionConstraint<'a>> { self.stickyPositionConstraint.as_ref() }
}


pub struct LayerBuilder<'a> {
    layerId: LayerId<'a>,
    parentLayerId: Option<LayerId<'a>>,
    backendNodeId: Option<crate::dom::BackendNodeId>,
    offsetX: f64,
    offsetY: f64,
    width: f64,
    height: f64,
    transform: Option<Vec<f64>>,
    anchorX: Option<f64>,
    anchorY: Option<f64>,
    anchorZ: Option<f64>,
    paintCount: u64,
    drawsContent: bool,
    invisible: Option<bool>,
    scrollRects: Option<Vec<ScrollRect<'a>>>,
    stickyPositionConstraint: Option<StickyPositionConstraint<'a>>,
}

impl<'a> LayerBuilder<'a> {
    /// The id of parent (not present for root).
    pub fn parentLayerId(mut self, parentLayerId: LayerId<'a>) -> Self { self.parentLayerId = Some(parentLayerId); self }
    /// The backend id for the node associated with this layer.
    pub fn backendNodeId(mut self, backendNodeId: crate::dom::BackendNodeId) -> Self { self.backendNodeId = Some(backendNodeId); self }
    /// Transformation matrix for layer, default is identity matrix
    pub fn transform(mut self, transform: Vec<f64>) -> Self { self.transform = Some(transform); self }
    /// Transform anchor point X, absent if no transform specified
    pub fn anchorX(mut self, anchorX: f64) -> Self { self.anchorX = Some(anchorX); self }
    /// Transform anchor point Y, absent if no transform specified
    pub fn anchorY(mut self, anchorY: f64) -> Self { self.anchorY = Some(anchorY); self }
    /// Transform anchor point Z, absent if no transform specified
    pub fn anchorZ(mut self, anchorZ: f64) -> Self { self.anchorZ = Some(anchorZ); self }
    /// Set if layer is not visible.
    pub fn invisible(mut self, invisible: bool) -> Self { self.invisible = Some(invisible); self }
    /// Rectangles scrolling on main thread only.
    pub fn scrollRects(mut self, scrollRects: Vec<ScrollRect<'a>>) -> Self { self.scrollRects = Some(scrollRects); self }
    /// Sticky position constraint information
    pub fn stickyPositionConstraint(mut self, stickyPositionConstraint: StickyPositionConstraint<'a>) -> Self { self.stickyPositionConstraint = Some(stickyPositionConstraint); self }
    pub fn build(self) -> Layer<'a> {
        Layer {
            layerId: self.layerId,
            parentLayerId: self.parentLayerId,
            backendNodeId: self.backendNodeId,
            offsetX: self.offsetX,
            offsetY: self.offsetY,
            width: self.width,
            height: self.height,
            transform: self.transform,
            anchorX: self.anchorX,
            anchorY: self.anchorY,
            anchorZ: self.anchorZ,
            paintCount: self.paintCount,
            drawsContent: self.drawsContent,
            invisible: self.invisible,
            scrollRects: self.scrollRects,
            stickyPositionConstraint: self.stickyPositionConstraint,
        }
    }
}

/// Array of timings, one per paint step.

pub type PaintProfile = Vec<f64>;

/// Provides the reasons why the given layer was composited.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CompositingReasonsParams<'a> {
    /// The id of the layer for which we want to get the reasons it was composited.
    layerId: LayerId<'a>,
}

impl<'a> CompositingReasonsParams<'a> {
    pub fn builder(layerId: LayerId<'a>) -> CompositingReasonsParamsBuilder<'a> {
        CompositingReasonsParamsBuilder {
            layerId: layerId,
        }
    }
    pub fn layerId(&self) -> &LayerId<'a> { &self.layerId }
}


pub struct CompositingReasonsParamsBuilder<'a> {
    layerId: LayerId<'a>,
}

impl<'a> CompositingReasonsParamsBuilder<'a> {
    pub fn build(self) -> CompositingReasonsParams<'a> {
        CompositingReasonsParams {
            layerId: self.layerId,
        }
    }
}

/// Provides the reasons why the given layer was composited.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CompositingReasonsReturns<'a> {
    /// A list of strings specifying reasons for the given layer to become composited.
    compositingReasons: Vec<Cow<'a, str>>,
    /// A list of strings specifying reason IDs for the given layer to become composited.
    compositingReasonIds: Vec<Cow<'a, str>>,
}

impl<'a> CompositingReasonsReturns<'a> {
    pub fn builder(compositingReasons: Vec<Cow<'a, str>>, compositingReasonIds: Vec<Cow<'a, str>>) -> CompositingReasonsReturnsBuilder<'a> {
        CompositingReasonsReturnsBuilder {
            compositingReasons: compositingReasons,
            compositingReasonIds: compositingReasonIds,
        }
    }
    pub fn compositingReasons(&self) -> &[Cow<'a, str>] { &self.compositingReasons }
    pub fn compositingReasonIds(&self) -> &[Cow<'a, str>] { &self.compositingReasonIds }
}


pub struct CompositingReasonsReturnsBuilder<'a> {
    compositingReasons: Vec<Cow<'a, str>>,
    compositingReasonIds: Vec<Cow<'a, str>>,
}

impl<'a> CompositingReasonsReturnsBuilder<'a> {
    pub fn build(self) -> CompositingReasonsReturns<'a> {
        CompositingReasonsReturns {
            compositingReasons: self.compositingReasons,
            compositingReasonIds: self.compositingReasonIds,
        }
    }
}

impl<'a> CompositingReasonsParams<'a> { pub const METHOD: &'static str = "LayerTree.compositingReasons"; }

impl<'a> crate::CdpCommand<'a> for CompositingReasonsParams<'a> {
    const METHOD: &'static str = "LayerTree.compositingReasons";
    type Response = CompositingReasonsReturns<'a>;
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}

impl DisableParams { pub const METHOD: &'static str = "LayerTree.disable"; }

impl<'a> crate::CdpCommand<'a> for DisableParams {
    const METHOD: &'static str = "LayerTree.disable";
    type Response = crate::EmptyReturns;
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnableParams {}

impl EnableParams { pub const METHOD: &'static str = "LayerTree.enable"; }

impl<'a> crate::CdpCommand<'a> for EnableParams {
    const METHOD: &'static str = "LayerTree.enable";
    type Response = crate::EmptyReturns;
}

/// Returns the snapshot identifier.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LoadSnapshotParams<'a> {
    /// An array of tiles composing the snapshot.
    tiles: Vec<PictureTile<'a>>,
}

impl<'a> LoadSnapshotParams<'a> {
    pub fn builder(tiles: Vec<PictureTile<'a>>) -> LoadSnapshotParamsBuilder<'a> {
        LoadSnapshotParamsBuilder {
            tiles: tiles,
        }
    }
    pub fn tiles(&self) -> &[PictureTile<'a>] { &self.tiles }
}


pub struct LoadSnapshotParamsBuilder<'a> {
    tiles: Vec<PictureTile<'a>>,
}

impl<'a> LoadSnapshotParamsBuilder<'a> {
    pub fn build(self) -> LoadSnapshotParams<'a> {
        LoadSnapshotParams {
            tiles: self.tiles,
        }
    }
}

/// Returns the snapshot identifier.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LoadSnapshotReturns<'a> {
    /// The id of the snapshot.
    snapshotId: SnapshotId<'a>,
}

impl<'a> LoadSnapshotReturns<'a> {
    pub fn builder(snapshotId: SnapshotId<'a>) -> LoadSnapshotReturnsBuilder<'a> {
        LoadSnapshotReturnsBuilder {
            snapshotId: snapshotId,
        }
    }
    pub fn snapshotId(&self) -> &SnapshotId<'a> { &self.snapshotId }
}


pub struct LoadSnapshotReturnsBuilder<'a> {
    snapshotId: SnapshotId<'a>,
}

impl<'a> LoadSnapshotReturnsBuilder<'a> {
    pub fn build(self) -> LoadSnapshotReturns<'a> {
        LoadSnapshotReturns {
            snapshotId: self.snapshotId,
        }
    }
}

impl<'a> LoadSnapshotParams<'a> { pub const METHOD: &'static str = "LayerTree.loadSnapshot"; }

impl<'a> crate::CdpCommand<'a> for LoadSnapshotParams<'a> {
    const METHOD: &'static str = "LayerTree.loadSnapshot";
    type Response = LoadSnapshotReturns<'a>;
}

/// Returns the layer snapshot identifier.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct MakeSnapshotParams<'a> {
    /// The id of the layer.
    layerId: LayerId<'a>,
}

impl<'a> MakeSnapshotParams<'a> {
    pub fn builder(layerId: LayerId<'a>) -> MakeSnapshotParamsBuilder<'a> {
        MakeSnapshotParamsBuilder {
            layerId: layerId,
        }
    }
    pub fn layerId(&self) -> &LayerId<'a> { &self.layerId }
}


pub struct MakeSnapshotParamsBuilder<'a> {
    layerId: LayerId<'a>,
}

impl<'a> MakeSnapshotParamsBuilder<'a> {
    pub fn build(self) -> MakeSnapshotParams<'a> {
        MakeSnapshotParams {
            layerId: self.layerId,
        }
    }
}

/// Returns the layer snapshot identifier.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct MakeSnapshotReturns<'a> {
    /// The id of the layer snapshot.
    snapshotId: SnapshotId<'a>,
}

impl<'a> MakeSnapshotReturns<'a> {
    pub fn builder(snapshotId: SnapshotId<'a>) -> MakeSnapshotReturnsBuilder<'a> {
        MakeSnapshotReturnsBuilder {
            snapshotId: snapshotId,
        }
    }
    pub fn snapshotId(&self) -> &SnapshotId<'a> { &self.snapshotId }
}


pub struct MakeSnapshotReturnsBuilder<'a> {
    snapshotId: SnapshotId<'a>,
}

impl<'a> MakeSnapshotReturnsBuilder<'a> {
    pub fn build(self) -> MakeSnapshotReturns<'a> {
        MakeSnapshotReturns {
            snapshotId: self.snapshotId,
        }
    }
}

impl<'a> MakeSnapshotParams<'a> { pub const METHOD: &'static str = "LayerTree.makeSnapshot"; }

impl<'a> crate::CdpCommand<'a> for MakeSnapshotParams<'a> {
    const METHOD: &'static str = "LayerTree.makeSnapshot";
    type Response = MakeSnapshotReturns<'a>;
}


#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ProfileSnapshotParams<'a> {
    /// The id of the layer snapshot.
    snapshotId: SnapshotId<'a>,
    /// The maximum number of times to replay the snapshot (1, if not specified).
    #[serde(skip_serializing_if = "Option::is_none")]
    minRepeatCount: Option<u64>,
    /// The minimum duration (in seconds) to replay the snapshot.
    #[serde(skip_serializing_if = "Option::is_none")]
    minDuration: Option<f64>,
    /// The clip rectangle to apply when replaying the snapshot.
    #[serde(skip_serializing_if = "Option::is_none")]
    clipRect: Option<crate::dom::Rect>,
}

impl<'a> ProfileSnapshotParams<'a> {
    pub fn builder(snapshotId: SnapshotId<'a>) -> ProfileSnapshotParamsBuilder<'a> {
        ProfileSnapshotParamsBuilder {
            snapshotId: snapshotId,
            minRepeatCount: None,
            minDuration: None,
            clipRect: None,
        }
    }
    pub fn snapshotId(&self) -> &SnapshotId<'a> { &self.snapshotId }
    pub fn minRepeatCount(&self) -> Option<u64> { self.minRepeatCount }
    pub fn minDuration(&self) -> Option<f64> { self.minDuration }
    pub fn clipRect(&self) -> Option<&crate::dom::Rect> { self.clipRect.as_ref() }
}


pub struct ProfileSnapshotParamsBuilder<'a> {
    snapshotId: SnapshotId<'a>,
    minRepeatCount: Option<u64>,
    minDuration: Option<f64>,
    clipRect: Option<crate::dom::Rect>,
}

impl<'a> ProfileSnapshotParamsBuilder<'a> {
    /// The maximum number of times to replay the snapshot (1, if not specified).
    pub fn minRepeatCount(mut self, minRepeatCount: u64) -> Self { self.minRepeatCount = Some(minRepeatCount); self }
    /// The minimum duration (in seconds) to replay the snapshot.
    pub fn minDuration(mut self, minDuration: f64) -> Self { self.minDuration = Some(minDuration); self }
    /// The clip rectangle to apply when replaying the snapshot.
    pub fn clipRect(mut self, clipRect: crate::dom::Rect) -> Self { self.clipRect = Some(clipRect); self }
    pub fn build(self) -> ProfileSnapshotParams<'a> {
        ProfileSnapshotParams {
            snapshotId: self.snapshotId,
            minRepeatCount: self.minRepeatCount,
            minDuration: self.minDuration,
            clipRect: self.clipRect,
        }
    }
}


#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ProfileSnapshotReturns {
    /// The array of paint profiles, one per run.
    timings: Vec<PaintProfile>,
}

impl ProfileSnapshotReturns {
    pub fn builder(timings: Vec<PaintProfile>) -> ProfileSnapshotReturnsBuilder {
        ProfileSnapshotReturnsBuilder {
            timings: timings,
        }
    }
    pub fn timings(&self) -> &[PaintProfile] { &self.timings }
}


pub struct ProfileSnapshotReturnsBuilder {
    timings: Vec<PaintProfile>,
}

impl ProfileSnapshotReturnsBuilder {
    pub fn build(self) -> ProfileSnapshotReturns {
        ProfileSnapshotReturns {
            timings: self.timings,
        }
    }
}

impl<'a> ProfileSnapshotParams<'a> { pub const METHOD: &'static str = "LayerTree.profileSnapshot"; }

impl<'a> crate::CdpCommand<'a> for ProfileSnapshotParams<'a> {
    const METHOD: &'static str = "LayerTree.profileSnapshot";
    type Response = ProfileSnapshotReturns;
}

/// Releases layer snapshot captured by the back-end.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReleaseSnapshotParams<'a> {
    /// The id of the layer snapshot.
    snapshotId: SnapshotId<'a>,
}

impl<'a> ReleaseSnapshotParams<'a> {
    pub fn builder(snapshotId: SnapshotId<'a>) -> ReleaseSnapshotParamsBuilder<'a> {
        ReleaseSnapshotParamsBuilder {
            snapshotId: snapshotId,
        }
    }
    pub fn snapshotId(&self) -> &SnapshotId<'a> { &self.snapshotId }
}


pub struct ReleaseSnapshotParamsBuilder<'a> {
    snapshotId: SnapshotId<'a>,
}

impl<'a> ReleaseSnapshotParamsBuilder<'a> {
    pub fn build(self) -> ReleaseSnapshotParams<'a> {
        ReleaseSnapshotParams {
            snapshotId: self.snapshotId,
        }
    }
}

impl<'a> ReleaseSnapshotParams<'a> { pub const METHOD: &'static str = "LayerTree.releaseSnapshot"; }

impl<'a> crate::CdpCommand<'a> for ReleaseSnapshotParams<'a> {
    const METHOD: &'static str = "LayerTree.releaseSnapshot";
    type Response = crate::EmptyReturns;
}

/// Replays the layer snapshot and returns the resulting bitmap.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReplaySnapshotParams<'a> {
    /// The id of the layer snapshot.
    snapshotId: SnapshotId<'a>,
    /// The first step to replay from (replay from the very start if not specified).
    #[serde(skip_serializing_if = "Option::is_none")]
    fromStep: Option<i64>,
    /// The last step to replay to (replay till the end if not specified).
    #[serde(skip_serializing_if = "Option::is_none")]
    toStep: Option<i64>,
    /// The scale to apply while replaying (defaults to 1).
    #[serde(skip_serializing_if = "Option::is_none")]
    scale: Option<f64>,
}

impl<'a> ReplaySnapshotParams<'a> {
    pub fn builder(snapshotId: SnapshotId<'a>) -> ReplaySnapshotParamsBuilder<'a> {
        ReplaySnapshotParamsBuilder {
            snapshotId: snapshotId,
            fromStep: None,
            toStep: None,
            scale: None,
        }
    }
    pub fn snapshotId(&self) -> &SnapshotId<'a> { &self.snapshotId }
    pub fn fromStep(&self) -> Option<i64> { self.fromStep }
    pub fn toStep(&self) -> Option<i64> { self.toStep }
    pub fn scale(&self) -> Option<f64> { self.scale }
}


pub struct ReplaySnapshotParamsBuilder<'a> {
    snapshotId: SnapshotId<'a>,
    fromStep: Option<i64>,
    toStep: Option<i64>,
    scale: Option<f64>,
}

impl<'a> ReplaySnapshotParamsBuilder<'a> {
    /// The first step to replay from (replay from the very start if not specified).
    pub fn fromStep(mut self, fromStep: i64) -> Self { self.fromStep = Some(fromStep); self }
    /// The last step to replay to (replay till the end if not specified).
    pub fn toStep(mut self, toStep: i64) -> Self { self.toStep = Some(toStep); self }
    /// The scale to apply while replaying (defaults to 1).
    pub fn scale(mut self, scale: f64) -> Self { self.scale = Some(scale); self }
    pub fn build(self) -> ReplaySnapshotParams<'a> {
        ReplaySnapshotParams {
            snapshotId: self.snapshotId,
            fromStep: self.fromStep,
            toStep: self.toStep,
            scale: self.scale,
        }
    }
}

/// Replays the layer snapshot and returns the resulting bitmap.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReplaySnapshotReturns<'a> {
    /// A data: URL for resulting image.
    dataURL: Cow<'a, str>,
}

impl<'a> ReplaySnapshotReturns<'a> {
    pub fn builder(dataURL: impl Into<Cow<'a, str>>) -> ReplaySnapshotReturnsBuilder<'a> {
        ReplaySnapshotReturnsBuilder {
            dataURL: dataURL.into(),
        }
    }
    pub fn dataURL(&self) -> &str { self.dataURL.as_ref() }
}


pub struct ReplaySnapshotReturnsBuilder<'a> {
    dataURL: Cow<'a, str>,
}

impl<'a> ReplaySnapshotReturnsBuilder<'a> {
    pub fn build(self) -> ReplaySnapshotReturns<'a> {
        ReplaySnapshotReturns {
            dataURL: self.dataURL,
        }
    }
}

impl<'a> ReplaySnapshotParams<'a> { pub const METHOD: &'static str = "LayerTree.replaySnapshot"; }

impl<'a> crate::CdpCommand<'a> for ReplaySnapshotParams<'a> {
    const METHOD: &'static str = "LayerTree.replaySnapshot";
    type Response = ReplaySnapshotReturns<'a>;
}

/// Replays the layer snapshot and returns canvas log.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SnapshotCommandLogParams<'a> {
    /// The id of the layer snapshot.
    snapshotId: SnapshotId<'a>,
}

impl<'a> SnapshotCommandLogParams<'a> {
    pub fn builder(snapshotId: SnapshotId<'a>) -> SnapshotCommandLogParamsBuilder<'a> {
        SnapshotCommandLogParamsBuilder {
            snapshotId: snapshotId,
        }
    }
    pub fn snapshotId(&self) -> &SnapshotId<'a> { &self.snapshotId }
}


pub struct SnapshotCommandLogParamsBuilder<'a> {
    snapshotId: SnapshotId<'a>,
}

impl<'a> SnapshotCommandLogParamsBuilder<'a> {
    pub fn build(self) -> SnapshotCommandLogParams<'a> {
        SnapshotCommandLogParams {
            snapshotId: self.snapshotId,
        }
    }
}

/// Replays the layer snapshot and returns canvas log.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SnapshotCommandLogReturns {
    /// The array of canvas function calls.
    commandLog: Vec<serde_json::Map<String, JsonValue>>,
}

impl SnapshotCommandLogReturns {
    pub fn builder(commandLog: Vec<serde_json::Map<String, JsonValue>>) -> SnapshotCommandLogReturnsBuilder {
        SnapshotCommandLogReturnsBuilder {
            commandLog: commandLog,
        }
    }
    pub fn commandLog(&self) -> &[serde_json::Map<String, JsonValue>] { &self.commandLog }
}


pub struct SnapshotCommandLogReturnsBuilder {
    commandLog: Vec<serde_json::Map<String, JsonValue>>,
}

impl SnapshotCommandLogReturnsBuilder {
    pub fn build(self) -> SnapshotCommandLogReturns {
        SnapshotCommandLogReturns {
            commandLog: self.commandLog,
        }
    }
}

impl<'a> SnapshotCommandLogParams<'a> { pub const METHOD: &'static str = "LayerTree.snapshotCommandLog"; }

impl<'a> crate::CdpCommand<'a> for SnapshotCommandLogParams<'a> {
    const METHOD: &'static str = "LayerTree.snapshotCommandLog";
    type Response = SnapshotCommandLogReturns;
}