Skip to main content

js_protocol/heapprofiler/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5/// Heap snapshot object id.
6
7pub type HeapSnapshotObjectId<'a> = Cow<'a, str>;
8
9/// Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.
10
11#[derive(Debug, Clone, Serialize, Deserialize, Default)]
12#[serde(rename_all = "camelCase")]
13pub struct SamplingHeapProfileNode<'a> {
14    /// Function location.
15    #[serde(rename = "callFrame")]
16    call_frame: crate::runtime::CallFrame<'a>,
17    /// Allocations size in bytes for the node excluding children.
18    #[serde(rename = "selfSize")]
19    self_size: f64,
20    /// Node id. Ids are unique across all profiles collected between startSampling and stopSampling.
21    id: u64,
22    /// Child nodes.
23    children: Vec<Box<SamplingHeapProfileNode<'a>>>,
24}
25
26impl<'a> SamplingHeapProfileNode<'a> {
27    /// Creates a builder for this type with the required parameters:
28    /// * `call_frame`: Function location.
29    /// * `self_size`: Allocations size in bytes for the node excluding children.
30    /// * `id`: Node id. Ids are unique across all profiles collected between startSampling and stopSampling.
31    /// * `children`: Child nodes.
32    pub fn builder(call_frame: crate::runtime::CallFrame<'a>, self_size: f64, id: u64, children: Vec<Box<SamplingHeapProfileNode<'a>>>) -> SamplingHeapProfileNodeBuilder<'a> {
33        SamplingHeapProfileNodeBuilder {
34            call_frame: call_frame,
35            self_size: self_size,
36            id: id,
37            children: children,
38        }
39    }
40    /// Function location.
41    pub fn call_frame(&self) -> &crate::runtime::CallFrame<'a> { &self.call_frame }
42    /// Allocations size in bytes for the node excluding children.
43    pub fn self_size(&self) -> f64 { self.self_size }
44    /// Node id. Ids are unique across all profiles collected between startSampling and stopSampling.
45    pub fn id(&self) -> u64 { self.id }
46    /// Child nodes.
47    pub fn children(&self) -> &[Box<SamplingHeapProfileNode<'a>>] { &self.children }
48}
49
50
51pub struct SamplingHeapProfileNodeBuilder<'a> {
52    call_frame: crate::runtime::CallFrame<'a>,
53    self_size: f64,
54    id: u64,
55    children: Vec<Box<SamplingHeapProfileNode<'a>>>,
56}
57
58impl<'a> SamplingHeapProfileNodeBuilder<'a> {
59    pub fn build(self) -> SamplingHeapProfileNode<'a> {
60        SamplingHeapProfileNode {
61            call_frame: self.call_frame,
62            self_size: self.self_size,
63            id: self.id,
64            children: self.children,
65        }
66    }
67}
68
69/// A single sample from a sampling profile.
70
71#[derive(Debug, Clone, Serialize, Deserialize, Default)]
72#[serde(rename_all = "camelCase")]
73pub struct SamplingHeapProfileSample {
74    /// Allocation size in bytes attributed to the sample.
75    size: f64,
76    /// Id of the corresponding profile tree node.
77    #[serde(rename = "nodeId")]
78    node_id: u64,
79    /// Time-ordered sample ordinal number. It is unique across all profiles retrieved
80    /// between startSampling and stopSampling.
81    ordinal: f64,
82}
83
84impl SamplingHeapProfileSample {
85    /// Creates a builder for this type with the required parameters:
86    /// * `size`: Allocation size in bytes attributed to the sample.
87    /// * `node_id`: Id of the corresponding profile tree node.
88    /// * `ordinal`: Time-ordered sample ordinal number. It is unique across all profiles retrieved between startSampling and stopSampling.
89    pub fn builder(size: f64, node_id: u64, ordinal: f64) -> SamplingHeapProfileSampleBuilder {
90        SamplingHeapProfileSampleBuilder {
91            size: size,
92            node_id: node_id,
93            ordinal: ordinal,
94        }
95    }
96    /// Allocation size in bytes attributed to the sample.
97    pub fn size(&self) -> f64 { self.size }
98    /// Id of the corresponding profile tree node.
99    pub fn node_id(&self) -> u64 { self.node_id }
100    /// Time-ordered sample ordinal number. It is unique across all profiles retrieved
101    /// between startSampling and stopSampling.
102    pub fn ordinal(&self) -> f64 { self.ordinal }
103}
104
105
106pub struct SamplingHeapProfileSampleBuilder {
107    size: f64,
108    node_id: u64,
109    ordinal: f64,
110}
111
112impl SamplingHeapProfileSampleBuilder {
113    pub fn build(self) -> SamplingHeapProfileSample {
114        SamplingHeapProfileSample {
115            size: self.size,
116            node_id: self.node_id,
117            ordinal: self.ordinal,
118        }
119    }
120}
121
122/// Sampling profile.
123
124#[derive(Debug, Clone, Serialize, Deserialize, Default)]
125#[serde(rename_all = "camelCase")]
126pub struct SamplingHeapProfile<'a> {
127    head: SamplingHeapProfileNode<'a>,
128    samples: Vec<SamplingHeapProfileSample>,
129}
130
131impl<'a> SamplingHeapProfile<'a> {
132    /// Creates a builder for this type with the required parameters:
133    /// * `head`: 
134    /// * `samples`: 
135    pub fn builder(head: SamplingHeapProfileNode<'a>, samples: Vec<SamplingHeapProfileSample>) -> SamplingHeapProfileBuilder<'a> {
136        SamplingHeapProfileBuilder {
137            head: head,
138            samples: samples,
139        }
140    }
141    pub fn head(&self) -> &SamplingHeapProfileNode<'a> { &self.head }
142    pub fn samples(&self) -> &[SamplingHeapProfileSample] { &self.samples }
143}
144
145
146pub struct SamplingHeapProfileBuilder<'a> {
147    head: SamplingHeapProfileNode<'a>,
148    samples: Vec<SamplingHeapProfileSample>,
149}
150
151impl<'a> SamplingHeapProfileBuilder<'a> {
152    pub fn build(self) -> SamplingHeapProfile<'a> {
153        SamplingHeapProfile {
154            head: self.head,
155            samples: self.samples,
156        }
157    }
158}
159
160/// Enables console to refer to the node with given id via $x (see Command Line API for more details
161/// $x functions).
162
163#[derive(Debug, Clone, Serialize, Deserialize, Default)]
164#[serde(rename_all = "camelCase")]
165pub struct AddInspectedHeapObjectParams<'a> {
166    /// Heap snapshot object id to be accessible by means of $x command line API.
167    #[serde(rename = "heapObjectId")]
168    heap_object_id: HeapSnapshotObjectId<'a>,
169}
170
171impl<'a> AddInspectedHeapObjectParams<'a> {
172    /// Creates a builder for this type with the required parameters:
173    /// * `heap_object_id`: Heap snapshot object id to be accessible by means of $x command line API.
174    pub fn builder(heap_object_id: impl Into<HeapSnapshotObjectId<'a>>) -> AddInspectedHeapObjectParamsBuilder<'a> {
175        AddInspectedHeapObjectParamsBuilder {
176            heap_object_id: heap_object_id.into(),
177        }
178    }
179    /// Heap snapshot object id to be accessible by means of $x command line API.
180    pub fn heap_object_id(&self) -> &HeapSnapshotObjectId<'a> { &self.heap_object_id }
181}
182
183
184pub struct AddInspectedHeapObjectParamsBuilder<'a> {
185    heap_object_id: HeapSnapshotObjectId<'a>,
186}
187
188impl<'a> AddInspectedHeapObjectParamsBuilder<'a> {
189    pub fn build(self) -> AddInspectedHeapObjectParams<'a> {
190        AddInspectedHeapObjectParams {
191            heap_object_id: self.heap_object_id,
192        }
193    }
194}
195
196impl<'a> AddInspectedHeapObjectParams<'a> { pub const METHOD: &'static str = "HeapProfiler.addInspectedHeapObject"; }
197
198impl<'a> crate::CdpCommand<'a> for AddInspectedHeapObjectParams<'a> {
199    const METHOD: &'static str = "HeapProfiler.addInspectedHeapObject";
200    type Response = crate::EmptyReturns;
201}
202
203#[derive(Debug, Clone, Serialize, Deserialize, Default)]
204pub struct CollectGarbageParams {}
205
206impl CollectGarbageParams { pub const METHOD: &'static str = "HeapProfiler.collectGarbage"; }
207
208impl<'a> crate::CdpCommand<'a> for CollectGarbageParams {
209    const METHOD: &'static str = "HeapProfiler.collectGarbage";
210    type Response = crate::EmptyReturns;
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize, Default)]
214pub struct DisableParams {}
215
216impl DisableParams { pub const METHOD: &'static str = "HeapProfiler.disable"; }
217
218impl<'a> crate::CdpCommand<'a> for DisableParams {
219    const METHOD: &'static str = "HeapProfiler.disable";
220    type Response = crate::EmptyReturns;
221}
222
223#[derive(Debug, Clone, Serialize, Deserialize, Default)]
224pub struct EnableParams {}
225
226impl EnableParams { pub const METHOD: &'static str = "HeapProfiler.enable"; }
227
228impl<'a> crate::CdpCommand<'a> for EnableParams {
229    const METHOD: &'static str = "HeapProfiler.enable";
230    type Response = crate::EmptyReturns;
231}
232
233
234#[derive(Debug, Clone, Serialize, Deserialize, Default)]
235#[serde(rename_all = "camelCase")]
236pub struct GetHeapObjectIdParams<'a> {
237    /// Identifier of the object to get heap object id for.
238    #[serde(rename = "objectId")]
239    object_id: crate::runtime::RemoteObjectId<'a>,
240}
241
242impl<'a> GetHeapObjectIdParams<'a> {
243    /// Creates a builder for this type with the required parameters:
244    /// * `object_id`: Identifier of the object to get heap object id for.
245    pub fn builder(object_id: crate::runtime::RemoteObjectId<'a>) -> GetHeapObjectIdParamsBuilder<'a> {
246        GetHeapObjectIdParamsBuilder {
247            object_id: object_id,
248        }
249    }
250    /// Identifier of the object to get heap object id for.
251    pub fn object_id(&self) -> &crate::runtime::RemoteObjectId<'a> { &self.object_id }
252}
253
254
255pub struct GetHeapObjectIdParamsBuilder<'a> {
256    object_id: crate::runtime::RemoteObjectId<'a>,
257}
258
259impl<'a> GetHeapObjectIdParamsBuilder<'a> {
260    pub fn build(self) -> GetHeapObjectIdParams<'a> {
261        GetHeapObjectIdParams {
262            object_id: self.object_id,
263        }
264    }
265}
266
267
268#[derive(Debug, Clone, Serialize, Deserialize, Default)]
269#[serde(rename_all = "camelCase")]
270pub struct GetHeapObjectIdReturns<'a> {
271    /// Id of the heap snapshot object corresponding to the passed remote object id.
272    #[serde(rename = "heapSnapshotObjectId")]
273    heap_snapshot_object_id: HeapSnapshotObjectId<'a>,
274}
275
276impl<'a> GetHeapObjectIdReturns<'a> {
277    /// Creates a builder for this type with the required parameters:
278    /// * `heap_snapshot_object_id`: Id of the heap snapshot object corresponding to the passed remote object id.
279    pub fn builder(heap_snapshot_object_id: impl Into<HeapSnapshotObjectId<'a>>) -> GetHeapObjectIdReturnsBuilder<'a> {
280        GetHeapObjectIdReturnsBuilder {
281            heap_snapshot_object_id: heap_snapshot_object_id.into(),
282        }
283    }
284    /// Id of the heap snapshot object corresponding to the passed remote object id.
285    pub fn heap_snapshot_object_id(&self) -> &HeapSnapshotObjectId<'a> { &self.heap_snapshot_object_id }
286}
287
288
289pub struct GetHeapObjectIdReturnsBuilder<'a> {
290    heap_snapshot_object_id: HeapSnapshotObjectId<'a>,
291}
292
293impl<'a> GetHeapObjectIdReturnsBuilder<'a> {
294    pub fn build(self) -> GetHeapObjectIdReturns<'a> {
295        GetHeapObjectIdReturns {
296            heap_snapshot_object_id: self.heap_snapshot_object_id,
297        }
298    }
299}
300
301impl<'a> GetHeapObjectIdParams<'a> { pub const METHOD: &'static str = "HeapProfiler.getHeapObjectId"; }
302
303impl<'a> crate::CdpCommand<'a> for GetHeapObjectIdParams<'a> {
304    const METHOD: &'static str = "HeapProfiler.getHeapObjectId";
305    type Response = GetHeapObjectIdReturns<'a>;
306}
307
308
309#[derive(Debug, Clone, Serialize, Deserialize, Default)]
310#[serde(rename_all = "camelCase")]
311pub struct GetObjectByHeapObjectIdParams<'a> {
312    #[serde(rename = "objectId")]
313    object_id: HeapSnapshotObjectId<'a>,
314    /// Symbolic group name that can be used to release multiple objects.
315    #[serde(skip_serializing_if = "Option::is_none", rename = "objectGroup")]
316    object_group: Option<Cow<'a, str>>,
317}
318
319impl<'a> GetObjectByHeapObjectIdParams<'a> {
320    /// Creates a builder for this type with the required parameters:
321    /// * `object_id`: 
322    pub fn builder(object_id: impl Into<HeapSnapshotObjectId<'a>>) -> GetObjectByHeapObjectIdParamsBuilder<'a> {
323        GetObjectByHeapObjectIdParamsBuilder {
324            object_id: object_id.into(),
325            object_group: None,
326        }
327    }
328    pub fn object_id(&self) -> &HeapSnapshotObjectId<'a> { &self.object_id }
329    /// Symbolic group name that can be used to release multiple objects.
330    pub fn object_group(&self) -> Option<&str> { self.object_group.as_deref() }
331}
332
333
334pub struct GetObjectByHeapObjectIdParamsBuilder<'a> {
335    object_id: HeapSnapshotObjectId<'a>,
336    object_group: Option<Cow<'a, str>>,
337}
338
339impl<'a> GetObjectByHeapObjectIdParamsBuilder<'a> {
340    /// Symbolic group name that can be used to release multiple objects.
341    pub fn object_group(mut self, object_group: impl Into<Cow<'a, str>>) -> Self { self.object_group = Some(object_group.into()); self }
342    pub fn build(self) -> GetObjectByHeapObjectIdParams<'a> {
343        GetObjectByHeapObjectIdParams {
344            object_id: self.object_id,
345            object_group: self.object_group,
346        }
347    }
348}
349
350
351#[derive(Debug, Clone, Serialize, Deserialize, Default)]
352#[serde(rename_all = "camelCase")]
353pub struct GetObjectByHeapObjectIdReturns<'a> {
354    /// Evaluation result.
355    result: crate::runtime::RemoteObject<'a>,
356}
357
358impl<'a> GetObjectByHeapObjectIdReturns<'a> {
359    /// Creates a builder for this type with the required parameters:
360    /// * `result`: Evaluation result.
361    pub fn builder(result: crate::runtime::RemoteObject<'a>) -> GetObjectByHeapObjectIdReturnsBuilder<'a> {
362        GetObjectByHeapObjectIdReturnsBuilder {
363            result: result,
364        }
365    }
366    /// Evaluation result.
367    pub fn result(&self) -> &crate::runtime::RemoteObject<'a> { &self.result }
368}
369
370
371pub struct GetObjectByHeapObjectIdReturnsBuilder<'a> {
372    result: crate::runtime::RemoteObject<'a>,
373}
374
375impl<'a> GetObjectByHeapObjectIdReturnsBuilder<'a> {
376    pub fn build(self) -> GetObjectByHeapObjectIdReturns<'a> {
377        GetObjectByHeapObjectIdReturns {
378            result: self.result,
379        }
380    }
381}
382
383impl<'a> GetObjectByHeapObjectIdParams<'a> { pub const METHOD: &'static str = "HeapProfiler.getObjectByHeapObjectId"; }
384
385impl<'a> crate::CdpCommand<'a> for GetObjectByHeapObjectIdParams<'a> {
386    const METHOD: &'static str = "HeapProfiler.getObjectByHeapObjectId";
387    type Response = GetObjectByHeapObjectIdReturns<'a>;
388}
389
390
391#[derive(Debug, Clone, Serialize, Deserialize, Default)]
392#[serde(rename_all = "camelCase")]
393pub struct GetSamplingProfileReturns<'a> {
394    /// Return the sampling profile being collected.
395    profile: SamplingHeapProfile<'a>,
396}
397
398impl<'a> GetSamplingProfileReturns<'a> {
399    /// Creates a builder for this type with the required parameters:
400    /// * `profile`: Return the sampling profile being collected.
401    pub fn builder(profile: SamplingHeapProfile<'a>) -> GetSamplingProfileReturnsBuilder<'a> {
402        GetSamplingProfileReturnsBuilder {
403            profile: profile,
404        }
405    }
406    /// Return the sampling profile being collected.
407    pub fn profile(&self) -> &SamplingHeapProfile<'a> { &self.profile }
408}
409
410
411pub struct GetSamplingProfileReturnsBuilder<'a> {
412    profile: SamplingHeapProfile<'a>,
413}
414
415impl<'a> GetSamplingProfileReturnsBuilder<'a> {
416    pub fn build(self) -> GetSamplingProfileReturns<'a> {
417        GetSamplingProfileReturns {
418            profile: self.profile,
419        }
420    }
421}
422
423#[derive(Debug, Clone, Serialize, Deserialize, Default)]
424pub struct GetSamplingProfileParams {}
425
426impl GetSamplingProfileParams { pub const METHOD: &'static str = "HeapProfiler.getSamplingProfile"; }
427
428impl<'a> crate::CdpCommand<'a> for GetSamplingProfileParams {
429    const METHOD: &'static str = "HeapProfiler.getSamplingProfile";
430    type Response = GetSamplingProfileReturns<'a>;
431}
432
433
434#[derive(Debug, Clone, Serialize, Deserialize, Default)]
435#[serde(rename_all = "camelCase")]
436pub struct StartSamplingParams {
437    /// Average sample interval in bytes. Poisson distribution is used for the intervals. The
438    /// default value is 32768 bytes.
439    #[serde(skip_serializing_if = "Option::is_none", rename = "samplingInterval")]
440    sampling_interval: Option<f64>,
441    /// Maximum stack depth. The default value is 128.
442    #[serde(skip_serializing_if = "Option::is_none", rename = "stackDepth")]
443    stack_depth: Option<f64>,
444    /// By default, the sampling heap profiler reports only objects which are
445    /// still alive when the profile is returned via getSamplingProfile or
446    /// stopSampling, which is useful for determining what functions contribute
447    /// the most to steady-state memory usage. This flag instructs the sampling
448    /// heap profiler to also include information about objects discarded by
449    /// major GC, which will show which functions cause large temporary memory
450    /// usage or long GC pauses.
451    #[serde(skip_serializing_if = "Option::is_none", rename = "includeObjectsCollectedByMajorGC")]
452    include_objects_collected_by_major_gc: Option<bool>,
453    /// By default, the sampling heap profiler reports only objects which are
454    /// still alive when the profile is returned via getSamplingProfile or
455    /// stopSampling, which is useful for determining what functions contribute
456    /// the most to steady-state memory usage. This flag instructs the sampling
457    /// heap profiler to also include information about objects discarded by
458    /// minor GC, which is useful when tuning a latency-sensitive application
459    /// for minimal GC activity.
460    #[serde(skip_serializing_if = "Option::is_none", rename = "includeObjectsCollectedByMinorGC")]
461    include_objects_collected_by_minor_gc: Option<bool>,
462}
463
464impl StartSamplingParams {
465    /// Creates a builder for this type.
466    pub fn builder() -> StartSamplingParamsBuilder {
467        StartSamplingParamsBuilder {
468            sampling_interval: None,
469            stack_depth: None,
470            include_objects_collected_by_major_gc: None,
471            include_objects_collected_by_minor_gc: None,
472        }
473    }
474    /// Average sample interval in bytes. Poisson distribution is used for the intervals. The
475    /// default value is 32768 bytes.
476    pub fn sampling_interval(&self) -> Option<f64> { self.sampling_interval }
477    /// Maximum stack depth. The default value is 128.
478    pub fn stack_depth(&self) -> Option<f64> { self.stack_depth }
479    /// By default, the sampling heap profiler reports only objects which are
480    /// still alive when the profile is returned via getSamplingProfile or
481    /// stopSampling, which is useful for determining what functions contribute
482    /// the most to steady-state memory usage. This flag instructs the sampling
483    /// heap profiler to also include information about objects discarded by
484    /// major GC, which will show which functions cause large temporary memory
485    /// usage or long GC pauses.
486    pub fn include_objects_collected_by_major_gc(&self) -> Option<bool> { self.include_objects_collected_by_major_gc }
487    /// By default, the sampling heap profiler reports only objects which are
488    /// still alive when the profile is returned via getSamplingProfile or
489    /// stopSampling, which is useful for determining what functions contribute
490    /// the most to steady-state memory usage. This flag instructs the sampling
491    /// heap profiler to also include information about objects discarded by
492    /// minor GC, which is useful when tuning a latency-sensitive application
493    /// for minimal GC activity.
494    pub fn include_objects_collected_by_minor_gc(&self) -> Option<bool> { self.include_objects_collected_by_minor_gc }
495}
496
497#[derive(Default)]
498pub struct StartSamplingParamsBuilder {
499    sampling_interval: Option<f64>,
500    stack_depth: Option<f64>,
501    include_objects_collected_by_major_gc: Option<bool>,
502    include_objects_collected_by_minor_gc: Option<bool>,
503}
504
505impl StartSamplingParamsBuilder {
506    /// Average sample interval in bytes. Poisson distribution is used for the intervals. The
507    /// default value is 32768 bytes.
508    pub fn sampling_interval(mut self, sampling_interval: f64) -> Self { self.sampling_interval = Some(sampling_interval); self }
509    /// Maximum stack depth. The default value is 128.
510    pub fn stack_depth(mut self, stack_depth: f64) -> Self { self.stack_depth = Some(stack_depth); self }
511    /// By default, the sampling heap profiler reports only objects which are
512    /// still alive when the profile is returned via getSamplingProfile or
513    /// stopSampling, which is useful for determining what functions contribute
514    /// the most to steady-state memory usage. This flag instructs the sampling
515    /// heap profiler to also include information about objects discarded by
516    /// major GC, which will show which functions cause large temporary memory
517    /// usage or long GC pauses.
518    pub fn include_objects_collected_by_major_gc(mut self, include_objects_collected_by_major_gc: bool) -> Self { self.include_objects_collected_by_major_gc = Some(include_objects_collected_by_major_gc); self }
519    /// By default, the sampling heap profiler reports only objects which are
520    /// still alive when the profile is returned via getSamplingProfile or
521    /// stopSampling, which is useful for determining what functions contribute
522    /// the most to steady-state memory usage. This flag instructs the sampling
523    /// heap profiler to also include information about objects discarded by
524    /// minor GC, which is useful when tuning a latency-sensitive application
525    /// for minimal GC activity.
526    pub fn include_objects_collected_by_minor_gc(mut self, include_objects_collected_by_minor_gc: bool) -> Self { self.include_objects_collected_by_minor_gc = Some(include_objects_collected_by_minor_gc); self }
527    pub fn build(self) -> StartSamplingParams {
528        StartSamplingParams {
529            sampling_interval: self.sampling_interval,
530            stack_depth: self.stack_depth,
531            include_objects_collected_by_major_gc: self.include_objects_collected_by_major_gc,
532            include_objects_collected_by_minor_gc: self.include_objects_collected_by_minor_gc,
533        }
534    }
535}
536
537impl StartSamplingParams { pub const METHOD: &'static str = "HeapProfiler.startSampling"; }
538
539impl<'a> crate::CdpCommand<'a> for StartSamplingParams {
540    const METHOD: &'static str = "HeapProfiler.startSampling";
541    type Response = crate::EmptyReturns;
542}
543
544
545#[derive(Debug, Clone, Serialize, Deserialize, Default)]
546#[serde(rename_all = "camelCase")]
547pub struct StartTrackingHeapObjectsParams {
548    #[serde(skip_serializing_if = "Option::is_none", rename = "trackAllocations")]
549    track_allocations: Option<bool>,
550}
551
552impl StartTrackingHeapObjectsParams {
553    /// Creates a builder for this type.
554    pub fn builder() -> StartTrackingHeapObjectsParamsBuilder {
555        StartTrackingHeapObjectsParamsBuilder {
556            track_allocations: None,
557        }
558    }
559    pub fn track_allocations(&self) -> Option<bool> { self.track_allocations }
560}
561
562#[derive(Default)]
563pub struct StartTrackingHeapObjectsParamsBuilder {
564    track_allocations: Option<bool>,
565}
566
567impl StartTrackingHeapObjectsParamsBuilder {
568    pub fn track_allocations(mut self, track_allocations: bool) -> Self { self.track_allocations = Some(track_allocations); self }
569    pub fn build(self) -> StartTrackingHeapObjectsParams {
570        StartTrackingHeapObjectsParams {
571            track_allocations: self.track_allocations,
572        }
573    }
574}
575
576impl StartTrackingHeapObjectsParams { pub const METHOD: &'static str = "HeapProfiler.startTrackingHeapObjects"; }
577
578impl<'a> crate::CdpCommand<'a> for StartTrackingHeapObjectsParams {
579    const METHOD: &'static str = "HeapProfiler.startTrackingHeapObjects";
580    type Response = crate::EmptyReturns;
581}
582
583
584#[derive(Debug, Clone, Serialize, Deserialize, Default)]
585#[serde(rename_all = "camelCase")]
586pub struct StopSamplingReturns<'a> {
587    /// Recorded sampling heap profile.
588    profile: SamplingHeapProfile<'a>,
589}
590
591impl<'a> StopSamplingReturns<'a> {
592    /// Creates a builder for this type with the required parameters:
593    /// * `profile`: Recorded sampling heap profile.
594    pub fn builder(profile: SamplingHeapProfile<'a>) -> StopSamplingReturnsBuilder<'a> {
595        StopSamplingReturnsBuilder {
596            profile: profile,
597        }
598    }
599    /// Recorded sampling heap profile.
600    pub fn profile(&self) -> &SamplingHeapProfile<'a> { &self.profile }
601}
602
603
604pub struct StopSamplingReturnsBuilder<'a> {
605    profile: SamplingHeapProfile<'a>,
606}
607
608impl<'a> StopSamplingReturnsBuilder<'a> {
609    pub fn build(self) -> StopSamplingReturns<'a> {
610        StopSamplingReturns {
611            profile: self.profile,
612        }
613    }
614}
615
616#[derive(Debug, Clone, Serialize, Deserialize, Default)]
617pub struct StopSamplingParams {}
618
619impl StopSamplingParams { pub const METHOD: &'static str = "HeapProfiler.stopSampling"; }
620
621impl<'a> crate::CdpCommand<'a> for StopSamplingParams {
622    const METHOD: &'static str = "HeapProfiler.stopSampling";
623    type Response = StopSamplingReturns<'a>;
624}
625
626
627#[derive(Debug, Clone, Serialize, Deserialize, Default)]
628#[serde(rename_all = "camelCase")]
629pub struct StopTrackingHeapObjectsParams {
630    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken
631    /// when the tracking is stopped.
632    #[serde(skip_serializing_if = "Option::is_none", rename = "reportProgress")]
633    report_progress: Option<bool>,
634    /// Deprecated in favor of 'exposeInternals'.
635    #[serde(skip_serializing_if = "Option::is_none", rename = "treatGlobalObjectsAsRoots")]
636    treat_global_objects_as_roots: Option<bool>,
637    /// If true, numerical values are included in the snapshot
638    #[serde(skip_serializing_if = "Option::is_none", rename = "captureNumericValue")]
639    capture_numeric_value: Option<bool>,
640    /// If true, exposes internals of the snapshot.
641    #[serde(skip_serializing_if = "Option::is_none", rename = "exposeInternals")]
642    expose_internals: Option<bool>,
643}
644
645impl StopTrackingHeapObjectsParams {
646    /// Creates a builder for this type.
647    pub fn builder() -> StopTrackingHeapObjectsParamsBuilder {
648        StopTrackingHeapObjectsParamsBuilder {
649            report_progress: None,
650            treat_global_objects_as_roots: None,
651            capture_numeric_value: None,
652            expose_internals: None,
653        }
654    }
655    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken
656    /// when the tracking is stopped.
657    pub fn report_progress(&self) -> Option<bool> { self.report_progress }
658    /// Deprecated in favor of 'exposeInternals'.
659    pub fn treat_global_objects_as_roots(&self) -> Option<bool> { self.treat_global_objects_as_roots }
660    /// If true, numerical values are included in the snapshot
661    pub fn capture_numeric_value(&self) -> Option<bool> { self.capture_numeric_value }
662    /// If true, exposes internals of the snapshot.
663    pub fn expose_internals(&self) -> Option<bool> { self.expose_internals }
664}
665
666#[derive(Default)]
667pub struct StopTrackingHeapObjectsParamsBuilder {
668    report_progress: Option<bool>,
669    treat_global_objects_as_roots: Option<bool>,
670    capture_numeric_value: Option<bool>,
671    expose_internals: Option<bool>,
672}
673
674impl StopTrackingHeapObjectsParamsBuilder {
675    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken
676    /// when the tracking is stopped.
677    pub fn report_progress(mut self, report_progress: bool) -> Self { self.report_progress = Some(report_progress); self }
678    /// Deprecated in favor of 'exposeInternals'.
679    pub fn treat_global_objects_as_roots(mut self, treat_global_objects_as_roots: bool) -> Self { self.treat_global_objects_as_roots = Some(treat_global_objects_as_roots); self }
680    /// If true, numerical values are included in the snapshot
681    pub fn capture_numeric_value(mut self, capture_numeric_value: bool) -> Self { self.capture_numeric_value = Some(capture_numeric_value); self }
682    /// If true, exposes internals of the snapshot.
683    pub fn expose_internals(mut self, expose_internals: bool) -> Self { self.expose_internals = Some(expose_internals); self }
684    pub fn build(self) -> StopTrackingHeapObjectsParams {
685        StopTrackingHeapObjectsParams {
686            report_progress: self.report_progress,
687            treat_global_objects_as_roots: self.treat_global_objects_as_roots,
688            capture_numeric_value: self.capture_numeric_value,
689            expose_internals: self.expose_internals,
690        }
691    }
692}
693
694impl StopTrackingHeapObjectsParams { pub const METHOD: &'static str = "HeapProfiler.stopTrackingHeapObjects"; }
695
696impl<'a> crate::CdpCommand<'a> for StopTrackingHeapObjectsParams {
697    const METHOD: &'static str = "HeapProfiler.stopTrackingHeapObjects";
698    type Response = crate::EmptyReturns;
699}
700
701
702#[derive(Debug, Clone, Serialize, Deserialize, Default)]
703#[serde(rename_all = "camelCase")]
704pub struct TakeHeapSnapshotParams {
705    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
706    #[serde(skip_serializing_if = "Option::is_none", rename = "reportProgress")]
707    report_progress: Option<bool>,
708    /// If true, a raw snapshot without artificial roots will be generated.
709    /// Deprecated in favor of 'exposeInternals'.
710    #[serde(skip_serializing_if = "Option::is_none", rename = "treatGlobalObjectsAsRoots")]
711    treat_global_objects_as_roots: Option<bool>,
712    /// If true, numerical values are included in the snapshot
713    #[serde(skip_serializing_if = "Option::is_none", rename = "captureNumericValue")]
714    capture_numeric_value: Option<bool>,
715    /// If true, exposes internals of the snapshot.
716    #[serde(skip_serializing_if = "Option::is_none", rename = "exposeInternals")]
717    expose_internals: Option<bool>,
718}
719
720impl TakeHeapSnapshotParams {
721    /// Creates a builder for this type.
722    pub fn builder() -> TakeHeapSnapshotParamsBuilder {
723        TakeHeapSnapshotParamsBuilder {
724            report_progress: None,
725            treat_global_objects_as_roots: None,
726            capture_numeric_value: None,
727            expose_internals: None,
728        }
729    }
730    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
731    pub fn report_progress(&self) -> Option<bool> { self.report_progress }
732    /// If true, a raw snapshot without artificial roots will be generated.
733    /// Deprecated in favor of 'exposeInternals'.
734    pub fn treat_global_objects_as_roots(&self) -> Option<bool> { self.treat_global_objects_as_roots }
735    /// If true, numerical values are included in the snapshot
736    pub fn capture_numeric_value(&self) -> Option<bool> { self.capture_numeric_value }
737    /// If true, exposes internals of the snapshot.
738    pub fn expose_internals(&self) -> Option<bool> { self.expose_internals }
739}
740
741#[derive(Default)]
742pub struct TakeHeapSnapshotParamsBuilder {
743    report_progress: Option<bool>,
744    treat_global_objects_as_roots: Option<bool>,
745    capture_numeric_value: Option<bool>,
746    expose_internals: Option<bool>,
747}
748
749impl TakeHeapSnapshotParamsBuilder {
750    /// If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken.
751    pub fn report_progress(mut self, report_progress: bool) -> Self { self.report_progress = Some(report_progress); self }
752    /// If true, a raw snapshot without artificial roots will be generated.
753    /// Deprecated in favor of 'exposeInternals'.
754    pub fn treat_global_objects_as_roots(mut self, treat_global_objects_as_roots: bool) -> Self { self.treat_global_objects_as_roots = Some(treat_global_objects_as_roots); self }
755    /// If true, numerical values are included in the snapshot
756    pub fn capture_numeric_value(mut self, capture_numeric_value: bool) -> Self { self.capture_numeric_value = Some(capture_numeric_value); self }
757    /// If true, exposes internals of the snapshot.
758    pub fn expose_internals(mut self, expose_internals: bool) -> Self { self.expose_internals = Some(expose_internals); self }
759    pub fn build(self) -> TakeHeapSnapshotParams {
760        TakeHeapSnapshotParams {
761            report_progress: self.report_progress,
762            treat_global_objects_as_roots: self.treat_global_objects_as_roots,
763            capture_numeric_value: self.capture_numeric_value,
764            expose_internals: self.expose_internals,
765        }
766    }
767}
768
769impl TakeHeapSnapshotParams { pub const METHOD: &'static str = "HeapProfiler.takeHeapSnapshot"; }
770
771impl<'a> crate::CdpCommand<'a> for TakeHeapSnapshotParams {
772    const METHOD: &'static str = "HeapProfiler.takeHeapSnapshot";
773    type Response = crate::EmptyReturns;
774}