Skip to main content

cdp_driver/protocol/
performance.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `Performance` domain.
5//!
6//! Types, command parameters and event payloads for the `Performance`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12/// Run-time execution metric.
13#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
14pub struct Metric {
15    /// Metric name.
16    pub name: String,
17    /// Metric value.
18    pub value: f64,
19}
20
21/// Disable collecting and reporting metrics.
22///
23/// Parameters of `Performance.disable`.
24#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
25pub struct DisableParams {}
26
27impl crate::typed::Command for DisableParams {
28    const METHOD: &'static str = "Performance.disable";
29    type Returns = crate::typed::NoReturns;
30}
31
32/// Enable collecting and reporting metrics.
33///
34/// Parameters of `Performance.enable`.
35#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
36pub struct EnableParams {
37    /// Time domain to use for collecting and reporting duration metrics.
38    #[serde(
39        rename = "timeDomain",
40        default,
41        skip_serializing_if = "Option::is_none"
42    )]
43    pub time_domain: Option<EnableTimeDomain>,
44}
45
46/// The values `timeDomain` accepts on `enable`.
47#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
48pub enum EnableTimeDomain {
49    /// `timeTicks`
50    #[serde(rename = "timeTicks")]
51    TimeTicks,
52    /// `threadTicks`
53    #[serde(rename = "threadTicks")]
54    ThreadTicks,
55    /// A value this vendored schema does not list. Chrome adds values ahead of
56    /// the published protocol, so an unrecognised one is kept as it arrived
57    /// rather than failing the payload it came in.
58    #[serde(untagged)]
59    Unrecognized(String),
60}
61
62impl crate::typed::Command for EnableParams {
63    const METHOD: &'static str = "Performance.enable";
64    type Returns = crate::typed::NoReturns;
65}
66
67/// Sets time domain to use for collecting and reporting duration metrics.
68/// Note that this must be called before enabling metrics collection. Calling
69/// this method while metrics collection is enabled returns an error.
70///
71/// Deprecated in the protocol.
72///
73/// Experimental: may change without notice.
74///
75/// Parameters of `Performance.setTimeDomain`.
76#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
77pub struct SetTimeDomainParams {
78    /// Time domain
79    #[serde(rename = "timeDomain")]
80    pub time_domain: SetTimeDomainTimeDomain,
81}
82
83/// The values `timeDomain` accepts on `setTimeDomain`.
84#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
85pub enum SetTimeDomainTimeDomain {
86    /// `timeTicks`
87    #[serde(rename = "timeTicks")]
88    TimeTicks,
89    /// `threadTicks`
90    #[serde(rename = "threadTicks")]
91    ThreadTicks,
92    /// A value this vendored schema does not list. Chrome adds values ahead of
93    /// the published protocol, so an unrecognised one is kept as it arrived
94    /// rather than failing the payload it came in.
95    #[serde(untagged)]
96    Unrecognized(String),
97}
98
99impl crate::typed::Command for SetTimeDomainParams {
100    const METHOD: &'static str = "Performance.setTimeDomain";
101    type Returns = crate::typed::NoReturns;
102}
103
104/// Retrieve current values of run-time metrics.
105///
106/// Parameters of `Performance.getMetrics`.
107#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
108pub struct GetMetricsParams {}
109
110/// What `Performance.getMetrics` answers with.
111#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
112pub struct GetMetricsReturns {
113    /// Current values for run-time metrics.
114    pub metrics: Vec<Metric>,
115}
116
117impl crate::typed::Command for GetMetricsParams {
118    const METHOD: &'static str = "Performance.getMetrics";
119    type Returns = GetMetricsReturns;
120}
121
122/// Current values of the metrics.
123///
124/// Payload of the `Performance.metrics` event.
125#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
126pub struct MetricsEvent {
127    /// Current values of the metrics.
128    pub metrics: Vec<Metric>,
129    /// Timestamp title.
130    pub title: String,
131}
132
133impl crate::typed::Event for MetricsEvent {
134    const METHOD: &'static str = "Performance.metrics";
135}