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> {
35 SamplingProfileNodeBuilder {
36 size: size,
37 total: total,
38 stack: stack,
39 }
40 }
41 pub fn size(&self) -> f64 { self.size }
43 pub fn total(&self) -> f64 { self.total }
45 pub fn stack(&self) -> &[Cow<'a, str>] { &self.stack }
47}
48
49
50pub struct SamplingProfileNodeBuilder<'a> {
51 size: f64,
52 total: f64,
53 stack: Vec<Cow<'a, str>>,
54}
55
56impl<'a> SamplingProfileNodeBuilder<'a> {
57 pub fn build(self) -> SamplingProfileNode<'a> {
58 SamplingProfileNode {
59 size: self.size,
60 total: self.total,
61 stack: self.stack,
62 }
63 }
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize, Default)]
69#[serde(rename_all = "camelCase")]
70pub struct SamplingProfile<'a> {
71 samples: Vec<SamplingProfileNode<'a>>,
72 modules: Vec<Module<'a>>,
73}
74
75impl<'a> SamplingProfile<'a> {
76 pub fn builder(samples: Vec<SamplingProfileNode<'a>>, modules: Vec<Module<'a>>) -> SamplingProfileBuilder<'a> {
80 SamplingProfileBuilder {
81 samples: samples,
82 modules: modules,
83 }
84 }
85 pub fn samples(&self) -> &[SamplingProfileNode<'a>] { &self.samples }
86 pub fn modules(&self) -> &[Module<'a>] { &self.modules }
87}
88
89
90pub struct SamplingProfileBuilder<'a> {
91 samples: Vec<SamplingProfileNode<'a>>,
92 modules: Vec<Module<'a>>,
93}
94
95impl<'a> SamplingProfileBuilder<'a> {
96 pub fn build(self) -> SamplingProfile<'a> {
97 SamplingProfile {
98 samples: self.samples,
99 modules: self.modules,
100 }
101 }
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize, Default)]
107#[serde(rename_all = "camelCase")]
108pub struct Module<'a> {
109 name: Cow<'a, str>,
111 uuid: Cow<'a, str>,
113 #[serde(rename = "baseAddress")]
116 base_address: Cow<'a, str>,
117 size: f64,
119}
120
121impl<'a> Module<'a> {
122 pub fn builder(name: impl Into<Cow<'a, str>>, uuid: impl Into<Cow<'a, str>>, base_address: impl Into<Cow<'a, str>>, size: f64) -> ModuleBuilder<'a> {
128 ModuleBuilder {
129 name: name.into(),
130 uuid: uuid.into(),
131 base_address: base_address.into(),
132 size: size,
133 }
134 }
135 pub fn name(&self) -> &str { self.name.as_ref() }
137 pub fn uuid(&self) -> &str { self.uuid.as_ref() }
139 pub fn base_address(&self) -> &str { self.base_address.as_ref() }
142 pub fn size(&self) -> f64 { self.size }
144}
145
146
147pub struct ModuleBuilder<'a> {
148 name: Cow<'a, str>,
149 uuid: Cow<'a, str>,
150 base_address: Cow<'a, str>,
151 size: f64,
152}
153
154impl<'a> ModuleBuilder<'a> {
155 pub fn build(self) -> Module<'a> {
156 Module {
157 name: self.name,
158 uuid: self.uuid,
159 base_address: self.base_address,
160 size: self.size,
161 }
162 }
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize, Default)]
168#[serde(rename_all = "camelCase")]
169pub struct DOMCounter<'a> {
170 name: Cow<'a, str>,
173 count: u64,
175}
176
177impl<'a> DOMCounter<'a> {
178 pub fn builder(name: impl Into<Cow<'a, str>>, count: u64) -> DOMCounterBuilder<'a> {
182 DOMCounterBuilder {
183 name: name.into(),
184 count: count,
185 }
186 }
187 pub fn name(&self) -> &str { self.name.as_ref() }
190 pub fn count(&self) -> u64 { self.count }
192}
193
194
195pub struct DOMCounterBuilder<'a> {
196 name: Cow<'a, str>,
197 count: u64,
198}
199
200impl<'a> DOMCounterBuilder<'a> {
201 pub fn build(self) -> DOMCounter<'a> {
202 DOMCounter {
203 name: self.name,
204 count: self.count,
205 }
206 }
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize, Default)]
212#[serde(rename_all = "camelCase")]
213pub struct GetDOMCountersReturns {
214 documents: i64,
215 nodes: i64,
216 #[serde(rename = "jsEventListeners")]
217 js_event_listeners: i64,
218}
219
220impl GetDOMCountersReturns {
221 pub fn builder(documents: i64, nodes: i64, js_event_listeners: i64) -> GetDOMCountersReturnsBuilder {
226 GetDOMCountersReturnsBuilder {
227 documents: documents,
228 nodes: nodes,
229 js_event_listeners: js_event_listeners,
230 }
231 }
232 pub fn documents(&self) -> i64 { self.documents }
233 pub fn nodes(&self) -> i64 { self.nodes }
234 pub fn js_event_listeners(&self) -> i64 { self.js_event_listeners }
235}
236
237
238pub struct GetDOMCountersReturnsBuilder {
239 documents: i64,
240 nodes: i64,
241 js_event_listeners: i64,
242}
243
244impl GetDOMCountersReturnsBuilder {
245 pub fn build(self) -> GetDOMCountersReturns {
246 GetDOMCountersReturns {
247 documents: self.documents,
248 nodes: self.nodes,
249 js_event_listeners: self.js_event_listeners,
250 }
251 }
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize, Default)]
255pub struct GetDOMCountersParams {}
256
257impl GetDOMCountersParams { pub const METHOD: &'static str = "Memory.getDOMCounters"; }
258
259impl<'a> crate::CdpCommand<'a> for GetDOMCountersParams {
260 const METHOD: &'static str = "Memory.getDOMCounters";
261 type Response = GetDOMCountersReturns;
262}
263
264#[derive(Debug, Clone, Serialize, Deserialize, Default)]
267#[serde(rename_all = "camelCase")]
268pub struct GetDOMCountersForLeakDetectionReturns<'a> {
269 counters: Vec<DOMCounter<'a>>,
271}
272
273impl<'a> GetDOMCountersForLeakDetectionReturns<'a> {
274 pub fn builder(counters: Vec<DOMCounter<'a>>) -> GetDOMCountersForLeakDetectionReturnsBuilder<'a> {
277 GetDOMCountersForLeakDetectionReturnsBuilder {
278 counters: counters,
279 }
280 }
281 pub fn counters(&self) -> &[DOMCounter<'a>] { &self.counters }
283}
284
285
286pub struct GetDOMCountersForLeakDetectionReturnsBuilder<'a> {
287 counters: Vec<DOMCounter<'a>>,
288}
289
290impl<'a> GetDOMCountersForLeakDetectionReturnsBuilder<'a> {
291 pub fn build(self) -> GetDOMCountersForLeakDetectionReturns<'a> {
292 GetDOMCountersForLeakDetectionReturns {
293 counters: self.counters,
294 }
295 }
296}
297
298#[derive(Debug, Clone, Serialize, Deserialize, Default)]
299pub struct GetDOMCountersForLeakDetectionParams {}
300
301impl GetDOMCountersForLeakDetectionParams { pub const METHOD: &'static str = "Memory.getDOMCountersForLeakDetection"; }
302
303impl<'a> crate::CdpCommand<'a> for GetDOMCountersForLeakDetectionParams {
304 const METHOD: &'static str = "Memory.getDOMCountersForLeakDetection";
305 type Response = GetDOMCountersForLeakDetectionReturns<'a>;
306}
307
308#[derive(Debug, Clone, Serialize, Deserialize, Default)]
309pub struct PrepareForLeakDetectionParams {}
310
311impl PrepareForLeakDetectionParams { pub const METHOD: &'static str = "Memory.prepareForLeakDetection"; }
312
313impl<'a> crate::CdpCommand<'a> for PrepareForLeakDetectionParams {
314 const METHOD: &'static str = "Memory.prepareForLeakDetection";
315 type Response = crate::EmptyReturns;
316}
317
318#[derive(Debug, Clone, Serialize, Deserialize, Default)]
319pub struct ForciblyPurgeJavaScriptMemoryParams {}
320
321impl ForciblyPurgeJavaScriptMemoryParams { pub const METHOD: &'static str = "Memory.forciblyPurgeJavaScriptMemory"; }
322
323impl<'a> crate::CdpCommand<'a> for ForciblyPurgeJavaScriptMemoryParams {
324 const METHOD: &'static str = "Memory.forciblyPurgeJavaScriptMemory";
325 type Response = crate::EmptyReturns;
326}
327
328#[derive(Debug, Clone, Serialize, Deserialize, Default)]
331#[serde(rename_all = "camelCase")]
332pub struct SetPressureNotificationsSuppressedParams {
333 suppressed: bool,
335}
336
337impl SetPressureNotificationsSuppressedParams {
338 pub fn builder(suppressed: bool) -> SetPressureNotificationsSuppressedParamsBuilder {
341 SetPressureNotificationsSuppressedParamsBuilder {
342 suppressed: suppressed,
343 }
344 }
345 pub fn suppressed(&self) -> bool { self.suppressed }
347}
348
349
350pub struct SetPressureNotificationsSuppressedParamsBuilder {
351 suppressed: bool,
352}
353
354impl SetPressureNotificationsSuppressedParamsBuilder {
355 pub fn build(self) -> SetPressureNotificationsSuppressedParams {
356 SetPressureNotificationsSuppressedParams {
357 suppressed: self.suppressed,
358 }
359 }
360}
361
362impl SetPressureNotificationsSuppressedParams { pub const METHOD: &'static str = "Memory.setPressureNotificationsSuppressed"; }
363
364impl<'a> crate::CdpCommand<'a> for SetPressureNotificationsSuppressedParams {
365 const METHOD: &'static str = "Memory.setPressureNotificationsSuppressed";
366 type Response = crate::EmptyReturns;
367}
368
369#[derive(Debug, Clone, Serialize, Deserialize, Default)]
372#[serde(rename_all = "camelCase")]
373pub struct SimulatePressureNotificationParams {
374 level: PressureLevel,
376}
377
378impl SimulatePressureNotificationParams {
379 pub fn builder(level: impl Into<PressureLevel>) -> SimulatePressureNotificationParamsBuilder {
382 SimulatePressureNotificationParamsBuilder {
383 level: level.into(),
384 }
385 }
386 pub fn level(&self) -> &PressureLevel { &self.level }
388}
389
390
391pub struct SimulatePressureNotificationParamsBuilder {
392 level: PressureLevel,
393}
394
395impl SimulatePressureNotificationParamsBuilder {
396 pub fn build(self) -> SimulatePressureNotificationParams {
397 SimulatePressureNotificationParams {
398 level: self.level,
399 }
400 }
401}
402
403impl SimulatePressureNotificationParams { pub const METHOD: &'static str = "Memory.simulatePressureNotification"; }
404
405impl<'a> crate::CdpCommand<'a> for SimulatePressureNotificationParams {
406 const METHOD: &'static str = "Memory.simulatePressureNotification";
407 type Response = crate::EmptyReturns;
408}
409
410#[derive(Debug, Clone, Serialize, Deserialize, Default)]
413#[serde(rename_all = "camelCase")]
414pub struct StartSamplingParams {
415 #[serde(skip_serializing_if = "Option::is_none", rename = "samplingInterval")]
417 sampling_interval: Option<i64>,
418 #[serde(skip_serializing_if = "Option::is_none", rename = "suppressRandomness")]
420 suppress_randomness: Option<bool>,
421}
422
423impl StartSamplingParams {
424 pub fn builder() -> StartSamplingParamsBuilder {
426 StartSamplingParamsBuilder {
427 sampling_interval: None,
428 suppress_randomness: None,
429 }
430 }
431 pub fn sampling_interval(&self) -> Option<i64> { self.sampling_interval }
433 pub fn suppress_randomness(&self) -> Option<bool> { self.suppress_randomness }
435}
436
437#[derive(Default)]
438pub struct StartSamplingParamsBuilder {
439 sampling_interval: Option<i64>,
440 suppress_randomness: Option<bool>,
441}
442
443impl StartSamplingParamsBuilder {
444 pub fn sampling_interval(mut self, sampling_interval: i64) -> Self { self.sampling_interval = Some(sampling_interval); self }
446 pub fn suppress_randomness(mut self, suppress_randomness: bool) -> Self { self.suppress_randomness = Some(suppress_randomness); self }
448 pub fn build(self) -> StartSamplingParams {
449 StartSamplingParams {
450 sampling_interval: self.sampling_interval,
451 suppress_randomness: self.suppress_randomness,
452 }
453 }
454}
455
456impl StartSamplingParams { pub const METHOD: &'static str = "Memory.startSampling"; }
457
458impl<'a> crate::CdpCommand<'a> for StartSamplingParams {
459 const METHOD: &'static str = "Memory.startSampling";
460 type Response = crate::EmptyReturns;
461}
462
463#[derive(Debug, Clone, Serialize, Deserialize, Default)]
464pub struct StopSamplingParams {}
465
466impl StopSamplingParams { pub const METHOD: &'static str = "Memory.stopSampling"; }
467
468impl<'a> crate::CdpCommand<'a> for StopSamplingParams {
469 const METHOD: &'static str = "Memory.stopSampling";
470 type Response = crate::EmptyReturns;
471}
472
473#[derive(Debug, Clone, Serialize, Deserialize, Default)]
477#[serde(rename_all = "camelCase")]
478pub struct GetAllTimeSamplingProfileReturns<'a> {
479 profile: SamplingProfile<'a>,
480}
481
482impl<'a> GetAllTimeSamplingProfileReturns<'a> {
483 pub fn builder(profile: SamplingProfile<'a>) -> GetAllTimeSamplingProfileReturnsBuilder<'a> {
486 GetAllTimeSamplingProfileReturnsBuilder {
487 profile: profile,
488 }
489 }
490 pub fn profile(&self) -> &SamplingProfile<'a> { &self.profile }
491}
492
493
494pub struct GetAllTimeSamplingProfileReturnsBuilder<'a> {
495 profile: SamplingProfile<'a>,
496}
497
498impl<'a> GetAllTimeSamplingProfileReturnsBuilder<'a> {
499 pub fn build(self) -> GetAllTimeSamplingProfileReturns<'a> {
500 GetAllTimeSamplingProfileReturns {
501 profile: self.profile,
502 }
503 }
504}
505
506#[derive(Debug, Clone, Serialize, Deserialize, Default)]
507pub struct GetAllTimeSamplingProfileParams {}
508
509impl GetAllTimeSamplingProfileParams { pub const METHOD: &'static str = "Memory.getAllTimeSamplingProfile"; }
510
511impl<'a> crate::CdpCommand<'a> for GetAllTimeSamplingProfileParams {
512 const METHOD: &'static str = "Memory.getAllTimeSamplingProfile";
513 type Response = GetAllTimeSamplingProfileReturns<'a>;
514}
515
516#[derive(Debug, Clone, Serialize, Deserialize, Default)]
520#[serde(rename_all = "camelCase")]
521pub struct GetBrowserSamplingProfileReturns<'a> {
522 profile: SamplingProfile<'a>,
523}
524
525impl<'a> GetBrowserSamplingProfileReturns<'a> {
526 pub fn builder(profile: SamplingProfile<'a>) -> GetBrowserSamplingProfileReturnsBuilder<'a> {
529 GetBrowserSamplingProfileReturnsBuilder {
530 profile: profile,
531 }
532 }
533 pub fn profile(&self) -> &SamplingProfile<'a> { &self.profile }
534}
535
536
537pub struct GetBrowserSamplingProfileReturnsBuilder<'a> {
538 profile: SamplingProfile<'a>,
539}
540
541impl<'a> GetBrowserSamplingProfileReturnsBuilder<'a> {
542 pub fn build(self) -> GetBrowserSamplingProfileReturns<'a> {
543 GetBrowserSamplingProfileReturns {
544 profile: self.profile,
545 }
546 }
547}
548
549#[derive(Debug, Clone, Serialize, Deserialize, Default)]
550pub struct GetBrowserSamplingProfileParams {}
551
552impl GetBrowserSamplingProfileParams { pub const METHOD: &'static str = "Memory.getBrowserSamplingProfile"; }
553
554impl<'a> crate::CdpCommand<'a> for GetBrowserSamplingProfileParams {
555 const METHOD: &'static str = "Memory.getBrowserSamplingProfile";
556 type Response = GetBrowserSamplingProfileReturns<'a>;
557}
558
559#[derive(Debug, Clone, Serialize, Deserialize, Default)]
563#[serde(rename_all = "camelCase")]
564pub struct GetSamplingProfileReturns<'a> {
565 profile: SamplingProfile<'a>,
566}
567
568impl<'a> GetSamplingProfileReturns<'a> {
569 pub fn builder(profile: SamplingProfile<'a>) -> GetSamplingProfileReturnsBuilder<'a> {
572 GetSamplingProfileReturnsBuilder {
573 profile: profile,
574 }
575 }
576 pub fn profile(&self) -> &SamplingProfile<'a> { &self.profile }
577}
578
579
580pub struct GetSamplingProfileReturnsBuilder<'a> {
581 profile: SamplingProfile<'a>,
582}
583
584impl<'a> GetSamplingProfileReturnsBuilder<'a> {
585 pub fn build(self) -> GetSamplingProfileReturns<'a> {
586 GetSamplingProfileReturns {
587 profile: self.profile,
588 }
589 }
590}
591
592#[derive(Debug, Clone, Serialize, Deserialize, Default)]
593pub struct GetSamplingProfileParams {}
594
595impl GetSamplingProfileParams { pub const METHOD: &'static str = "Memory.getSamplingProfile"; }
596
597impl<'a> crate::CdpCommand<'a> for GetSamplingProfileParams {
598 const METHOD: &'static str = "Memory.getSamplingProfile";
599 type Response = GetSamplingProfileReturns<'a>;
600}