1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
8pub enum PressureLevel {
9 #[default]
10 #[serde(rename = "moderate")]
11 Moderate,
12 #[serde(rename = "critical")]
13 Critical,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize, Default)]
19#[serde(rename_all = "camelCase")]
20pub struct SamplingProfileNode<'a> {
21 size: f64,
23 total: f64,
25 stack: Vec<Cow<'a, str>>,
27}
28
29impl<'a> SamplingProfileNode<'a> {
30 pub fn builder(size: f64, total: f64, stack: Vec<Cow<'a, str>>) -> SamplingProfileNodeBuilder<'a> {
31 SamplingProfileNodeBuilder {
32 size: size,
33 total: total,
34 stack: stack,
35 }
36 }
37 pub fn size(&self) -> f64 { self.size }
38 pub fn total(&self) -> f64 { self.total }
39 pub fn stack(&self) -> &[Cow<'a, str>] { &self.stack }
40}
41
42
43pub struct SamplingProfileNodeBuilder<'a> {
44 size: f64,
45 total: f64,
46 stack: Vec<Cow<'a, str>>,
47}
48
49impl<'a> SamplingProfileNodeBuilder<'a> {
50 pub fn build(self) -> SamplingProfileNode<'a> {
51 SamplingProfileNode {
52 size: self.size,
53 total: self.total,
54 stack: self.stack,
55 }
56 }
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize, Default)]
62#[serde(rename_all = "camelCase")]
63pub struct SamplingProfile<'a> {
64 samples: Vec<SamplingProfileNode<'a>>,
65 modules: Vec<Module<'a>>,
66}
67
68impl<'a> SamplingProfile<'a> {
69 pub fn builder(samples: Vec<SamplingProfileNode<'a>>, modules: Vec<Module<'a>>) -> SamplingProfileBuilder<'a> {
70 SamplingProfileBuilder {
71 samples: samples,
72 modules: modules,
73 }
74 }
75 pub fn samples(&self) -> &[SamplingProfileNode<'a>] { &self.samples }
76 pub fn modules(&self) -> &[Module<'a>] { &self.modules }
77}
78
79
80pub struct SamplingProfileBuilder<'a> {
81 samples: Vec<SamplingProfileNode<'a>>,
82 modules: Vec<Module<'a>>,
83}
84
85impl<'a> SamplingProfileBuilder<'a> {
86 pub fn build(self) -> SamplingProfile<'a> {
87 SamplingProfile {
88 samples: self.samples,
89 modules: self.modules,
90 }
91 }
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize, Default)]
97#[serde(rename_all = "camelCase")]
98pub struct Module<'a> {
99 name: Cow<'a, str>,
101 uuid: Cow<'a, str>,
103 baseAddress: Cow<'a, str>,
106 size: f64,
108}
109
110impl<'a> Module<'a> {
111 pub fn builder(name: impl Into<Cow<'a, str>>, uuid: impl Into<Cow<'a, str>>, baseAddress: impl Into<Cow<'a, str>>, size: f64) -> ModuleBuilder<'a> {
112 ModuleBuilder {
113 name: name.into(),
114 uuid: uuid.into(),
115 baseAddress: baseAddress.into(),
116 size: size,
117 }
118 }
119 pub fn name(&self) -> &str { self.name.as_ref() }
120 pub fn uuid(&self) -> &str { self.uuid.as_ref() }
121 pub fn baseAddress(&self) -> &str { self.baseAddress.as_ref() }
122 pub fn size(&self) -> f64 { self.size }
123}
124
125
126pub struct ModuleBuilder<'a> {
127 name: Cow<'a, str>,
128 uuid: Cow<'a, str>,
129 baseAddress: Cow<'a, str>,
130 size: f64,
131}
132
133impl<'a> ModuleBuilder<'a> {
134 pub fn build(self) -> Module<'a> {
135 Module {
136 name: self.name,
137 uuid: self.uuid,
138 baseAddress: self.baseAddress,
139 size: self.size,
140 }
141 }
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize, Default)]
147#[serde(rename_all = "camelCase")]
148pub struct DOMCounter<'a> {
149 name: Cow<'a, str>,
152 count: u64,
154}
155
156impl<'a> DOMCounter<'a> {
157 pub fn builder(name: impl Into<Cow<'a, str>>, count: u64) -> DOMCounterBuilder<'a> {
158 DOMCounterBuilder {
159 name: name.into(),
160 count: count,
161 }
162 }
163 pub fn name(&self) -> &str { self.name.as_ref() }
164 pub fn count(&self) -> u64 { self.count }
165}
166
167
168pub struct DOMCounterBuilder<'a> {
169 name: Cow<'a, str>,
170 count: u64,
171}
172
173impl<'a> DOMCounterBuilder<'a> {
174 pub fn build(self) -> DOMCounter<'a> {
175 DOMCounter {
176 name: self.name,
177 count: self.count,
178 }
179 }
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize, Default)]
185#[serde(rename_all = "camelCase")]
186pub struct GetDOMCountersReturns {
187 documents: i64,
188 nodes: i64,
189 jsEventListeners: i64,
190}
191
192impl GetDOMCountersReturns {
193 pub fn builder(documents: i64, nodes: i64, jsEventListeners: i64) -> GetDOMCountersReturnsBuilder {
194 GetDOMCountersReturnsBuilder {
195 documents: documents,
196 nodes: nodes,
197 jsEventListeners: jsEventListeners,
198 }
199 }
200 pub fn documents(&self) -> i64 { self.documents }
201 pub fn nodes(&self) -> i64 { self.nodes }
202 pub fn jsEventListeners(&self) -> i64 { self.jsEventListeners }
203}
204
205
206pub struct GetDOMCountersReturnsBuilder {
207 documents: i64,
208 nodes: i64,
209 jsEventListeners: i64,
210}
211
212impl GetDOMCountersReturnsBuilder {
213 pub fn build(self) -> GetDOMCountersReturns {
214 GetDOMCountersReturns {
215 documents: self.documents,
216 nodes: self.nodes,
217 jsEventListeners: self.jsEventListeners,
218 }
219 }
220}
221
222#[derive(Debug, Clone, Serialize, Deserialize, Default)]
223pub struct GetDOMCountersParams {}
224
225impl GetDOMCountersParams { pub const METHOD: &'static str = "Memory.getDOMCounters"; }
226
227impl<'a> crate::CdpCommand<'a> for GetDOMCountersParams {
228 const METHOD: &'static str = "Memory.getDOMCounters";
229 type Response = GetDOMCountersReturns;
230}
231
232#[derive(Debug, Clone, Serialize, Deserialize, Default)]
235#[serde(rename_all = "camelCase")]
236pub struct GetDOMCountersForLeakDetectionReturns<'a> {
237 counters: Vec<DOMCounter<'a>>,
239}
240
241impl<'a> GetDOMCountersForLeakDetectionReturns<'a> {
242 pub fn builder(counters: Vec<DOMCounter<'a>>) -> GetDOMCountersForLeakDetectionReturnsBuilder<'a> {
243 GetDOMCountersForLeakDetectionReturnsBuilder {
244 counters: counters,
245 }
246 }
247 pub fn counters(&self) -> &[DOMCounter<'a>] { &self.counters }
248}
249
250
251pub struct GetDOMCountersForLeakDetectionReturnsBuilder<'a> {
252 counters: Vec<DOMCounter<'a>>,
253}
254
255impl<'a> GetDOMCountersForLeakDetectionReturnsBuilder<'a> {
256 pub fn build(self) -> GetDOMCountersForLeakDetectionReturns<'a> {
257 GetDOMCountersForLeakDetectionReturns {
258 counters: self.counters,
259 }
260 }
261}
262
263#[derive(Debug, Clone, Serialize, Deserialize, Default)]
264pub struct GetDOMCountersForLeakDetectionParams {}
265
266impl GetDOMCountersForLeakDetectionParams { pub const METHOD: &'static str = "Memory.getDOMCountersForLeakDetection"; }
267
268impl<'a> crate::CdpCommand<'a> for GetDOMCountersForLeakDetectionParams {
269 const METHOD: &'static str = "Memory.getDOMCountersForLeakDetection";
270 type Response = GetDOMCountersForLeakDetectionReturns<'a>;
271}
272
273#[derive(Debug, Clone, Serialize, Deserialize, Default)]
274pub struct PrepareForLeakDetectionParams {}
275
276impl PrepareForLeakDetectionParams { pub const METHOD: &'static str = "Memory.prepareForLeakDetection"; }
277
278impl<'a> crate::CdpCommand<'a> for PrepareForLeakDetectionParams {
279 const METHOD: &'static str = "Memory.prepareForLeakDetection";
280 type Response = crate::EmptyReturns;
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize, Default)]
284pub struct ForciblyPurgeJavaScriptMemoryParams {}
285
286impl ForciblyPurgeJavaScriptMemoryParams { pub const METHOD: &'static str = "Memory.forciblyPurgeJavaScriptMemory"; }
287
288impl<'a> crate::CdpCommand<'a> for ForciblyPurgeJavaScriptMemoryParams {
289 const METHOD: &'static str = "Memory.forciblyPurgeJavaScriptMemory";
290 type Response = crate::EmptyReturns;
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize, Default)]
296#[serde(rename_all = "camelCase")]
297pub struct SetPressureNotificationsSuppressedParams {
298 suppressed: bool,
300}
301
302impl SetPressureNotificationsSuppressedParams {
303 pub fn builder(suppressed: bool) -> SetPressureNotificationsSuppressedParamsBuilder {
304 SetPressureNotificationsSuppressedParamsBuilder {
305 suppressed: suppressed,
306 }
307 }
308 pub fn suppressed(&self) -> bool { self.suppressed }
309}
310
311
312pub struct SetPressureNotificationsSuppressedParamsBuilder {
313 suppressed: bool,
314}
315
316impl SetPressureNotificationsSuppressedParamsBuilder {
317 pub fn build(self) -> SetPressureNotificationsSuppressedParams {
318 SetPressureNotificationsSuppressedParams {
319 suppressed: self.suppressed,
320 }
321 }
322}
323
324impl SetPressureNotificationsSuppressedParams { pub const METHOD: &'static str = "Memory.setPressureNotificationsSuppressed"; }
325
326impl<'a> crate::CdpCommand<'a> for SetPressureNotificationsSuppressedParams {
327 const METHOD: &'static str = "Memory.setPressureNotificationsSuppressed";
328 type Response = crate::EmptyReturns;
329}
330
331#[derive(Debug, Clone, Serialize, Deserialize, Default)]
334#[serde(rename_all = "camelCase")]
335pub struct SimulatePressureNotificationParams {
336 level: PressureLevel,
338}
339
340impl SimulatePressureNotificationParams {
341 pub fn builder(level: PressureLevel) -> SimulatePressureNotificationParamsBuilder {
342 SimulatePressureNotificationParamsBuilder {
343 level: level,
344 }
345 }
346 pub fn level(&self) -> &PressureLevel { &self.level }
347}
348
349
350pub struct SimulatePressureNotificationParamsBuilder {
351 level: PressureLevel,
352}
353
354impl SimulatePressureNotificationParamsBuilder {
355 pub fn build(self) -> SimulatePressureNotificationParams {
356 SimulatePressureNotificationParams {
357 level: self.level,
358 }
359 }
360}
361
362impl SimulatePressureNotificationParams { pub const METHOD: &'static str = "Memory.simulatePressureNotification"; }
363
364impl<'a> crate::CdpCommand<'a> for SimulatePressureNotificationParams {
365 const METHOD: &'static str = "Memory.simulatePressureNotification";
366 type Response = crate::EmptyReturns;
367}
368
369#[derive(Debug, Clone, Serialize, Deserialize, Default)]
372#[serde(rename_all = "camelCase")]
373pub struct StartSamplingParams {
374 #[serde(skip_serializing_if = "Option::is_none")]
376 samplingInterval: Option<i64>,
377 #[serde(skip_serializing_if = "Option::is_none")]
379 suppressRandomness: Option<bool>,
380}
381
382impl StartSamplingParams {
383 pub fn builder() -> StartSamplingParamsBuilder {
384 StartSamplingParamsBuilder {
385 samplingInterval: None,
386 suppressRandomness: None,
387 }
388 }
389 pub fn samplingInterval(&self) -> Option<i64> { self.samplingInterval }
390 pub fn suppressRandomness(&self) -> Option<bool> { self.suppressRandomness }
391}
392
393#[derive(Default)]
394pub struct StartSamplingParamsBuilder {
395 samplingInterval: Option<i64>,
396 suppressRandomness: Option<bool>,
397}
398
399impl StartSamplingParamsBuilder {
400 pub fn samplingInterval(mut self, samplingInterval: i64) -> Self { self.samplingInterval = Some(samplingInterval); self }
402 pub fn suppressRandomness(mut self, suppressRandomness: bool) -> Self { self.suppressRandomness = Some(suppressRandomness); self }
404 pub fn build(self) -> StartSamplingParams {
405 StartSamplingParams {
406 samplingInterval: self.samplingInterval,
407 suppressRandomness: self.suppressRandomness,
408 }
409 }
410}
411
412impl StartSamplingParams { pub const METHOD: &'static str = "Memory.startSampling"; }
413
414impl<'a> crate::CdpCommand<'a> for StartSamplingParams {
415 const METHOD: &'static str = "Memory.startSampling";
416 type Response = crate::EmptyReturns;
417}
418
419#[derive(Debug, Clone, Serialize, Deserialize, Default)]
420pub struct StopSamplingParams {}
421
422impl StopSamplingParams { pub const METHOD: &'static str = "Memory.stopSampling"; }
423
424impl<'a> crate::CdpCommand<'a> for StopSamplingParams {
425 const METHOD: &'static str = "Memory.stopSampling";
426 type Response = crate::EmptyReturns;
427}
428
429#[derive(Debug, Clone, Serialize, Deserialize, Default)]
433#[serde(rename_all = "camelCase")]
434pub struct GetAllTimeSamplingProfileReturns<'a> {
435 profile: SamplingProfile<'a>,
436}
437
438impl<'a> GetAllTimeSamplingProfileReturns<'a> {
439 pub fn builder(profile: SamplingProfile<'a>) -> GetAllTimeSamplingProfileReturnsBuilder<'a> {
440 GetAllTimeSamplingProfileReturnsBuilder {
441 profile: profile,
442 }
443 }
444 pub fn profile(&self) -> &SamplingProfile<'a> { &self.profile }
445}
446
447
448pub struct GetAllTimeSamplingProfileReturnsBuilder<'a> {
449 profile: SamplingProfile<'a>,
450}
451
452impl<'a> GetAllTimeSamplingProfileReturnsBuilder<'a> {
453 pub fn build(self) -> GetAllTimeSamplingProfileReturns<'a> {
454 GetAllTimeSamplingProfileReturns {
455 profile: self.profile,
456 }
457 }
458}
459
460#[derive(Debug, Clone, Serialize, Deserialize, Default)]
461pub struct GetAllTimeSamplingProfileParams {}
462
463impl GetAllTimeSamplingProfileParams { pub const METHOD: &'static str = "Memory.getAllTimeSamplingProfile"; }
464
465impl<'a> crate::CdpCommand<'a> for GetAllTimeSamplingProfileParams {
466 const METHOD: &'static str = "Memory.getAllTimeSamplingProfile";
467 type Response = GetAllTimeSamplingProfileReturns<'a>;
468}
469
470#[derive(Debug, Clone, Serialize, Deserialize, Default)]
474#[serde(rename_all = "camelCase")]
475pub struct GetBrowserSamplingProfileReturns<'a> {
476 profile: SamplingProfile<'a>,
477}
478
479impl<'a> GetBrowserSamplingProfileReturns<'a> {
480 pub fn builder(profile: SamplingProfile<'a>) -> GetBrowserSamplingProfileReturnsBuilder<'a> {
481 GetBrowserSamplingProfileReturnsBuilder {
482 profile: profile,
483 }
484 }
485 pub fn profile(&self) -> &SamplingProfile<'a> { &self.profile }
486}
487
488
489pub struct GetBrowserSamplingProfileReturnsBuilder<'a> {
490 profile: SamplingProfile<'a>,
491}
492
493impl<'a> GetBrowserSamplingProfileReturnsBuilder<'a> {
494 pub fn build(self) -> GetBrowserSamplingProfileReturns<'a> {
495 GetBrowserSamplingProfileReturns {
496 profile: self.profile,
497 }
498 }
499}
500
501#[derive(Debug, Clone, Serialize, Deserialize, Default)]
502pub struct GetBrowserSamplingProfileParams {}
503
504impl GetBrowserSamplingProfileParams { pub const METHOD: &'static str = "Memory.getBrowserSamplingProfile"; }
505
506impl<'a> crate::CdpCommand<'a> for GetBrowserSamplingProfileParams {
507 const METHOD: &'static str = "Memory.getBrowserSamplingProfile";
508 type Response = GetBrowserSamplingProfileReturns<'a>;
509}
510
511#[derive(Debug, Clone, Serialize, Deserialize, Default)]
515#[serde(rename_all = "camelCase")]
516pub struct GetSamplingProfileReturns<'a> {
517 profile: SamplingProfile<'a>,
518}
519
520impl<'a> GetSamplingProfileReturns<'a> {
521 pub fn builder(profile: SamplingProfile<'a>) -> GetSamplingProfileReturnsBuilder<'a> {
522 GetSamplingProfileReturnsBuilder {
523 profile: profile,
524 }
525 }
526 pub fn profile(&self) -> &SamplingProfile<'a> { &self.profile }
527}
528
529
530pub struct GetSamplingProfileReturnsBuilder<'a> {
531 profile: SamplingProfile<'a>,
532}
533
534impl<'a> GetSamplingProfileReturnsBuilder<'a> {
535 pub fn build(self) -> GetSamplingProfileReturns<'a> {
536 GetSamplingProfileReturns {
537 profile: self.profile,
538 }
539 }
540}
541
542#[derive(Debug, Clone, Serialize, Deserialize, Default)]
543pub struct GetSamplingProfileParams {}
544
545impl GetSamplingProfileParams { pub const METHOD: &'static str = "Memory.getSamplingProfile"; }
546
547impl<'a> crate::CdpCommand<'a> for GetSamplingProfileParams {
548 const METHOD: &'static str = "Memory.getSamplingProfile";
549 type Response = GetSamplingProfileReturns<'a>;
550}