Skip to main content

rustenium_cdp_definitions/js_protocol/heap_profiler/
commands.rs

1use serde::{Deserialize, Serialize};
2#[doc = "Enables console to refer to the node with given id via $x (see Command Line API for more details\n$x functions).\n[addInspectedHeapObject](https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler/#method-addInspectedHeapObject)"]
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct AddInspectedHeapObjectParams {
5    #[doc = "Heap snapshot object id to be accessible by means of $x command line API."]
6    #[serde(rename = "heapObjectId")]
7    pub heap_object_id: super::types::HeapSnapshotObjectId,
8}
9impl AddInspectedHeapObjectParams {
10    pub fn new(heap_object_id: impl Into<super::types::HeapSnapshotObjectId>) -> Self {
11        Self {
12            heap_object_id: heap_object_id.into(),
13        }
14    }
15}
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
17pub enum AddInspectedHeapObjectMethod {
18    #[serde(rename = "HeapProfiler.addInspectedHeapObject")]
19    AddInspectedHeapObject,
20}
21#[doc = "Enables console to refer to the node with given id via $x (see Command Line API for more details\n$x functions).\n[addInspectedHeapObject](https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler/#method-addInspectedHeapObject)"]
22#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
23pub struct AddInspectedHeapObject {
24    pub method: AddInspectedHeapObjectMethod,
25    pub params: AddInspectedHeapObjectParams,
26}
27impl AddInspectedHeapObject {
28    pub const IDENTIFIER: &'static str = "HeapProfiler.addInspectedHeapObject";
29    pub fn identifier(&self) -> &'static str {
30        Self::IDENTIFIER
31    }
32}
33impl crate::CommandResult for AddInspectedHeapObject {
34    type Result = super::results::AddInspectedHeapObjectResult;
35}
36#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
37pub struct CollectGarbageParams {}
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
39pub enum CollectGarbageMethod {
40    #[serde(rename = "HeapProfiler.collectGarbage")]
41    CollectGarbage,
42}
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
44pub struct CollectGarbage {
45    pub method: CollectGarbageMethod,
46    pub params: CollectGarbageParams,
47}
48impl CollectGarbage {
49    pub const IDENTIFIER: &'static str = "HeapProfiler.collectGarbage";
50    pub fn identifier(&self) -> &'static str {
51        Self::IDENTIFIER
52    }
53}
54impl crate::CommandResult for CollectGarbage {
55    type Result = super::results::CollectGarbageResult;
56}
57#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
58pub struct DisableParams {}
59#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
60pub enum DisableMethod {
61    #[serde(rename = "HeapProfiler.disable")]
62    Disable,
63}
64#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
65pub struct Disable {
66    pub method: DisableMethod,
67    pub params: DisableParams,
68}
69impl Disable {
70    pub const IDENTIFIER: &'static str = "HeapProfiler.disable";
71    pub fn identifier(&self) -> &'static str {
72        Self::IDENTIFIER
73    }
74}
75impl crate::CommandResult for Disable {
76    type Result = super::results::DisableResult;
77}
78#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
79pub struct EnableParams {}
80#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
81pub enum EnableMethod {
82    #[serde(rename = "HeapProfiler.enable")]
83    Enable,
84}
85#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
86pub struct Enable {
87    pub method: EnableMethod,
88    pub params: EnableParams,
89}
90impl Enable {
91    pub const IDENTIFIER: &'static str = "HeapProfiler.enable";
92    pub fn identifier(&self) -> &'static str {
93        Self::IDENTIFIER
94    }
95}
96impl crate::CommandResult for Enable {
97    type Result = super::results::EnableResult;
98}
99#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
100pub struct GetHeapObjectIdParams {
101    #[doc = "Identifier of the object to get heap object id for."]
102    #[serde(rename = "objectId")]
103    pub object_id: crate::js_protocol::runtime::types::RemoteObjectId,
104}
105impl GetHeapObjectIdParams {
106    pub fn new(object_id: impl Into<crate::js_protocol::runtime::types::RemoteObjectId>) -> Self {
107        Self {
108            object_id: object_id.into(),
109        }
110    }
111}
112#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
113pub enum GetHeapObjectIdMethod {
114    #[serde(rename = "HeapProfiler.getHeapObjectId")]
115    GetHeapObjectId,
116}
117#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
118pub struct GetHeapObjectId {
119    pub method: GetHeapObjectIdMethod,
120    pub params: GetHeapObjectIdParams,
121}
122impl GetHeapObjectId {
123    pub const IDENTIFIER: &'static str = "HeapProfiler.getHeapObjectId";
124    pub fn identifier(&self) -> &'static str {
125        Self::IDENTIFIER
126    }
127}
128impl crate::CommandResult for GetHeapObjectId {
129    type Result = super::results::GetHeapObjectIdResult;
130}
131#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
132pub struct GetObjectByHeapObjectIdParams {
133    #[serde(rename = "objectId")]
134    pub object_id: super::types::HeapSnapshotObjectId,
135    #[doc = "Symbolic group name that can be used to release multiple objects."]
136    #[serde(rename = "objectGroup")]
137    #[serde(skip_serializing_if = "Option::is_none")]
138    #[serde(default)]
139    pub object_group: Option<String>,
140}
141impl GetObjectByHeapObjectIdParams {
142    pub fn new(object_id: impl Into<super::types::HeapSnapshotObjectId>) -> Self {
143        Self {
144            object_id: object_id.into(),
145            object_group: None,
146        }
147    }
148}
149#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
150pub enum GetObjectByHeapObjectIdMethod {
151    #[serde(rename = "HeapProfiler.getObjectByHeapObjectId")]
152    GetObjectByHeapObjectId,
153}
154#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
155pub struct GetObjectByHeapObjectId {
156    pub method: GetObjectByHeapObjectIdMethod,
157    pub params: GetObjectByHeapObjectIdParams,
158}
159impl GetObjectByHeapObjectId {
160    pub const IDENTIFIER: &'static str = "HeapProfiler.getObjectByHeapObjectId";
161    pub fn identifier(&self) -> &'static str {
162        Self::IDENTIFIER
163    }
164}
165impl crate::CommandResult for GetObjectByHeapObjectId {
166    type Result = super::results::GetObjectByHeapObjectIdResult;
167}
168#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
169pub struct GetSamplingProfileParams {}
170#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
171pub enum GetSamplingProfileMethod {
172    #[serde(rename = "HeapProfiler.getSamplingProfile")]
173    GetSamplingProfile,
174}
175#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
176pub struct GetSamplingProfile {
177    pub method: GetSamplingProfileMethod,
178    pub params: GetSamplingProfileParams,
179}
180impl GetSamplingProfile {
181    pub const IDENTIFIER: &'static str = "HeapProfiler.getSamplingProfile";
182    pub fn identifier(&self) -> &'static str {
183        Self::IDENTIFIER
184    }
185}
186impl crate::CommandResult for GetSamplingProfile {
187    type Result = super::results::GetSamplingProfileResult;
188}
189#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
190pub struct StartSamplingParams {
191    #[doc = "Average sample interval in bytes. Poisson distribution is used for the intervals. The\ndefault value is 32768 bytes."]
192    #[serde(rename = "samplingInterval")]
193    #[serde(skip_serializing_if = "Option::is_none")]
194    #[serde(default)]
195    pub sampling_interval: Option<f64>,
196    #[doc = "Maximum stack depth. The default value is 128."]
197    #[serde(rename = "stackDepth")]
198    #[serde(skip_serializing_if = "Option::is_none")]
199    #[serde(default)]
200    pub stack_depth: Option<f64>,
201    #[doc = "By default, the sampling heap profiler reports only objects which are\nstill alive when the profile is returned via getSamplingProfile or\nstopSampling, which is useful for determining what functions contribute\nthe most to steady-state memory usage. This flag instructs the sampling\nheap profiler to also include information about objects discarded by\nmajor GC, which will show which functions cause large temporary memory\nusage or long GC pauses."]
202    #[serde(rename = "includeObjectsCollectedByMajorGC")]
203    #[serde(skip_serializing_if = "Option::is_none")]
204    #[serde(default)]
205    pub include_objects_collected_by_major_gc: Option<bool>,
206    #[doc = "By default, the sampling heap profiler reports only objects which are\nstill alive when the profile is returned via getSamplingProfile or\nstopSampling, which is useful for determining what functions contribute\nthe most to steady-state memory usage. This flag instructs the sampling\nheap profiler to also include information about objects discarded by\nminor GC, which is useful when tuning a latency-sensitive application\nfor minimal GC activity."]
207    #[serde(rename = "includeObjectsCollectedByMinorGC")]
208    #[serde(skip_serializing_if = "Option::is_none")]
209    #[serde(default)]
210    pub include_objects_collected_by_minor_gc: Option<bool>,
211}
212#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
213pub enum StartSamplingMethod {
214    #[serde(rename = "HeapProfiler.startSampling")]
215    StartSampling,
216}
217#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
218pub struct StartSampling {
219    pub method: StartSamplingMethod,
220    pub params: StartSamplingParams,
221}
222impl StartSampling {
223    pub const IDENTIFIER: &'static str = "HeapProfiler.startSampling";
224    pub fn identifier(&self) -> &'static str {
225        Self::IDENTIFIER
226    }
227}
228impl crate::CommandResult for StartSampling {
229    type Result = super::results::StartSamplingResult;
230}
231#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
232pub struct StartTrackingHeapObjectsParams {
233    #[serde(rename = "trackAllocations")]
234    #[serde(skip_serializing_if = "Option::is_none")]
235    #[serde(default)]
236    pub track_allocations: Option<bool>,
237}
238#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
239pub enum StartTrackingHeapObjectsMethod {
240    #[serde(rename = "HeapProfiler.startTrackingHeapObjects")]
241    StartTrackingHeapObjects,
242}
243#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
244pub struct StartTrackingHeapObjects {
245    pub method: StartTrackingHeapObjectsMethod,
246    pub params: StartTrackingHeapObjectsParams,
247}
248impl StartTrackingHeapObjects {
249    pub const IDENTIFIER: &'static str = "HeapProfiler.startTrackingHeapObjects";
250    pub fn identifier(&self) -> &'static str {
251        Self::IDENTIFIER
252    }
253}
254impl crate::CommandResult for StartTrackingHeapObjects {
255    type Result = super::results::StartTrackingHeapObjectsResult;
256}
257#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
258pub struct StopSamplingParams {}
259#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
260pub enum StopSamplingMethod {
261    #[serde(rename = "HeapProfiler.stopSampling")]
262    StopSampling,
263}
264#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
265pub struct StopSampling {
266    pub method: StopSamplingMethod,
267    pub params: StopSamplingParams,
268}
269impl StopSampling {
270    pub const IDENTIFIER: &'static str = "HeapProfiler.stopSampling";
271    pub fn identifier(&self) -> &'static str {
272        Self::IDENTIFIER
273    }
274}
275impl crate::CommandResult for StopSampling {
276    type Result = super::results::StopSamplingResult;
277}
278#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
279pub struct StopTrackingHeapObjectsParams {
280    #[doc = "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken\nwhen the tracking is stopped."]
281    #[serde(rename = "reportProgress")]
282    #[serde(skip_serializing_if = "Option::is_none")]
283    #[serde(default)]
284    pub report_progress: Option<bool>,
285    #[doc = "If true, numerical values are included in the snapshot"]
286    #[serde(rename = "captureNumericValue")]
287    #[serde(skip_serializing_if = "Option::is_none")]
288    #[serde(default)]
289    pub capture_numeric_value: Option<bool>,
290    #[doc = "If true, exposes internals of the snapshot."]
291    #[serde(rename = "exposeInternals")]
292    #[serde(skip_serializing_if = "Option::is_none")]
293    #[serde(default)]
294    pub expose_internals: Option<bool>,
295}
296#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
297pub enum StopTrackingHeapObjectsMethod {
298    #[serde(rename = "HeapProfiler.stopTrackingHeapObjects")]
299    StopTrackingHeapObjects,
300}
301#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
302pub struct StopTrackingHeapObjects {
303    pub method: StopTrackingHeapObjectsMethod,
304    pub params: StopTrackingHeapObjectsParams,
305}
306impl StopTrackingHeapObjects {
307    pub const IDENTIFIER: &'static str = "HeapProfiler.stopTrackingHeapObjects";
308    pub fn identifier(&self) -> &'static str {
309        Self::IDENTIFIER
310    }
311}
312impl crate::CommandResult for StopTrackingHeapObjects {
313    type Result = super::results::StopTrackingHeapObjectsResult;
314}
315#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
316pub struct TakeHeapSnapshotParams {
317    #[doc = "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken."]
318    #[serde(rename = "reportProgress")]
319    #[serde(skip_serializing_if = "Option::is_none")]
320    #[serde(default)]
321    pub report_progress: Option<bool>,
322    #[doc = "If true, numerical values are included in the snapshot"]
323    #[serde(rename = "captureNumericValue")]
324    #[serde(skip_serializing_if = "Option::is_none")]
325    #[serde(default)]
326    pub capture_numeric_value: Option<bool>,
327    #[doc = "If true, exposes internals of the snapshot."]
328    #[serde(rename = "exposeInternals")]
329    #[serde(skip_serializing_if = "Option::is_none")]
330    #[serde(default)]
331    pub expose_internals: Option<bool>,
332}
333#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
334pub enum TakeHeapSnapshotMethod {
335    #[serde(rename = "HeapProfiler.takeHeapSnapshot")]
336    TakeHeapSnapshot,
337}
338#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
339pub struct TakeHeapSnapshot {
340    pub method: TakeHeapSnapshotMethod,
341    pub params: TakeHeapSnapshotParams,
342}
343impl TakeHeapSnapshot {
344    pub const IDENTIFIER: &'static str = "HeapProfiler.takeHeapSnapshot";
345    pub fn identifier(&self) -> &'static str {
346        Self::IDENTIFIER
347    }
348}
349impl crate::CommandResult for TakeHeapSnapshot {
350    type Result = super::results::TakeHeapSnapshotResult;
351}
352group_enum ! (HeapProfilerCommands { AddInspectedHeapObject (AddInspectedHeapObject) , CollectGarbage (CollectGarbage) , Disable (Disable) , Enable (Enable) , GetHeapObjectId (GetHeapObjectId) , GetObjectByHeapObjectId (GetObjectByHeapObjectId) , GetSamplingProfile (GetSamplingProfile) , StartSampling (StartSampling) , StartTrackingHeapObjects (StartTrackingHeapObjects) , StopSampling (StopSampling) , StopTrackingHeapObjects (StopTrackingHeapObjects) , TakeHeapSnapshot (TakeHeapSnapshot) } + identifiable);