cdp_driver/protocol/headless_experimental.rs
1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! This domain provides experimental commands only supported in headless
5//! mode.
6//!
7//! Types, command parameters and event payloads for the `HeadlessExperimental`
8//! domain. The method-name constants for the same domain are in
9//! [`crate::methods`].
10//!
11//! This domain is experimental and may change without notice.
12
13use serde::{Deserialize, Serialize};
14
15/// Encoding options for a screenshot.
16#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
17pub struct ScreenshotParams {
18 /// Image compression format (defaults to png).
19 #[serde(default, skip_serializing_if = "Option::is_none")]
20 pub format: Option<ScreenshotParamsFormat>,
21 /// Compression quality from range \[0..100\] (jpeg and webp only).
22 #[serde(default, skip_serializing_if = "Option::is_none")]
23 pub quality: Option<i64>,
24 /// Optimize image encoding for speed, not for resulting size (defaults to
25 /// false)
26 #[serde(
27 rename = "optimizeForSpeed",
28 default,
29 skip_serializing_if = "Option::is_none"
30 )]
31 pub optimize_for_speed: Option<bool>,
32}
33
34/// The values `format` accepts on `ScreenshotParams`.
35#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
36pub enum ScreenshotParamsFormat {
37 /// `jpeg`
38 #[serde(rename = "jpeg")]
39 Jpeg,
40 /// `png`
41 #[serde(rename = "png")]
42 Png,
43 /// `webp`
44 #[serde(rename = "webp")]
45 Webp,
46 /// A value this vendored schema does not list. Chrome adds values ahead of
47 /// the published protocol, so an unrecognised one is kept as it arrived
48 /// rather than failing the payload it came in.
49 #[serde(untagged)]
50 Unrecognized(String),
51}
52
53/// Sends a BeginFrame to the target and returns when the frame was completed.
54/// Optionally captures a screenshot from the resulting frame. Requires that
55/// the target was created with enabled BeginFrameControl. Designed for use
56/// with --run-all-compositor-stages-before-draw, see also
57/// <https://goo.gle/chrome-headless-rendering> for more background.
58///
59/// Parameters of `HeadlessExperimental.beginFrame`.
60#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
61pub struct BeginFrameParams {
62 /// Timestamp of this BeginFrame in Renderer TimeTicks (milliseconds of
63 /// uptime). If not set, the current time will be used.
64 #[serde(
65 rename = "frameTimeTicks",
66 default,
67 skip_serializing_if = "Option::is_none"
68 )]
69 pub frame_time_ticks: Option<f64>,
70 /// The interval between BeginFrames that is reported to the compositor, in
71 /// milliseconds. Defaults to a 60 frames/second interval, i.e. about 16.666
72 /// milliseconds.
73 #[serde(default, skip_serializing_if = "Option::is_none")]
74 pub interval: Option<f64>,
75 /// Whether updates should not be committed and drawn onto the display. False
76 /// by default. If true, only side effects of the BeginFrame will be run, such
77 /// as layout and animations, but any visual updates may not be visible on the
78 /// display or in screenshots.
79 #[serde(
80 rename = "noDisplayUpdates",
81 default,
82 skip_serializing_if = "Option::is_none"
83 )]
84 pub no_display_updates: Option<bool>,
85 /// If set, a screenshot of the frame will be captured and returned in the
86 /// response. Otherwise, no screenshot will be captured. Note that capturing a
87 /// screenshot can fail, for example, during renderer initialization. In such
88 /// a case, no screenshot data will be returned.
89 #[serde(default, skip_serializing_if = "Option::is_none")]
90 pub screenshot: Option<ScreenshotParams>,
91}
92
93/// What `HeadlessExperimental.beginFrame` answers with.
94#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
95pub struct BeginFrameReturns {
96 /// Whether the BeginFrame resulted in damage and, thus, a new frame was
97 /// committed to the display. Reported for diagnostic uses, may be removed in
98 /// the future.
99 #[serde(rename = "hasDamage")]
100 pub has_damage: bool,
101 /// Base64-encoded image data of the screenshot, if one was requested and
102 /// successfully taken. (Encoded as a base64 string when passed over JSON)
103 #[serde(
104 rename = "screenshotData",
105 default,
106 skip_serializing_if = "Option::is_none"
107 )]
108 pub screenshot_data: Option<String>,
109}
110
111impl crate::typed::Command for BeginFrameParams {
112 const METHOD: &'static str = "HeadlessExperimental.beginFrame";
113 type Returns = BeginFrameReturns;
114}
115
116/// Disables headless events for the target.
117///
118/// Deprecated in the protocol.
119///
120/// Parameters of `HeadlessExperimental.disable`.
121#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
122pub struct DisableParams {}
123
124impl crate::typed::Command for DisableParams {
125 const METHOD: &'static str = "HeadlessExperimental.disable";
126 type Returns = crate::typed::NoReturns;
127}
128
129/// Enables headless events for the target.
130///
131/// Deprecated in the protocol.
132///
133/// Parameters of `HeadlessExperimental.enable`.
134#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
135pub struct EnableParams {}
136
137impl crate::typed::Command for EnableParams {
138 const METHOD: &'static str = "HeadlessExperimental.enable";
139 type Returns = crate::typed::NoReturns;
140}