Skip to main content

js_protocol/runtime/
mod.rs

1//! Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
2//! Evaluation results are returned as mirror object that expose object type, string representation
3//! and unique identifier that can be used for further object reference. Original objects are
4//! maintained in memory unless they are either explicitly released or are released along with the
5//! other objects in their object group.
6
7
8use serde::{Serialize, Deserialize};
9use serde_json::Value as JsonValue;
10use std::borrow::Cow;
11
12/// Unique script identifier.
13
14pub type ScriptId<'a> = Cow<'a, str>;
15
16/// Represents options for serialization. Overrides 'generatePreview' and 'returnByValue'.
17
18#[derive(Debug, Clone, Serialize, Deserialize, Default)]
19#[serde(rename_all = "camelCase")]
20pub struct SerializationOptions<'a> {
21    serialization: Cow<'a, str>,
22    /// Deep serialization depth. Default is full depth. Respected only in 'deep' serialization mode.
23    #[serde(skip_serializing_if = "Option::is_none", rename = "maxDepth")]
24    max_depth: Option<i64>,
25    /// Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM
26    /// serialization via 'maxNodeDepth: integer' and 'includeShadowTree: "none" | "open" | "all"'.
27    /// Values can be only of type string or integer.
28    #[serde(skip_serializing_if = "Option::is_none", rename = "additionalParameters")]
29    additional_parameters: Option<serde_json::Map<String, JsonValue>>,
30}
31
32impl<'a> SerializationOptions<'a> {
33    /// Creates a builder for this type with the required parameters:
34    /// * `serialization`: 
35    pub fn builder(serialization: impl Into<Cow<'a, str>>) -> SerializationOptionsBuilder<'a> {
36        SerializationOptionsBuilder {
37            serialization: serialization.into(),
38            max_depth: None,
39            additional_parameters: None,
40        }
41    }
42    pub fn serialization(&self) -> &str { self.serialization.as_ref() }
43    /// Deep serialization depth. Default is full depth. Respected only in 'deep' serialization mode.
44    pub fn max_depth(&self) -> Option<i64> { self.max_depth }
45    /// Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM
46    /// serialization via 'maxNodeDepth: integer' and 'includeShadowTree: "none" | "open" | "all"'.
47    /// Values can be only of type string or integer.
48    pub fn additional_parameters(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.additional_parameters.as_ref() }
49}
50
51
52pub struct SerializationOptionsBuilder<'a> {
53    serialization: Cow<'a, str>,
54    max_depth: Option<i64>,
55    additional_parameters: Option<serde_json::Map<String, JsonValue>>,
56}
57
58impl<'a> SerializationOptionsBuilder<'a> {
59    /// Deep serialization depth. Default is full depth. Respected only in 'deep' serialization mode.
60    pub fn max_depth(mut self, max_depth: i64) -> Self { self.max_depth = Some(max_depth); self }
61    /// Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM
62    /// serialization via 'maxNodeDepth: integer' and 'includeShadowTree: "none" | "open" | "all"'.
63    /// Values can be only of type string or integer.
64    pub fn additional_parameters(mut self, additional_parameters: serde_json::Map<String, JsonValue>) -> Self { self.additional_parameters = Some(additional_parameters); self }
65    pub fn build(self) -> SerializationOptions<'a> {
66        SerializationOptions {
67            serialization: self.serialization,
68            max_depth: self.max_depth,
69            additional_parameters: self.additional_parameters,
70        }
71    }
72}
73
74/// Represents deep serialized value.
75
76#[derive(Debug, Clone, Serialize, Deserialize, Default)]
77#[serde(rename_all = "camelCase")]
78pub struct DeepSerializedValue<'a> {
79    #[serde(rename = "type")]
80    type_: Cow<'a, str>,
81    #[serde(skip_serializing_if = "Option::is_none")]
82    value: Option<JsonValue>,
83    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
84    object_id: Option<Cow<'a, str>>,
85    /// Set if value reference met more then once during serialization. In such
86    /// case, value is provided only to one of the serialized values. Unique
87    /// per value in the scope of one CDP call.
88    #[serde(skip_serializing_if = "Option::is_none", rename = "weakLocalObjectReference")]
89    weak_local_object_reference: Option<i64>,
90}
91
92impl<'a> DeepSerializedValue<'a> {
93    /// Creates a builder for this type with the required parameters:
94    /// * `type_`: 
95    pub fn builder(type_: impl Into<Cow<'a, str>>) -> DeepSerializedValueBuilder<'a> {
96        DeepSerializedValueBuilder {
97            type_: type_.into(),
98            value: None,
99            object_id: None,
100            weak_local_object_reference: None,
101        }
102    }
103    pub fn type_(&self) -> &str { self.type_.as_ref() }
104    pub fn value(&self) -> Option<&JsonValue> { self.value.as_ref() }
105    pub fn object_id(&self) -> Option<&str> { self.object_id.as_deref() }
106    /// Set if value reference met more then once during serialization. In such
107    /// case, value is provided only to one of the serialized values. Unique
108    /// per value in the scope of one CDP call.
109    pub fn weak_local_object_reference(&self) -> Option<i64> { self.weak_local_object_reference }
110}
111
112
113pub struct DeepSerializedValueBuilder<'a> {
114    type_: Cow<'a, str>,
115    value: Option<JsonValue>,
116    object_id: Option<Cow<'a, str>>,
117    weak_local_object_reference: Option<i64>,
118}
119
120impl<'a> DeepSerializedValueBuilder<'a> {
121    pub fn value(mut self, value: JsonValue) -> Self { self.value = Some(value); self }
122    pub fn object_id(mut self, object_id: impl Into<Cow<'a, str>>) -> Self { self.object_id = Some(object_id.into()); self }
123    /// Set if value reference met more then once during serialization. In such
124    /// case, value is provided only to one of the serialized values. Unique
125    /// per value in the scope of one CDP call.
126    pub fn weak_local_object_reference(mut self, weak_local_object_reference: i64) -> Self { self.weak_local_object_reference = Some(weak_local_object_reference); self }
127    pub fn build(self) -> DeepSerializedValue<'a> {
128        DeepSerializedValue {
129            type_: self.type_,
130            value: self.value,
131            object_id: self.object_id,
132            weak_local_object_reference: self.weak_local_object_reference,
133        }
134    }
135}
136
137/// Unique object identifier.
138
139pub type RemoteObjectId<'a> = Cow<'a, str>;
140
141/// Primitive value which cannot be JSON-stringified. Includes values '-0', 'NaN', 'Infinity',
142/// '-Infinity', and bigint literals.
143
144pub type UnserializableValue<'a> = Cow<'a, str>;
145
146/// Mirror object referencing original JavaScript object.
147
148#[derive(Debug, Clone, Serialize, Deserialize, Default)]
149#[serde(rename_all = "camelCase")]
150pub struct RemoteObject<'a> {
151    /// Object type.
152    #[serde(rename = "type")]
153    type_: Cow<'a, str>,
154    /// Object subtype hint. Specified for 'object' type values only.
155    /// NOTE: If you change anything here, make sure to also update
156    /// 'subtype' in 'ObjectPreview' and 'PropertyPreview' below.
157    #[serde(skip_serializing_if = "Option::is_none")]
158    subtype: Option<Cow<'a, str>>,
159    /// Object class (constructor) name. Specified for 'object' type values only.
160    #[serde(skip_serializing_if = "Option::is_none", rename = "className")]
161    class_name: Option<Cow<'a, str>>,
162    /// Remote object value in case of primitive values or JSON values (if it was requested).
163    #[serde(skip_serializing_if = "Option::is_none")]
164    value: Option<JsonValue>,
165    /// Primitive value which can not be JSON-stringified does not have 'value', but gets this
166    /// property.
167    #[serde(skip_serializing_if = "Option::is_none", rename = "unserializableValue")]
168    unserializable_value: Option<UnserializableValue<'a>>,
169    /// String representation of the object.
170    #[serde(skip_serializing_if = "Option::is_none")]
171    description: Option<Cow<'a, str>>,
172    /// Deep serialized value.
173    #[serde(skip_serializing_if = "Option::is_none", rename = "deepSerializedValue")]
174    deep_serialized_value: Option<DeepSerializedValue<'a>>,
175    /// Unique object identifier (for non-primitive values).
176    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
177    object_id: Option<RemoteObjectId<'a>>,
178    /// Preview containing abbreviated property values. Specified for 'object' type values only.
179    #[serde(skip_serializing_if = "Option::is_none")]
180    preview: Option<ObjectPreview<'a>>,
181    #[serde(skip_serializing_if = "Option::is_none", rename = "customPreview")]
182    custom_preview: Option<CustomPreview<'a>>,
183}
184
185impl<'a> RemoteObject<'a> {
186    /// Creates a builder for this type with the required parameters:
187    /// * `type_`: Object type.
188    pub fn builder(type_: impl Into<Cow<'a, str>>) -> RemoteObjectBuilder<'a> {
189        RemoteObjectBuilder {
190            type_: type_.into(),
191            subtype: None,
192            class_name: None,
193            value: None,
194            unserializable_value: None,
195            description: None,
196            deep_serialized_value: None,
197            object_id: None,
198            preview: None,
199            custom_preview: None,
200        }
201    }
202    /// Object type.
203    pub fn type_(&self) -> &str { self.type_.as_ref() }
204    /// Object subtype hint. Specified for 'object' type values only.
205    /// NOTE: If you change anything here, make sure to also update
206    /// 'subtype' in 'ObjectPreview' and 'PropertyPreview' below.
207    pub fn subtype(&self) -> Option<&str> { self.subtype.as_deref() }
208    /// Object class (constructor) name. Specified for 'object' type values only.
209    pub fn class_name(&self) -> Option<&str> { self.class_name.as_deref() }
210    /// Remote object value in case of primitive values or JSON values (if it was requested).
211    pub fn value(&self) -> Option<&JsonValue> { self.value.as_ref() }
212    /// Primitive value which can not be JSON-stringified does not have 'value', but gets this
213    /// property.
214    pub fn unserializable_value(&self) -> Option<&UnserializableValue<'a>> { self.unserializable_value.as_ref() }
215    /// String representation of the object.
216    pub fn description(&self) -> Option<&str> { self.description.as_deref() }
217    /// Deep serialized value.
218    pub fn deep_serialized_value(&self) -> Option<&DeepSerializedValue<'a>> { self.deep_serialized_value.as_ref() }
219    /// Unique object identifier (for non-primitive values).
220    pub fn object_id(&self) -> Option<&RemoteObjectId<'a>> { self.object_id.as_ref() }
221    /// Preview containing abbreviated property values. Specified for 'object' type values only.
222    pub fn preview(&self) -> Option<&ObjectPreview<'a>> { self.preview.as_ref() }
223    pub fn custom_preview(&self) -> Option<&CustomPreview<'a>> { self.custom_preview.as_ref() }
224}
225
226
227pub struct RemoteObjectBuilder<'a> {
228    type_: Cow<'a, str>,
229    subtype: Option<Cow<'a, str>>,
230    class_name: Option<Cow<'a, str>>,
231    value: Option<JsonValue>,
232    unserializable_value: Option<UnserializableValue<'a>>,
233    description: Option<Cow<'a, str>>,
234    deep_serialized_value: Option<DeepSerializedValue<'a>>,
235    object_id: Option<RemoteObjectId<'a>>,
236    preview: Option<ObjectPreview<'a>>,
237    custom_preview: Option<CustomPreview<'a>>,
238}
239
240impl<'a> RemoteObjectBuilder<'a> {
241    /// Object subtype hint. Specified for 'object' type values only.
242    /// NOTE: If you change anything here, make sure to also update
243    /// 'subtype' in 'ObjectPreview' and 'PropertyPreview' below.
244    pub fn subtype(mut self, subtype: impl Into<Cow<'a, str>>) -> Self { self.subtype = Some(subtype.into()); self }
245    /// Object class (constructor) name. Specified for 'object' type values only.
246    pub fn class_name(mut self, class_name: impl Into<Cow<'a, str>>) -> Self { self.class_name = Some(class_name.into()); self }
247    /// Remote object value in case of primitive values or JSON values (if it was requested).
248    pub fn value(mut self, value: JsonValue) -> Self { self.value = Some(value); self }
249    /// Primitive value which can not be JSON-stringified does not have 'value', but gets this
250    /// property.
251    pub fn unserializable_value(mut self, unserializable_value: impl Into<UnserializableValue<'a>>) -> Self { self.unserializable_value = Some(unserializable_value.into()); self }
252    /// String representation of the object.
253    pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self { self.description = Some(description.into()); self }
254    /// Deep serialized value.
255    pub fn deep_serialized_value(mut self, deep_serialized_value: DeepSerializedValue<'a>) -> Self { self.deep_serialized_value = Some(deep_serialized_value); self }
256    /// Unique object identifier (for non-primitive values).
257    pub fn object_id(mut self, object_id: impl Into<RemoteObjectId<'a>>) -> Self { self.object_id = Some(object_id.into()); self }
258    /// Preview containing abbreviated property values. Specified for 'object' type values only.
259    pub fn preview(mut self, preview: ObjectPreview<'a>) -> Self { self.preview = Some(preview); self }
260    pub fn custom_preview(mut self, custom_preview: CustomPreview<'a>) -> Self { self.custom_preview = Some(custom_preview); self }
261    pub fn build(self) -> RemoteObject<'a> {
262        RemoteObject {
263            type_: self.type_,
264            subtype: self.subtype,
265            class_name: self.class_name,
266            value: self.value,
267            unserializable_value: self.unserializable_value,
268            description: self.description,
269            deep_serialized_value: self.deep_serialized_value,
270            object_id: self.object_id,
271            preview: self.preview,
272            custom_preview: self.custom_preview,
273        }
274    }
275}
276
277
278#[derive(Debug, Clone, Serialize, Deserialize, Default)]
279#[serde(rename_all = "camelCase")]
280pub struct CustomPreview<'a> {
281    /// The JSON-stringified result of formatter.header(object, config) call.
282    /// It contains json ML array that represents RemoteObject.
283    header: Cow<'a, str>,
284    /// If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
285    /// contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
286    /// The result value is json ML array.
287    #[serde(skip_serializing_if = "Option::is_none", rename = "bodyGetterId")]
288    body_getter_id: Option<RemoteObjectId<'a>>,
289}
290
291impl<'a> CustomPreview<'a> {
292    /// Creates a builder for this type with the required parameters:
293    /// * `header`: The JSON-stringified result of formatter.header(object, config) call. It contains json ML array that represents RemoteObject.
294    pub fn builder(header: impl Into<Cow<'a, str>>) -> CustomPreviewBuilder<'a> {
295        CustomPreviewBuilder {
296            header: header.into(),
297            body_getter_id: None,
298        }
299    }
300    /// The JSON-stringified result of formatter.header(object, config) call.
301    /// It contains json ML array that represents RemoteObject.
302    pub fn header(&self) -> &str { self.header.as_ref() }
303    /// If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
304    /// contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
305    /// The result value is json ML array.
306    pub fn body_getter_id(&self) -> Option<&RemoteObjectId<'a>> { self.body_getter_id.as_ref() }
307}
308
309
310pub struct CustomPreviewBuilder<'a> {
311    header: Cow<'a, str>,
312    body_getter_id: Option<RemoteObjectId<'a>>,
313}
314
315impl<'a> CustomPreviewBuilder<'a> {
316    /// If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
317    /// contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
318    /// The result value is json ML array.
319    pub fn body_getter_id(mut self, body_getter_id: impl Into<RemoteObjectId<'a>>) -> Self { self.body_getter_id = Some(body_getter_id.into()); self }
320    pub fn build(self) -> CustomPreview<'a> {
321        CustomPreview {
322            header: self.header,
323            body_getter_id: self.body_getter_id,
324        }
325    }
326}
327
328/// Object containing abbreviated remote object value.
329
330#[derive(Debug, Clone, Serialize, Deserialize, Default)]
331#[serde(rename_all = "camelCase")]
332pub struct ObjectPreview<'a> {
333    /// Object type.
334    #[serde(rename = "type")]
335    type_: Cow<'a, str>,
336    /// Object subtype hint. Specified for 'object' type values only.
337    #[serde(skip_serializing_if = "Option::is_none")]
338    subtype: Option<Cow<'a, str>>,
339    /// String representation of the object.
340    #[serde(skip_serializing_if = "Option::is_none")]
341    description: Option<Cow<'a, str>>,
342    /// True iff some of the properties or entries of the original object did not fit.
343    overflow: bool,
344    /// List of the properties.
345    properties: Vec<PropertyPreview<'a>>,
346    /// List of the entries. Specified for 'map' and 'set' subtype values only.
347    #[serde(skip_serializing_if = "Option::is_none")]
348    entries: Option<Vec<EntryPreview<'a>>>,
349}
350
351impl<'a> ObjectPreview<'a> {
352    /// Creates a builder for this type with the required parameters:
353    /// * `type_`: Object type.
354    /// * `overflow`: True iff some of the properties or entries of the original object did not fit.
355    /// * `properties`: List of the properties.
356    pub fn builder(type_: impl Into<Cow<'a, str>>, overflow: bool, properties: Vec<PropertyPreview<'a>>) -> ObjectPreviewBuilder<'a> {
357        ObjectPreviewBuilder {
358            type_: type_.into(),
359            subtype: None,
360            description: None,
361            overflow: overflow,
362            properties: properties,
363            entries: None,
364        }
365    }
366    /// Object type.
367    pub fn type_(&self) -> &str { self.type_.as_ref() }
368    /// Object subtype hint. Specified for 'object' type values only.
369    pub fn subtype(&self) -> Option<&str> { self.subtype.as_deref() }
370    /// String representation of the object.
371    pub fn description(&self) -> Option<&str> { self.description.as_deref() }
372    /// True iff some of the properties or entries of the original object did not fit.
373    pub fn overflow(&self) -> bool { self.overflow }
374    /// List of the properties.
375    pub fn properties(&self) -> &[PropertyPreview<'a>] { &self.properties }
376    /// List of the entries. Specified for 'map' and 'set' subtype values only.
377    pub fn entries(&self) -> Option<&[EntryPreview<'a>]> { self.entries.as_deref() }
378}
379
380
381pub struct ObjectPreviewBuilder<'a> {
382    type_: Cow<'a, str>,
383    subtype: Option<Cow<'a, str>>,
384    description: Option<Cow<'a, str>>,
385    overflow: bool,
386    properties: Vec<PropertyPreview<'a>>,
387    entries: Option<Vec<EntryPreview<'a>>>,
388}
389
390impl<'a> ObjectPreviewBuilder<'a> {
391    /// Object subtype hint. Specified for 'object' type values only.
392    pub fn subtype(mut self, subtype: impl Into<Cow<'a, str>>) -> Self { self.subtype = Some(subtype.into()); self }
393    /// String representation of the object.
394    pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self { self.description = Some(description.into()); self }
395    /// List of the entries. Specified for 'map' and 'set' subtype values only.
396    pub fn entries(mut self, entries: Vec<EntryPreview<'a>>) -> Self { self.entries = Some(entries); self }
397    pub fn build(self) -> ObjectPreview<'a> {
398        ObjectPreview {
399            type_: self.type_,
400            subtype: self.subtype,
401            description: self.description,
402            overflow: self.overflow,
403            properties: self.properties,
404            entries: self.entries,
405        }
406    }
407}
408
409
410#[derive(Debug, Clone, Serialize, Deserialize, Default)]
411#[serde(rename_all = "camelCase")]
412pub struct PropertyPreview<'a> {
413    /// Property name.
414    name: Cow<'a, str>,
415    /// Object type. Accessor means that the property itself is an accessor property.
416    #[serde(rename = "type")]
417    type_: Cow<'a, str>,
418    /// User-friendly property value string.
419    #[serde(skip_serializing_if = "Option::is_none")]
420    value: Option<Cow<'a, str>>,
421    /// Nested value preview.
422    #[serde(skip_serializing_if = "Option::is_none", rename = "valuePreview")]
423    value_preview: Option<ObjectPreview<'a>>,
424    /// Object subtype hint. Specified for 'object' type values only.
425    #[serde(skip_serializing_if = "Option::is_none")]
426    subtype: Option<Cow<'a, str>>,
427}
428
429impl<'a> PropertyPreview<'a> {
430    /// Creates a builder for this type with the required parameters:
431    /// * `name`: Property name.
432    /// * `type_`: Object type. Accessor means that the property itself is an accessor property.
433    pub fn builder(name: impl Into<Cow<'a, str>>, type_: impl Into<Cow<'a, str>>) -> PropertyPreviewBuilder<'a> {
434        PropertyPreviewBuilder {
435            name: name.into(),
436            type_: type_.into(),
437            value: None,
438            value_preview: None,
439            subtype: None,
440        }
441    }
442    /// Property name.
443    pub fn name(&self) -> &str { self.name.as_ref() }
444    /// Object type. Accessor means that the property itself is an accessor property.
445    pub fn type_(&self) -> &str { self.type_.as_ref() }
446    /// User-friendly property value string.
447    pub fn value(&self) -> Option<&str> { self.value.as_deref() }
448    /// Nested value preview.
449    pub fn value_preview(&self) -> Option<&ObjectPreview<'a>> { self.value_preview.as_ref() }
450    /// Object subtype hint. Specified for 'object' type values only.
451    pub fn subtype(&self) -> Option<&str> { self.subtype.as_deref() }
452}
453
454
455pub struct PropertyPreviewBuilder<'a> {
456    name: Cow<'a, str>,
457    type_: Cow<'a, str>,
458    value: Option<Cow<'a, str>>,
459    value_preview: Option<ObjectPreview<'a>>,
460    subtype: Option<Cow<'a, str>>,
461}
462
463impl<'a> PropertyPreviewBuilder<'a> {
464    /// User-friendly property value string.
465    pub fn value(mut self, value: impl Into<Cow<'a, str>>) -> Self { self.value = Some(value.into()); self }
466    /// Nested value preview.
467    pub fn value_preview(mut self, value_preview: ObjectPreview<'a>) -> Self { self.value_preview = Some(value_preview); self }
468    /// Object subtype hint. Specified for 'object' type values only.
469    pub fn subtype(mut self, subtype: impl Into<Cow<'a, str>>) -> Self { self.subtype = Some(subtype.into()); self }
470    pub fn build(self) -> PropertyPreview<'a> {
471        PropertyPreview {
472            name: self.name,
473            type_: self.type_,
474            value: self.value,
475            value_preview: self.value_preview,
476            subtype: self.subtype,
477        }
478    }
479}
480
481
482#[derive(Debug, Clone, Serialize, Deserialize, Default)]
483#[serde(rename_all = "camelCase")]
484pub struct EntryPreview<'a> {
485    /// Preview of the key. Specified for map-like collection entries.
486    #[serde(skip_serializing_if = "Option::is_none")]
487    key: Option<ObjectPreview<'a>>,
488    /// Preview of the value.
489    value: ObjectPreview<'a>,
490}
491
492impl<'a> EntryPreview<'a> {
493    /// Creates a builder for this type with the required parameters:
494    /// * `value`: Preview of the value.
495    pub fn builder(value: ObjectPreview<'a>) -> EntryPreviewBuilder<'a> {
496        EntryPreviewBuilder {
497            key: None,
498            value: value,
499        }
500    }
501    /// Preview of the key. Specified for map-like collection entries.
502    pub fn key(&self) -> Option<&ObjectPreview<'a>> { self.key.as_ref() }
503    /// Preview of the value.
504    pub fn value(&self) -> &ObjectPreview<'a> { &self.value }
505}
506
507
508pub struct EntryPreviewBuilder<'a> {
509    key: Option<ObjectPreview<'a>>,
510    value: ObjectPreview<'a>,
511}
512
513impl<'a> EntryPreviewBuilder<'a> {
514    /// Preview of the key. Specified for map-like collection entries.
515    pub fn key(mut self, key: ObjectPreview<'a>) -> Self { self.key = Some(key); self }
516    pub fn build(self) -> EntryPreview<'a> {
517        EntryPreview {
518            key: self.key,
519            value: self.value,
520        }
521    }
522}
523
524/// Object property descriptor.
525
526#[derive(Debug, Clone, Serialize, Deserialize, Default)]
527#[serde(rename_all = "camelCase")]
528pub struct PropertyDescriptor<'a> {
529    /// Property name or symbol description.
530    name: Cow<'a, str>,
531    /// The value associated with the property.
532    #[serde(skip_serializing_if = "Option::is_none")]
533    value: Option<RemoteObject<'a>>,
534    /// True if the value associated with the property may be changed (data descriptors only).
535    #[serde(skip_serializing_if = "Option::is_none")]
536    writable: Option<bool>,
537    /// A function which serves as a getter for the property, or 'undefined' if there is no getter
538    /// (accessor descriptors only).
539    #[serde(skip_serializing_if = "Option::is_none")]
540    get: Option<RemoteObject<'a>>,
541    /// A function which serves as a setter for the property, or 'undefined' if there is no setter
542    /// (accessor descriptors only).
543    #[serde(skip_serializing_if = "Option::is_none")]
544    set: Option<RemoteObject<'a>>,
545    /// True if the type of this property descriptor may be changed and if the property may be
546    /// deleted from the corresponding object.
547    configurable: bool,
548    /// True if this property shows up during enumeration of the properties on the corresponding
549    /// object.
550    enumerable: bool,
551    /// True if the result was thrown during the evaluation.
552    #[serde(skip_serializing_if = "Option::is_none", rename = "wasThrown")]
553    was_thrown: Option<bool>,
554    /// True if the property is owned for the object.
555    #[serde(skip_serializing_if = "Option::is_none", rename = "isOwn")]
556    is_own: Option<bool>,
557    /// Property symbol object, if the property is of the 'symbol' type.
558    #[serde(skip_serializing_if = "Option::is_none")]
559    symbol: Option<RemoteObject<'a>>,
560}
561
562impl<'a> PropertyDescriptor<'a> {
563    /// Creates a builder for this type with the required parameters:
564    /// * `name`: Property name or symbol description.
565    /// * `configurable`: True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object.
566    /// * `enumerable`: True if this property shows up during enumeration of the properties on the corresponding object.
567    pub fn builder(name: impl Into<Cow<'a, str>>, configurable: bool, enumerable: bool) -> PropertyDescriptorBuilder<'a> {
568        PropertyDescriptorBuilder {
569            name: name.into(),
570            value: None,
571            writable: None,
572            get: None,
573            set: None,
574            configurable: configurable,
575            enumerable: enumerable,
576            was_thrown: None,
577            is_own: None,
578            symbol: None,
579        }
580    }
581    /// Property name or symbol description.
582    pub fn name(&self) -> &str { self.name.as_ref() }
583    /// The value associated with the property.
584    pub fn value(&self) -> Option<&RemoteObject<'a>> { self.value.as_ref() }
585    /// True if the value associated with the property may be changed (data descriptors only).
586    pub fn writable(&self) -> Option<bool> { self.writable }
587    /// A function which serves as a getter for the property, or 'undefined' if there is no getter
588    /// (accessor descriptors only).
589    pub fn get(&self) -> Option<&RemoteObject<'a>> { self.get.as_ref() }
590    /// A function which serves as a setter for the property, or 'undefined' if there is no setter
591    /// (accessor descriptors only).
592    pub fn set(&self) -> Option<&RemoteObject<'a>> { self.set.as_ref() }
593    /// True if the type of this property descriptor may be changed and if the property may be
594    /// deleted from the corresponding object.
595    pub fn configurable(&self) -> bool { self.configurable }
596    /// True if this property shows up during enumeration of the properties on the corresponding
597    /// object.
598    pub fn enumerable(&self) -> bool { self.enumerable }
599    /// True if the result was thrown during the evaluation.
600    pub fn was_thrown(&self) -> Option<bool> { self.was_thrown }
601    /// True if the property is owned for the object.
602    pub fn is_own(&self) -> Option<bool> { self.is_own }
603    /// Property symbol object, if the property is of the 'symbol' type.
604    pub fn symbol(&self) -> Option<&RemoteObject<'a>> { self.symbol.as_ref() }
605}
606
607
608pub struct PropertyDescriptorBuilder<'a> {
609    name: Cow<'a, str>,
610    value: Option<RemoteObject<'a>>,
611    writable: Option<bool>,
612    get: Option<RemoteObject<'a>>,
613    set: Option<RemoteObject<'a>>,
614    configurable: bool,
615    enumerable: bool,
616    was_thrown: Option<bool>,
617    is_own: Option<bool>,
618    symbol: Option<RemoteObject<'a>>,
619}
620
621impl<'a> PropertyDescriptorBuilder<'a> {
622    /// The value associated with the property.
623    pub fn value(mut self, value: RemoteObject<'a>) -> Self { self.value = Some(value); self }
624    /// True if the value associated with the property may be changed (data descriptors only).
625    pub fn writable(mut self, writable: bool) -> Self { self.writable = Some(writable); self }
626    /// A function which serves as a getter for the property, or 'undefined' if there is no getter
627    /// (accessor descriptors only).
628    pub fn get(mut self, get: RemoteObject<'a>) -> Self { self.get = Some(get); self }
629    /// A function which serves as a setter for the property, or 'undefined' if there is no setter
630    /// (accessor descriptors only).
631    pub fn set(mut self, set: RemoteObject<'a>) -> Self { self.set = Some(set); self }
632    /// True if the result was thrown during the evaluation.
633    pub fn was_thrown(mut self, was_thrown: bool) -> Self { self.was_thrown = Some(was_thrown); self }
634    /// True if the property is owned for the object.
635    pub fn is_own(mut self, is_own: bool) -> Self { self.is_own = Some(is_own); self }
636    /// Property symbol object, if the property is of the 'symbol' type.
637    pub fn symbol(mut self, symbol: RemoteObject<'a>) -> Self { self.symbol = Some(symbol); self }
638    pub fn build(self) -> PropertyDescriptor<'a> {
639        PropertyDescriptor {
640            name: self.name,
641            value: self.value,
642            writable: self.writable,
643            get: self.get,
644            set: self.set,
645            configurable: self.configurable,
646            enumerable: self.enumerable,
647            was_thrown: self.was_thrown,
648            is_own: self.is_own,
649            symbol: self.symbol,
650        }
651    }
652}
653
654/// Object internal property descriptor. This property isn't normally visible in JavaScript code.
655
656#[derive(Debug, Clone, Serialize, Deserialize, Default)]
657#[serde(rename_all = "camelCase")]
658pub struct InternalPropertyDescriptor<'a> {
659    /// Conventional property name.
660    name: Cow<'a, str>,
661    /// The value associated with the property.
662    #[serde(skip_serializing_if = "Option::is_none")]
663    value: Option<RemoteObject<'a>>,
664}
665
666impl<'a> InternalPropertyDescriptor<'a> {
667    /// Creates a builder for this type with the required parameters:
668    /// * `name`: Conventional property name.
669    pub fn builder(name: impl Into<Cow<'a, str>>) -> InternalPropertyDescriptorBuilder<'a> {
670        InternalPropertyDescriptorBuilder {
671            name: name.into(),
672            value: None,
673        }
674    }
675    /// Conventional property name.
676    pub fn name(&self) -> &str { self.name.as_ref() }
677    /// The value associated with the property.
678    pub fn value(&self) -> Option<&RemoteObject<'a>> { self.value.as_ref() }
679}
680
681
682pub struct InternalPropertyDescriptorBuilder<'a> {
683    name: Cow<'a, str>,
684    value: Option<RemoteObject<'a>>,
685}
686
687impl<'a> InternalPropertyDescriptorBuilder<'a> {
688    /// The value associated with the property.
689    pub fn value(mut self, value: RemoteObject<'a>) -> Self { self.value = Some(value); self }
690    pub fn build(self) -> InternalPropertyDescriptor<'a> {
691        InternalPropertyDescriptor {
692            name: self.name,
693            value: self.value,
694        }
695    }
696}
697
698/// Object private field descriptor.
699
700#[derive(Debug, Clone, Serialize, Deserialize, Default)]
701#[serde(rename_all = "camelCase")]
702pub struct PrivatePropertyDescriptor<'a> {
703    /// Private property name.
704    name: Cow<'a, str>,
705    /// The value associated with the private property.
706    #[serde(skip_serializing_if = "Option::is_none")]
707    value: Option<RemoteObject<'a>>,
708    /// A function which serves as a getter for the private property,
709    /// or 'undefined' if there is no getter (accessor descriptors only).
710    #[serde(skip_serializing_if = "Option::is_none")]
711    get: Option<RemoteObject<'a>>,
712    /// A function which serves as a setter for the private property,
713    /// or 'undefined' if there is no setter (accessor descriptors only).
714    #[serde(skip_serializing_if = "Option::is_none")]
715    set: Option<RemoteObject<'a>>,
716}
717
718impl<'a> PrivatePropertyDescriptor<'a> {
719    /// Creates a builder for this type with the required parameters:
720    /// * `name`: Private property name.
721    pub fn builder(name: impl Into<Cow<'a, str>>) -> PrivatePropertyDescriptorBuilder<'a> {
722        PrivatePropertyDescriptorBuilder {
723            name: name.into(),
724            value: None,
725            get: None,
726            set: None,
727        }
728    }
729    /// Private property name.
730    pub fn name(&self) -> &str { self.name.as_ref() }
731    /// The value associated with the private property.
732    pub fn value(&self) -> Option<&RemoteObject<'a>> { self.value.as_ref() }
733    /// A function which serves as a getter for the private property,
734    /// or 'undefined' if there is no getter (accessor descriptors only).
735    pub fn get(&self) -> Option<&RemoteObject<'a>> { self.get.as_ref() }
736    /// A function which serves as a setter for the private property,
737    /// or 'undefined' if there is no setter (accessor descriptors only).
738    pub fn set(&self) -> Option<&RemoteObject<'a>> { self.set.as_ref() }
739}
740
741
742pub struct PrivatePropertyDescriptorBuilder<'a> {
743    name: Cow<'a, str>,
744    value: Option<RemoteObject<'a>>,
745    get: Option<RemoteObject<'a>>,
746    set: Option<RemoteObject<'a>>,
747}
748
749impl<'a> PrivatePropertyDescriptorBuilder<'a> {
750    /// The value associated with the private property.
751    pub fn value(mut self, value: RemoteObject<'a>) -> Self { self.value = Some(value); self }
752    /// A function which serves as a getter for the private property,
753    /// or 'undefined' if there is no getter (accessor descriptors only).
754    pub fn get(mut self, get: RemoteObject<'a>) -> Self { self.get = Some(get); self }
755    /// A function which serves as a setter for the private property,
756    /// or 'undefined' if there is no setter (accessor descriptors only).
757    pub fn set(mut self, set: RemoteObject<'a>) -> Self { self.set = Some(set); self }
758    pub fn build(self) -> PrivatePropertyDescriptor<'a> {
759        PrivatePropertyDescriptor {
760            name: self.name,
761            value: self.value,
762            get: self.get,
763            set: self.set,
764        }
765    }
766}
767
768/// Represents function call argument. Either remote object id 'objectId', primitive 'value',
769/// unserializable primitive value or neither of (for undefined) them should be specified.
770
771#[derive(Debug, Clone, Serialize, Deserialize, Default)]
772#[serde(rename_all = "camelCase")]
773pub struct CallArgument<'a> {
774    /// Primitive value or serializable javascript object.
775    #[serde(skip_serializing_if = "Option::is_none")]
776    value: Option<JsonValue>,
777    /// Primitive value which can not be JSON-stringified.
778    #[serde(skip_serializing_if = "Option::is_none", rename = "unserializableValue")]
779    unserializable_value: Option<UnserializableValue<'a>>,
780    /// Remote object handle.
781    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
782    object_id: Option<RemoteObjectId<'a>>,
783}
784
785impl<'a> CallArgument<'a> {
786    /// Creates a builder for this type.
787    pub fn builder() -> CallArgumentBuilder<'a> {
788        CallArgumentBuilder {
789            value: None,
790            unserializable_value: None,
791            object_id: None,
792        }
793    }
794    /// Primitive value or serializable javascript object.
795    pub fn value(&self) -> Option<&JsonValue> { self.value.as_ref() }
796    /// Primitive value which can not be JSON-stringified.
797    pub fn unserializable_value(&self) -> Option<&UnserializableValue<'a>> { self.unserializable_value.as_ref() }
798    /// Remote object handle.
799    pub fn object_id(&self) -> Option<&RemoteObjectId<'a>> { self.object_id.as_ref() }
800}
801
802#[derive(Default)]
803pub struct CallArgumentBuilder<'a> {
804    value: Option<JsonValue>,
805    unserializable_value: Option<UnserializableValue<'a>>,
806    object_id: Option<RemoteObjectId<'a>>,
807}
808
809impl<'a> CallArgumentBuilder<'a> {
810    /// Primitive value or serializable javascript object.
811    pub fn value(mut self, value: JsonValue) -> Self { self.value = Some(value); self }
812    /// Primitive value which can not be JSON-stringified.
813    pub fn unserializable_value(mut self, unserializable_value: impl Into<UnserializableValue<'a>>) -> Self { self.unserializable_value = Some(unserializable_value.into()); self }
814    /// Remote object handle.
815    pub fn object_id(mut self, object_id: impl Into<RemoteObjectId<'a>>) -> Self { self.object_id = Some(object_id.into()); self }
816    pub fn build(self) -> CallArgument<'a> {
817        CallArgument {
818            value: self.value,
819            unserializable_value: self.unserializable_value,
820            object_id: self.object_id,
821        }
822    }
823}
824
825/// Id of an execution context.
826
827pub type ExecutionContextId = i64;
828
829/// Description of an isolated world.
830
831#[derive(Debug, Clone, Serialize, Deserialize, Default)]
832#[serde(rename_all = "camelCase")]
833pub struct ExecutionContextDescription<'a> {
834    /// Unique id of the execution context. It can be used to specify in which execution context
835    /// script evaluation should be performed.
836    id: ExecutionContextId,
837    /// Execution context origin.
838    origin: Cow<'a, str>,
839    /// Human readable name describing given context.
840    name: Cow<'a, str>,
841    /// A system-unique execution context identifier. Unlike the id, this is unique across
842    /// multiple processes, so can be reliably used to identify specific context while backend
843    /// performs a cross-process navigation.
844    #[serde(rename = "uniqueId")]
845    unique_id: Cow<'a, str>,
846    /// Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
847    #[serde(skip_serializing_if = "Option::is_none", rename = "auxData")]
848    aux_data: Option<serde_json::Map<String, JsonValue>>,
849}
850
851impl<'a> ExecutionContextDescription<'a> {
852    /// Creates a builder for this type with the required parameters:
853    /// * `id`: Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed.
854    /// * `origin`: Execution context origin.
855    /// * `name`: Human readable name describing given context.
856    /// * `unique_id`: A system-unique execution context identifier. Unlike the id, this is unique across multiple processes, so can be reliably used to identify specific context while backend performs a cross-process navigation.
857    pub fn builder(id: ExecutionContextId, origin: impl Into<Cow<'a, str>>, name: impl Into<Cow<'a, str>>, unique_id: impl Into<Cow<'a, str>>) -> ExecutionContextDescriptionBuilder<'a> {
858        ExecutionContextDescriptionBuilder {
859            id: id,
860            origin: origin.into(),
861            name: name.into(),
862            unique_id: unique_id.into(),
863            aux_data: None,
864        }
865    }
866    /// Unique id of the execution context. It can be used to specify in which execution context
867    /// script evaluation should be performed.
868    pub fn id(&self) -> &ExecutionContextId { &self.id }
869    /// Execution context origin.
870    pub fn origin(&self) -> &str { self.origin.as_ref() }
871    /// Human readable name describing given context.
872    pub fn name(&self) -> &str { self.name.as_ref() }
873    /// A system-unique execution context identifier. Unlike the id, this is unique across
874    /// multiple processes, so can be reliably used to identify specific context while backend
875    /// performs a cross-process navigation.
876    pub fn unique_id(&self) -> &str { self.unique_id.as_ref() }
877    /// Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
878    pub fn aux_data(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.aux_data.as_ref() }
879}
880
881
882pub struct ExecutionContextDescriptionBuilder<'a> {
883    id: ExecutionContextId,
884    origin: Cow<'a, str>,
885    name: Cow<'a, str>,
886    unique_id: Cow<'a, str>,
887    aux_data: Option<serde_json::Map<String, JsonValue>>,
888}
889
890impl<'a> ExecutionContextDescriptionBuilder<'a> {
891    /// Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
892    pub fn aux_data(mut self, aux_data: serde_json::Map<String, JsonValue>) -> Self { self.aux_data = Some(aux_data); self }
893    pub fn build(self) -> ExecutionContextDescription<'a> {
894        ExecutionContextDescription {
895            id: self.id,
896            origin: self.origin,
897            name: self.name,
898            unique_id: self.unique_id,
899            aux_data: self.aux_data,
900        }
901    }
902}
903
904/// Detailed information about exception (or error) that was thrown during script compilation or
905/// execution.
906
907#[derive(Debug, Clone, Serialize, Deserialize, Default)]
908#[serde(rename_all = "camelCase")]
909pub struct ExceptionDetails<'a> {
910    /// Exception id.
911    #[serde(rename = "exceptionId")]
912    exception_id: u64,
913    /// Exception text, which should be used together with exception object when available.
914    text: Cow<'a, str>,
915    /// Line number of the exception location (0-based).
916    #[serde(rename = "lineNumber")]
917    line_number: i64,
918    /// Column number of the exception location (0-based).
919    #[serde(rename = "columnNumber")]
920    column_number: i64,
921    /// Script ID of the exception location.
922    #[serde(skip_serializing_if = "Option::is_none", rename = "scriptId")]
923    script_id: Option<ScriptId<'a>>,
924    /// URL of the exception location, to be used when the script was not reported.
925    #[serde(skip_serializing_if = "Option::is_none")]
926    url: Option<Cow<'a, str>>,
927    /// JavaScript stack trace if available.
928    #[serde(skip_serializing_if = "Option::is_none", rename = "stackTrace")]
929    stack_trace: Option<StackTrace<'a>>,
930    /// Exception object if available.
931    #[serde(skip_serializing_if = "Option::is_none")]
932    exception: Option<RemoteObject<'a>>,
933    /// Identifier of the context where exception happened.
934    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextId")]
935    execution_context_id: Option<ExecutionContextId>,
936    /// Dictionary with entries of meta data that the client associated
937    /// with this exception, such as information about associated network
938    /// requests, etc.
939    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionMetaData")]
940    exception_meta_data: Option<serde_json::Map<String, JsonValue>>,
941}
942
943impl<'a> ExceptionDetails<'a> {
944    /// Creates a builder for this type with the required parameters:
945    /// * `exception_id`: Exception id.
946    /// * `text`: Exception text, which should be used together with exception object when available.
947    /// * `line_number`: Line number of the exception location (0-based).
948    /// * `column_number`: Column number of the exception location (0-based).
949    pub fn builder(exception_id: u64, text: impl Into<Cow<'a, str>>, line_number: i64, column_number: i64) -> ExceptionDetailsBuilder<'a> {
950        ExceptionDetailsBuilder {
951            exception_id: exception_id,
952            text: text.into(),
953            line_number: line_number,
954            column_number: column_number,
955            script_id: None,
956            url: None,
957            stack_trace: None,
958            exception: None,
959            execution_context_id: None,
960            exception_meta_data: None,
961        }
962    }
963    /// Exception id.
964    pub fn exception_id(&self) -> u64 { self.exception_id }
965    /// Exception text, which should be used together with exception object when available.
966    pub fn text(&self) -> &str { self.text.as_ref() }
967    /// Line number of the exception location (0-based).
968    pub fn line_number(&self) -> i64 { self.line_number }
969    /// Column number of the exception location (0-based).
970    pub fn column_number(&self) -> i64 { self.column_number }
971    /// Script ID of the exception location.
972    pub fn script_id(&self) -> Option<&ScriptId<'a>> { self.script_id.as_ref() }
973    /// URL of the exception location, to be used when the script was not reported.
974    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
975    /// JavaScript stack trace if available.
976    pub fn stack_trace(&self) -> Option<&StackTrace<'a>> { self.stack_trace.as_ref() }
977    /// Exception object if available.
978    pub fn exception(&self) -> Option<&RemoteObject<'a>> { self.exception.as_ref() }
979    /// Identifier of the context where exception happened.
980    pub fn execution_context_id(&self) -> Option<&ExecutionContextId> { self.execution_context_id.as_ref() }
981    /// Dictionary with entries of meta data that the client associated
982    /// with this exception, such as information about associated network
983    /// requests, etc.
984    pub fn exception_meta_data(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.exception_meta_data.as_ref() }
985}
986
987
988pub struct ExceptionDetailsBuilder<'a> {
989    exception_id: u64,
990    text: Cow<'a, str>,
991    line_number: i64,
992    column_number: i64,
993    script_id: Option<ScriptId<'a>>,
994    url: Option<Cow<'a, str>>,
995    stack_trace: Option<StackTrace<'a>>,
996    exception: Option<RemoteObject<'a>>,
997    execution_context_id: Option<ExecutionContextId>,
998    exception_meta_data: Option<serde_json::Map<String, JsonValue>>,
999}
1000
1001impl<'a> ExceptionDetailsBuilder<'a> {
1002    /// Script ID of the exception location.
1003    pub fn script_id(mut self, script_id: impl Into<ScriptId<'a>>) -> Self { self.script_id = Some(script_id.into()); self }
1004    /// URL of the exception location, to be used when the script was not reported.
1005    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
1006    /// JavaScript stack trace if available.
1007    pub fn stack_trace(mut self, stack_trace: StackTrace<'a>) -> Self { self.stack_trace = Some(stack_trace); self }
1008    /// Exception object if available.
1009    pub fn exception(mut self, exception: RemoteObject<'a>) -> Self { self.exception = Some(exception); self }
1010    /// Identifier of the context where exception happened.
1011    pub fn execution_context_id(mut self, execution_context_id: ExecutionContextId) -> Self { self.execution_context_id = Some(execution_context_id); self }
1012    /// Dictionary with entries of meta data that the client associated
1013    /// with this exception, such as information about associated network
1014    /// requests, etc.
1015    pub fn exception_meta_data(mut self, exception_meta_data: serde_json::Map<String, JsonValue>) -> Self { self.exception_meta_data = Some(exception_meta_data); self }
1016    pub fn build(self) -> ExceptionDetails<'a> {
1017        ExceptionDetails {
1018            exception_id: self.exception_id,
1019            text: self.text,
1020            line_number: self.line_number,
1021            column_number: self.column_number,
1022            script_id: self.script_id,
1023            url: self.url,
1024            stack_trace: self.stack_trace,
1025            exception: self.exception,
1026            execution_context_id: self.execution_context_id,
1027            exception_meta_data: self.exception_meta_data,
1028        }
1029    }
1030}
1031
1032/// Number of milliseconds since epoch.
1033
1034pub type Timestamp = f64;
1035
1036/// Number of milliseconds.
1037
1038pub type TimeDelta = f64;
1039
1040/// Stack entry for runtime errors and assertions.
1041
1042#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1043#[serde(rename_all = "camelCase")]
1044pub struct CallFrame<'a> {
1045    /// JavaScript function name.
1046    #[serde(rename = "functionName")]
1047    function_name: Cow<'a, str>,
1048    /// JavaScript script id.
1049    #[serde(rename = "scriptId")]
1050    script_id: ScriptId<'a>,
1051    /// JavaScript script name or url.
1052    url: Cow<'a, str>,
1053    /// JavaScript script line number (0-based).
1054    #[serde(rename = "lineNumber")]
1055    line_number: i64,
1056    /// JavaScript script column number (0-based).
1057    #[serde(rename = "columnNumber")]
1058    column_number: i64,
1059}
1060
1061impl<'a> CallFrame<'a> {
1062    /// Creates a builder for this type with the required parameters:
1063    /// * `function_name`: JavaScript function name.
1064    /// * `script_id`: JavaScript script id.
1065    /// * `url`: JavaScript script name or url.
1066    /// * `line_number`: JavaScript script line number (0-based).
1067    /// * `column_number`: JavaScript script column number (0-based).
1068    pub fn builder(function_name: impl Into<Cow<'a, str>>, script_id: impl Into<ScriptId<'a>>, url: impl Into<Cow<'a, str>>, line_number: i64, column_number: i64) -> CallFrameBuilder<'a> {
1069        CallFrameBuilder {
1070            function_name: function_name.into(),
1071            script_id: script_id.into(),
1072            url: url.into(),
1073            line_number: line_number,
1074            column_number: column_number,
1075        }
1076    }
1077    /// JavaScript function name.
1078    pub fn function_name(&self) -> &str { self.function_name.as_ref() }
1079    /// JavaScript script id.
1080    pub fn script_id(&self) -> &ScriptId<'a> { &self.script_id }
1081    /// JavaScript script name or url.
1082    pub fn url(&self) -> &str { self.url.as_ref() }
1083    /// JavaScript script line number (0-based).
1084    pub fn line_number(&self) -> i64 { self.line_number }
1085    /// JavaScript script column number (0-based).
1086    pub fn column_number(&self) -> i64 { self.column_number }
1087}
1088
1089
1090pub struct CallFrameBuilder<'a> {
1091    function_name: Cow<'a, str>,
1092    script_id: ScriptId<'a>,
1093    url: Cow<'a, str>,
1094    line_number: i64,
1095    column_number: i64,
1096}
1097
1098impl<'a> CallFrameBuilder<'a> {
1099    pub fn build(self) -> CallFrame<'a> {
1100        CallFrame {
1101            function_name: self.function_name,
1102            script_id: self.script_id,
1103            url: self.url,
1104            line_number: self.line_number,
1105            column_number: self.column_number,
1106        }
1107    }
1108}
1109
1110/// Call frames for assertions or error messages.
1111
1112#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1113#[serde(rename_all = "camelCase")]
1114pub struct StackTrace<'a> {
1115    /// String label of this stack trace. For async traces this may be a name of the function that
1116    /// initiated the async call.
1117    #[serde(skip_serializing_if = "Option::is_none")]
1118    description: Option<Cow<'a, str>>,
1119    /// JavaScript function name.
1120    #[serde(rename = "callFrames")]
1121    call_frames: Vec<CallFrame<'a>>,
1122    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
1123    #[serde(skip_serializing_if = "Option::is_none")]
1124    parent: Option<Box<StackTrace<'a>>>,
1125    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
1126    #[serde(skip_serializing_if = "Option::is_none", rename = "parentId")]
1127    parent_id: Option<StackTraceId<'a>>,
1128}
1129
1130impl<'a> StackTrace<'a> {
1131    /// Creates a builder for this type with the required parameters:
1132    /// * `call_frames`: JavaScript function name.
1133    pub fn builder(call_frames: Vec<CallFrame<'a>>) -> StackTraceBuilder<'a> {
1134        StackTraceBuilder {
1135            description: None,
1136            call_frames: call_frames,
1137            parent: None,
1138            parent_id: None,
1139        }
1140    }
1141    /// String label of this stack trace. For async traces this may be a name of the function that
1142    /// initiated the async call.
1143    pub fn description(&self) -> Option<&str> { self.description.as_deref() }
1144    /// JavaScript function name.
1145    pub fn call_frames(&self) -> &[CallFrame<'a>] { &self.call_frames }
1146    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
1147    pub fn parent(&self) -> Option<&StackTrace<'a>> { self.parent.as_deref() }
1148    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
1149    pub fn parent_id(&self) -> Option<&StackTraceId<'a>> { self.parent_id.as_ref() }
1150}
1151
1152
1153pub struct StackTraceBuilder<'a> {
1154    description: Option<Cow<'a, str>>,
1155    call_frames: Vec<CallFrame<'a>>,
1156    parent: Option<Box<StackTrace<'a>>>,
1157    parent_id: Option<StackTraceId<'a>>,
1158}
1159
1160impl<'a> StackTraceBuilder<'a> {
1161    /// String label of this stack trace. For async traces this may be a name of the function that
1162    /// initiated the async call.
1163    pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self { self.description = Some(description.into()); self }
1164    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
1165    pub fn parent(mut self, parent: Box<StackTrace<'a>>) -> Self { self.parent = Some(parent); self }
1166    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
1167    pub fn parent_id(mut self, parent_id: StackTraceId<'a>) -> Self { self.parent_id = Some(parent_id); self }
1168    pub fn build(self) -> StackTrace<'a> {
1169        StackTrace {
1170            description: self.description,
1171            call_frames: self.call_frames,
1172            parent: self.parent,
1173            parent_id: self.parent_id,
1174        }
1175    }
1176}
1177
1178/// Unique identifier of current debugger.
1179
1180pub type UniqueDebuggerId<'a> = Cow<'a, str>;
1181
1182/// If 'debuggerId' is set stack trace comes from another debugger and can be resolved there. This
1183/// allows to track cross-debugger calls. See 'Runtime.StackTrace' and 'Debugger.paused' for usages.
1184
1185#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1186#[serde(rename_all = "camelCase")]
1187pub struct StackTraceId<'a> {
1188    id: Cow<'a, str>,
1189    #[serde(skip_serializing_if = "Option::is_none", rename = "debuggerId")]
1190    debugger_id: Option<UniqueDebuggerId<'a>>,
1191}
1192
1193impl<'a> StackTraceId<'a> {
1194    /// Creates a builder for this type with the required parameters:
1195    /// * `id`: 
1196    pub fn builder(id: impl Into<Cow<'a, str>>) -> StackTraceIdBuilder<'a> {
1197        StackTraceIdBuilder {
1198            id: id.into(),
1199            debugger_id: None,
1200        }
1201    }
1202    pub fn id(&self) -> &str { self.id.as_ref() }
1203    pub fn debugger_id(&self) -> Option<&UniqueDebuggerId<'a>> { self.debugger_id.as_ref() }
1204}
1205
1206
1207pub struct StackTraceIdBuilder<'a> {
1208    id: Cow<'a, str>,
1209    debugger_id: Option<UniqueDebuggerId<'a>>,
1210}
1211
1212impl<'a> StackTraceIdBuilder<'a> {
1213    pub fn debugger_id(mut self, debugger_id: impl Into<UniqueDebuggerId<'a>>) -> Self { self.debugger_id = Some(debugger_id.into()); self }
1214    pub fn build(self) -> StackTraceId<'a> {
1215        StackTraceId {
1216            id: self.id,
1217            debugger_id: self.debugger_id,
1218        }
1219    }
1220}
1221
1222/// Add handler to promise with given promise object id.
1223
1224#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1225#[serde(rename_all = "camelCase")]
1226pub struct AwaitPromiseParams<'a> {
1227    /// Identifier of the promise.
1228    #[serde(rename = "promiseObjectId")]
1229    promise_object_id: RemoteObjectId<'a>,
1230    /// Whether the result is expected to be a JSON object that should be sent by value.
1231    #[serde(skip_serializing_if = "Option::is_none", rename = "returnByValue")]
1232    return_by_value: Option<bool>,
1233    /// Whether preview should be generated for the result.
1234    #[serde(skip_serializing_if = "Option::is_none", rename = "generatePreview")]
1235    generate_preview: Option<bool>,
1236}
1237
1238impl<'a> AwaitPromiseParams<'a> {
1239    /// Creates a builder for this type with the required parameters:
1240    /// * `promise_object_id`: Identifier of the promise.
1241    pub fn builder(promise_object_id: impl Into<RemoteObjectId<'a>>) -> AwaitPromiseParamsBuilder<'a> {
1242        AwaitPromiseParamsBuilder {
1243            promise_object_id: promise_object_id.into(),
1244            return_by_value: None,
1245            generate_preview: None,
1246        }
1247    }
1248    /// Identifier of the promise.
1249    pub fn promise_object_id(&self) -> &RemoteObjectId<'a> { &self.promise_object_id }
1250    /// Whether the result is expected to be a JSON object that should be sent by value.
1251    pub fn return_by_value(&self) -> Option<bool> { self.return_by_value }
1252    /// Whether preview should be generated for the result.
1253    pub fn generate_preview(&self) -> Option<bool> { self.generate_preview }
1254}
1255
1256
1257pub struct AwaitPromiseParamsBuilder<'a> {
1258    promise_object_id: RemoteObjectId<'a>,
1259    return_by_value: Option<bool>,
1260    generate_preview: Option<bool>,
1261}
1262
1263impl<'a> AwaitPromiseParamsBuilder<'a> {
1264    /// Whether the result is expected to be a JSON object that should be sent by value.
1265    pub fn return_by_value(mut self, return_by_value: bool) -> Self { self.return_by_value = Some(return_by_value); self }
1266    /// Whether preview should be generated for the result.
1267    pub fn generate_preview(mut self, generate_preview: bool) -> Self { self.generate_preview = Some(generate_preview); self }
1268    pub fn build(self) -> AwaitPromiseParams<'a> {
1269        AwaitPromiseParams {
1270            promise_object_id: self.promise_object_id,
1271            return_by_value: self.return_by_value,
1272            generate_preview: self.generate_preview,
1273        }
1274    }
1275}
1276
1277/// Add handler to promise with given promise object id.
1278
1279#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1280#[serde(rename_all = "camelCase")]
1281pub struct AwaitPromiseReturns<'a> {
1282    /// Promise result. Will contain rejected value if promise was rejected.
1283    result: RemoteObject<'a>,
1284    /// Exception details if stack strace is available.
1285    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
1286    exception_details: Option<ExceptionDetails<'a>>,
1287}
1288
1289impl<'a> AwaitPromiseReturns<'a> {
1290    /// Creates a builder for this type with the required parameters:
1291    /// * `result`: Promise result. Will contain rejected value if promise was rejected.
1292    pub fn builder(result: RemoteObject<'a>) -> AwaitPromiseReturnsBuilder<'a> {
1293        AwaitPromiseReturnsBuilder {
1294            result: result,
1295            exception_details: None,
1296        }
1297    }
1298    /// Promise result. Will contain rejected value if promise was rejected.
1299    pub fn result(&self) -> &RemoteObject<'a> { &self.result }
1300    /// Exception details if stack strace is available.
1301    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
1302}
1303
1304
1305pub struct AwaitPromiseReturnsBuilder<'a> {
1306    result: RemoteObject<'a>,
1307    exception_details: Option<ExceptionDetails<'a>>,
1308}
1309
1310impl<'a> AwaitPromiseReturnsBuilder<'a> {
1311    /// Exception details if stack strace is available.
1312    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
1313    pub fn build(self) -> AwaitPromiseReturns<'a> {
1314        AwaitPromiseReturns {
1315            result: self.result,
1316            exception_details: self.exception_details,
1317        }
1318    }
1319}
1320
1321impl<'a> AwaitPromiseParams<'a> { pub const METHOD: &'static str = "Runtime.awaitPromise"; }
1322
1323impl<'a> crate::CdpCommand<'a> for AwaitPromiseParams<'a> {
1324    const METHOD: &'static str = "Runtime.awaitPromise";
1325    type Response = AwaitPromiseReturns<'a>;
1326}
1327
1328/// Calls function with given declaration on the given object. Object group of the result is
1329/// inherited from the target object.
1330
1331#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1332#[serde(rename_all = "camelCase")]
1333pub struct CallFunctionOnParams<'a> {
1334    /// Declaration of the function to call.
1335    #[serde(rename = "functionDeclaration")]
1336    function_declaration: Cow<'a, str>,
1337    /// Identifier of the object to call function on. Either objectId or executionContextId should
1338    /// be specified.
1339    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
1340    object_id: Option<RemoteObjectId<'a>>,
1341    /// Call arguments. All call arguments must belong to the same JavaScript world as the target
1342    /// object.
1343    #[serde(skip_serializing_if = "Option::is_none")]
1344    arguments: Option<Vec<CallArgument<'a>>>,
1345    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
1346    /// execution. Overrides 'setPauseOnException' state.
1347    #[serde(skip_serializing_if = "Option::is_none")]
1348    silent: Option<bool>,
1349    /// Whether the result is expected to be a JSON object which should be sent by value.
1350    /// Can be overriden by 'serializationOptions'.
1351    #[serde(skip_serializing_if = "Option::is_none", rename = "returnByValue")]
1352    return_by_value: Option<bool>,
1353    /// Whether preview should be generated for the result.
1354    #[serde(skip_serializing_if = "Option::is_none", rename = "generatePreview")]
1355    generate_preview: Option<bool>,
1356    /// Whether execution should be treated as initiated by user in the UI.
1357    #[serde(skip_serializing_if = "Option::is_none", rename = "userGesture")]
1358    user_gesture: Option<bool>,
1359    /// Whether execution should 'await' for resulting value and return once awaited promise is
1360    /// resolved.
1361    #[serde(skip_serializing_if = "Option::is_none", rename = "awaitPromise")]
1362    await_promise: Option<bool>,
1363    /// Specifies execution context which global object will be used to call function on. Either
1364    /// executionContextId or objectId should be specified.
1365    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextId")]
1366    execution_context_id: Option<ExecutionContextId>,
1367    /// Symbolic group name that can be used to release multiple objects. If objectGroup is not
1368    /// specified and objectId is, objectGroup will be inherited from object.
1369    #[serde(skip_serializing_if = "Option::is_none", rename = "objectGroup")]
1370    object_group: Option<Cow<'a, str>>,
1371    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
1372    #[serde(skip_serializing_if = "Option::is_none", rename = "throwOnSideEffect")]
1373    throw_on_side_effect: Option<bool>,
1374    /// An alternative way to specify the execution context to call function on.
1375    /// Compared to contextId that may be reused across processes, this is guaranteed to be
1376    /// system-unique, so it can be used to prevent accidental function call
1377    /// in context different than intended (e.g. as a result of navigation across process
1378    /// boundaries).
1379    /// This is mutually exclusive with 'executionContextId'.
1380    #[serde(skip_serializing_if = "Option::is_none", rename = "uniqueContextId")]
1381    unique_context_id: Option<Cow<'a, str>>,
1382    /// Specifies the result serialization. If provided, overrides
1383    /// 'generatePreview' and 'returnByValue'.
1384    #[serde(skip_serializing_if = "Option::is_none", rename = "serializationOptions")]
1385    serialization_options: Option<SerializationOptions<'a>>,
1386}
1387
1388impl<'a> CallFunctionOnParams<'a> {
1389    /// Creates a builder for this type with the required parameters:
1390    /// * `function_declaration`: Declaration of the function to call.
1391    pub fn builder(function_declaration: impl Into<Cow<'a, str>>) -> CallFunctionOnParamsBuilder<'a> {
1392        CallFunctionOnParamsBuilder {
1393            function_declaration: function_declaration.into(),
1394            object_id: None,
1395            arguments: None,
1396            silent: None,
1397            return_by_value: None,
1398            generate_preview: None,
1399            user_gesture: None,
1400            await_promise: None,
1401            execution_context_id: None,
1402            object_group: None,
1403            throw_on_side_effect: None,
1404            unique_context_id: None,
1405            serialization_options: None,
1406        }
1407    }
1408    /// Declaration of the function to call.
1409    pub fn function_declaration(&self) -> &str { self.function_declaration.as_ref() }
1410    /// Identifier of the object to call function on. Either objectId or executionContextId should
1411    /// be specified.
1412    pub fn object_id(&self) -> Option<&RemoteObjectId<'a>> { self.object_id.as_ref() }
1413    /// Call arguments. All call arguments must belong to the same JavaScript world as the target
1414    /// object.
1415    pub fn arguments(&self) -> Option<&[CallArgument<'a>]> { self.arguments.as_deref() }
1416    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
1417    /// execution. Overrides 'setPauseOnException' state.
1418    pub fn silent(&self) -> Option<bool> { self.silent }
1419    /// Whether the result is expected to be a JSON object which should be sent by value.
1420    /// Can be overriden by 'serializationOptions'.
1421    pub fn return_by_value(&self) -> Option<bool> { self.return_by_value }
1422    /// Whether preview should be generated for the result.
1423    pub fn generate_preview(&self) -> Option<bool> { self.generate_preview }
1424    /// Whether execution should be treated as initiated by user in the UI.
1425    pub fn user_gesture(&self) -> Option<bool> { self.user_gesture }
1426    /// Whether execution should 'await' for resulting value and return once awaited promise is
1427    /// resolved.
1428    pub fn await_promise(&self) -> Option<bool> { self.await_promise }
1429    /// Specifies execution context which global object will be used to call function on. Either
1430    /// executionContextId or objectId should be specified.
1431    pub fn execution_context_id(&self) -> Option<&ExecutionContextId> { self.execution_context_id.as_ref() }
1432    /// Symbolic group name that can be used to release multiple objects. If objectGroup is not
1433    /// specified and objectId is, objectGroup will be inherited from object.
1434    pub fn object_group(&self) -> Option<&str> { self.object_group.as_deref() }
1435    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
1436    pub fn throw_on_side_effect(&self) -> Option<bool> { self.throw_on_side_effect }
1437    /// An alternative way to specify the execution context to call function on.
1438    /// Compared to contextId that may be reused across processes, this is guaranteed to be
1439    /// system-unique, so it can be used to prevent accidental function call
1440    /// in context different than intended (e.g. as a result of navigation across process
1441    /// boundaries).
1442    /// This is mutually exclusive with 'executionContextId'.
1443    pub fn unique_context_id(&self) -> Option<&str> { self.unique_context_id.as_deref() }
1444    /// Specifies the result serialization. If provided, overrides
1445    /// 'generatePreview' and 'returnByValue'.
1446    pub fn serialization_options(&self) -> Option<&SerializationOptions<'a>> { self.serialization_options.as_ref() }
1447}
1448
1449
1450pub struct CallFunctionOnParamsBuilder<'a> {
1451    function_declaration: Cow<'a, str>,
1452    object_id: Option<RemoteObjectId<'a>>,
1453    arguments: Option<Vec<CallArgument<'a>>>,
1454    silent: Option<bool>,
1455    return_by_value: Option<bool>,
1456    generate_preview: Option<bool>,
1457    user_gesture: Option<bool>,
1458    await_promise: Option<bool>,
1459    execution_context_id: Option<ExecutionContextId>,
1460    object_group: Option<Cow<'a, str>>,
1461    throw_on_side_effect: Option<bool>,
1462    unique_context_id: Option<Cow<'a, str>>,
1463    serialization_options: Option<SerializationOptions<'a>>,
1464}
1465
1466impl<'a> CallFunctionOnParamsBuilder<'a> {
1467    /// Identifier of the object to call function on. Either objectId or executionContextId should
1468    /// be specified.
1469    pub fn object_id(mut self, object_id: impl Into<RemoteObjectId<'a>>) -> Self { self.object_id = Some(object_id.into()); self }
1470    /// Call arguments. All call arguments must belong to the same JavaScript world as the target
1471    /// object.
1472    pub fn arguments(mut self, arguments: Vec<CallArgument<'a>>) -> Self { self.arguments = Some(arguments); self }
1473    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
1474    /// execution. Overrides 'setPauseOnException' state.
1475    pub fn silent(mut self, silent: bool) -> Self { self.silent = Some(silent); self }
1476    /// Whether the result is expected to be a JSON object which should be sent by value.
1477    /// Can be overriden by 'serializationOptions'.
1478    pub fn return_by_value(mut self, return_by_value: bool) -> Self { self.return_by_value = Some(return_by_value); self }
1479    /// Whether preview should be generated for the result.
1480    pub fn generate_preview(mut self, generate_preview: bool) -> Self { self.generate_preview = Some(generate_preview); self }
1481    /// Whether execution should be treated as initiated by user in the UI.
1482    pub fn user_gesture(mut self, user_gesture: bool) -> Self { self.user_gesture = Some(user_gesture); self }
1483    /// Whether execution should 'await' for resulting value and return once awaited promise is
1484    /// resolved.
1485    pub fn await_promise(mut self, await_promise: bool) -> Self { self.await_promise = Some(await_promise); self }
1486    /// Specifies execution context which global object will be used to call function on. Either
1487    /// executionContextId or objectId should be specified.
1488    pub fn execution_context_id(mut self, execution_context_id: ExecutionContextId) -> Self { self.execution_context_id = Some(execution_context_id); self }
1489    /// Symbolic group name that can be used to release multiple objects. If objectGroup is not
1490    /// specified and objectId is, objectGroup will be inherited from object.
1491    pub fn object_group(mut self, object_group: impl Into<Cow<'a, str>>) -> Self { self.object_group = Some(object_group.into()); self }
1492    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
1493    pub fn throw_on_side_effect(mut self, throw_on_side_effect: bool) -> Self { self.throw_on_side_effect = Some(throw_on_side_effect); self }
1494    /// An alternative way to specify the execution context to call function on.
1495    /// Compared to contextId that may be reused across processes, this is guaranteed to be
1496    /// system-unique, so it can be used to prevent accidental function call
1497    /// in context different than intended (e.g. as a result of navigation across process
1498    /// boundaries).
1499    /// This is mutually exclusive with 'executionContextId'.
1500    pub fn unique_context_id(mut self, unique_context_id: impl Into<Cow<'a, str>>) -> Self { self.unique_context_id = Some(unique_context_id.into()); self }
1501    /// Specifies the result serialization. If provided, overrides
1502    /// 'generatePreview' and 'returnByValue'.
1503    pub fn serialization_options(mut self, serialization_options: SerializationOptions<'a>) -> Self { self.serialization_options = Some(serialization_options); self }
1504    pub fn build(self) -> CallFunctionOnParams<'a> {
1505        CallFunctionOnParams {
1506            function_declaration: self.function_declaration,
1507            object_id: self.object_id,
1508            arguments: self.arguments,
1509            silent: self.silent,
1510            return_by_value: self.return_by_value,
1511            generate_preview: self.generate_preview,
1512            user_gesture: self.user_gesture,
1513            await_promise: self.await_promise,
1514            execution_context_id: self.execution_context_id,
1515            object_group: self.object_group,
1516            throw_on_side_effect: self.throw_on_side_effect,
1517            unique_context_id: self.unique_context_id,
1518            serialization_options: self.serialization_options,
1519        }
1520    }
1521}
1522
1523/// Calls function with given declaration on the given object. Object group of the result is
1524/// inherited from the target object.
1525
1526#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1527#[serde(rename_all = "camelCase")]
1528pub struct CallFunctionOnReturns<'a> {
1529    /// Call result.
1530    result: RemoteObject<'a>,
1531    /// Exception details.
1532    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
1533    exception_details: Option<ExceptionDetails<'a>>,
1534}
1535
1536impl<'a> CallFunctionOnReturns<'a> {
1537    /// Creates a builder for this type with the required parameters:
1538    /// * `result`: Call result.
1539    pub fn builder(result: RemoteObject<'a>) -> CallFunctionOnReturnsBuilder<'a> {
1540        CallFunctionOnReturnsBuilder {
1541            result: result,
1542            exception_details: None,
1543        }
1544    }
1545    /// Call result.
1546    pub fn result(&self) -> &RemoteObject<'a> { &self.result }
1547    /// Exception details.
1548    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
1549}
1550
1551
1552pub struct CallFunctionOnReturnsBuilder<'a> {
1553    result: RemoteObject<'a>,
1554    exception_details: Option<ExceptionDetails<'a>>,
1555}
1556
1557impl<'a> CallFunctionOnReturnsBuilder<'a> {
1558    /// Exception details.
1559    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
1560    pub fn build(self) -> CallFunctionOnReturns<'a> {
1561        CallFunctionOnReturns {
1562            result: self.result,
1563            exception_details: self.exception_details,
1564        }
1565    }
1566}
1567
1568impl<'a> CallFunctionOnParams<'a> { pub const METHOD: &'static str = "Runtime.callFunctionOn"; }
1569
1570impl<'a> crate::CdpCommand<'a> for CallFunctionOnParams<'a> {
1571    const METHOD: &'static str = "Runtime.callFunctionOn";
1572    type Response = CallFunctionOnReturns<'a>;
1573}
1574
1575/// Compiles expression.
1576
1577#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1578#[serde(rename_all = "camelCase")]
1579pub struct CompileScriptParams<'a> {
1580    /// Expression to compile.
1581    expression: Cow<'a, str>,
1582    /// Source url to be set for the script.
1583    #[serde(rename = "sourceURL")]
1584    source_url: Cow<'a, str>,
1585    /// Specifies whether the compiled script should be persisted.
1586    #[serde(rename = "persistScript")]
1587    persist_script: bool,
1588    /// Specifies in which execution context to perform script run. If the parameter is omitted the
1589    /// evaluation will be performed in the context of the inspected page.
1590    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextId")]
1591    execution_context_id: Option<ExecutionContextId>,
1592}
1593
1594impl<'a> CompileScriptParams<'a> {
1595    /// Creates a builder for this type with the required parameters:
1596    /// * `expression`: Expression to compile.
1597    /// * `source_url`: Source url to be set for the script.
1598    /// * `persist_script`: Specifies whether the compiled script should be persisted.
1599    pub fn builder(expression: impl Into<Cow<'a, str>>, source_url: impl Into<Cow<'a, str>>, persist_script: bool) -> CompileScriptParamsBuilder<'a> {
1600        CompileScriptParamsBuilder {
1601            expression: expression.into(),
1602            source_url: source_url.into(),
1603            persist_script: persist_script,
1604            execution_context_id: None,
1605        }
1606    }
1607    /// Expression to compile.
1608    pub fn expression(&self) -> &str { self.expression.as_ref() }
1609    /// Source url to be set for the script.
1610    pub fn source_url(&self) -> &str { self.source_url.as_ref() }
1611    /// Specifies whether the compiled script should be persisted.
1612    pub fn persist_script(&self) -> bool { self.persist_script }
1613    /// Specifies in which execution context to perform script run. If the parameter is omitted the
1614    /// evaluation will be performed in the context of the inspected page.
1615    pub fn execution_context_id(&self) -> Option<&ExecutionContextId> { self.execution_context_id.as_ref() }
1616}
1617
1618
1619pub struct CompileScriptParamsBuilder<'a> {
1620    expression: Cow<'a, str>,
1621    source_url: Cow<'a, str>,
1622    persist_script: bool,
1623    execution_context_id: Option<ExecutionContextId>,
1624}
1625
1626impl<'a> CompileScriptParamsBuilder<'a> {
1627    /// Specifies in which execution context to perform script run. If the parameter is omitted the
1628    /// evaluation will be performed in the context of the inspected page.
1629    pub fn execution_context_id(mut self, execution_context_id: ExecutionContextId) -> Self { self.execution_context_id = Some(execution_context_id); self }
1630    pub fn build(self) -> CompileScriptParams<'a> {
1631        CompileScriptParams {
1632            expression: self.expression,
1633            source_url: self.source_url,
1634            persist_script: self.persist_script,
1635            execution_context_id: self.execution_context_id,
1636        }
1637    }
1638}
1639
1640/// Compiles expression.
1641
1642#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1643#[serde(rename_all = "camelCase")]
1644pub struct CompileScriptReturns<'a> {
1645    /// Id of the script.
1646    #[serde(skip_serializing_if = "Option::is_none", rename = "scriptId")]
1647    script_id: Option<ScriptId<'a>>,
1648    /// Exception details.
1649    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
1650    exception_details: Option<ExceptionDetails<'a>>,
1651}
1652
1653impl<'a> CompileScriptReturns<'a> {
1654    /// Creates a builder for this type.
1655    pub fn builder() -> CompileScriptReturnsBuilder<'a> {
1656        CompileScriptReturnsBuilder {
1657            script_id: None,
1658            exception_details: None,
1659        }
1660    }
1661    /// Id of the script.
1662    pub fn script_id(&self) -> Option<&ScriptId<'a>> { self.script_id.as_ref() }
1663    /// Exception details.
1664    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
1665}
1666
1667#[derive(Default)]
1668pub struct CompileScriptReturnsBuilder<'a> {
1669    script_id: Option<ScriptId<'a>>,
1670    exception_details: Option<ExceptionDetails<'a>>,
1671}
1672
1673impl<'a> CompileScriptReturnsBuilder<'a> {
1674    /// Id of the script.
1675    pub fn script_id(mut self, script_id: impl Into<ScriptId<'a>>) -> Self { self.script_id = Some(script_id.into()); self }
1676    /// Exception details.
1677    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
1678    pub fn build(self) -> CompileScriptReturns<'a> {
1679        CompileScriptReturns {
1680            script_id: self.script_id,
1681            exception_details: self.exception_details,
1682        }
1683    }
1684}
1685
1686impl<'a> CompileScriptParams<'a> { pub const METHOD: &'static str = "Runtime.compileScript"; }
1687
1688impl<'a> crate::CdpCommand<'a> for CompileScriptParams<'a> {
1689    const METHOD: &'static str = "Runtime.compileScript";
1690    type Response = CompileScriptReturns<'a>;
1691}
1692
1693#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1694pub struct DisableParams {}
1695
1696impl DisableParams { pub const METHOD: &'static str = "Runtime.disable"; }
1697
1698impl<'a> crate::CdpCommand<'a> for DisableParams {
1699    const METHOD: &'static str = "Runtime.disable";
1700    type Response = crate::EmptyReturns;
1701}
1702
1703#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1704pub struct DiscardConsoleEntriesParams {}
1705
1706impl DiscardConsoleEntriesParams { pub const METHOD: &'static str = "Runtime.discardConsoleEntries"; }
1707
1708impl<'a> crate::CdpCommand<'a> for DiscardConsoleEntriesParams {
1709    const METHOD: &'static str = "Runtime.discardConsoleEntries";
1710    type Response = crate::EmptyReturns;
1711}
1712
1713#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1714pub struct EnableParams {}
1715
1716impl EnableParams { pub const METHOD: &'static str = "Runtime.enable"; }
1717
1718impl<'a> crate::CdpCommand<'a> for EnableParams {
1719    const METHOD: &'static str = "Runtime.enable";
1720    type Response = crate::EmptyReturns;
1721}
1722
1723/// Evaluates expression on global object.
1724
1725#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1726#[serde(rename_all = "camelCase")]
1727pub struct EvaluateParams<'a> {
1728    /// Expression to evaluate.
1729    expression: Cow<'a, str>,
1730    /// Symbolic group name that can be used to release multiple objects.
1731    #[serde(skip_serializing_if = "Option::is_none", rename = "objectGroup")]
1732    object_group: Option<Cow<'a, str>>,
1733    /// Determines whether Command Line API should be available during the evaluation.
1734    #[serde(skip_serializing_if = "Option::is_none", rename = "includeCommandLineAPI")]
1735    include_command_line_api: Option<bool>,
1736    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
1737    /// execution. Overrides 'setPauseOnException' state.
1738    #[serde(skip_serializing_if = "Option::is_none")]
1739    silent: Option<bool>,
1740    /// Specifies in which execution context to perform evaluation. If the parameter is omitted the
1741    /// evaluation will be performed in the context of the inspected page.
1742    /// This is mutually exclusive with 'uniqueContextId', which offers an
1743    /// alternative way to identify the execution context that is more reliable
1744    /// in a multi-process environment.
1745    #[serde(skip_serializing_if = "Option::is_none", rename = "contextId")]
1746    context_id: Option<ExecutionContextId>,
1747    /// Whether the result is expected to be a JSON object that should be sent by value.
1748    #[serde(skip_serializing_if = "Option::is_none", rename = "returnByValue")]
1749    return_by_value: Option<bool>,
1750    /// Whether preview should be generated for the result.
1751    #[serde(skip_serializing_if = "Option::is_none", rename = "generatePreview")]
1752    generate_preview: Option<bool>,
1753    /// Whether execution should be treated as initiated by user in the UI.
1754    #[serde(skip_serializing_if = "Option::is_none", rename = "userGesture")]
1755    user_gesture: Option<bool>,
1756    /// Whether execution should 'await' for resulting value and return once awaited promise is
1757    /// resolved.
1758    #[serde(skip_serializing_if = "Option::is_none", rename = "awaitPromise")]
1759    await_promise: Option<bool>,
1760    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
1761    /// This implies 'disableBreaks' below.
1762    #[serde(skip_serializing_if = "Option::is_none", rename = "throwOnSideEffect")]
1763    throw_on_side_effect: Option<bool>,
1764    /// Terminate execution after timing out (number of milliseconds).
1765    #[serde(skip_serializing_if = "Option::is_none")]
1766    timeout: Option<TimeDelta>,
1767    /// Disable breakpoints during execution.
1768    #[serde(skip_serializing_if = "Option::is_none", rename = "disableBreaks")]
1769    disable_breaks: Option<bool>,
1770    /// Setting this flag to true enables 'let' re-declaration and top-level 'await'.
1771    /// Note that 'let' variables can only be re-declared if they originate from
1772    /// 'replMode' themselves.
1773    #[serde(skip_serializing_if = "Option::is_none", rename = "replMode")]
1774    repl_mode: Option<bool>,
1775    /// The Content Security Policy (CSP) for the target might block 'unsafe-eval'
1776    /// which includes eval(), Function(), setTimeout() and setInterval()
1777    /// when called with non-callable arguments. This flag bypasses CSP for this
1778    /// evaluation and allows unsafe-eval. Defaults to true.
1779    #[serde(skip_serializing_if = "Option::is_none", rename = "allowUnsafeEvalBlockedByCSP")]
1780    allow_unsafe_eval_blocked_by_csp: Option<bool>,
1781    /// An alternative way to specify the execution context to evaluate in.
1782    /// Compared to contextId that may be reused across processes, this is guaranteed to be
1783    /// system-unique, so it can be used to prevent accidental evaluation of the expression
1784    /// in context different than intended (e.g. as a result of navigation across process
1785    /// boundaries).
1786    /// This is mutually exclusive with 'contextId'.
1787    #[serde(skip_serializing_if = "Option::is_none", rename = "uniqueContextId")]
1788    unique_context_id: Option<Cow<'a, str>>,
1789    /// Specifies the result serialization. If provided, overrides
1790    /// 'generatePreview' and 'returnByValue'.
1791    #[serde(skip_serializing_if = "Option::is_none", rename = "serializationOptions")]
1792    serialization_options: Option<SerializationOptions<'a>>,
1793}
1794
1795impl<'a> EvaluateParams<'a> {
1796    /// Creates a builder for this type with the required parameters:
1797    /// * `expression`: Expression to evaluate.
1798    pub fn builder(expression: impl Into<Cow<'a, str>>) -> EvaluateParamsBuilder<'a> {
1799        EvaluateParamsBuilder {
1800            expression: expression.into(),
1801            object_group: None,
1802            include_command_line_api: None,
1803            silent: None,
1804            context_id: None,
1805            return_by_value: None,
1806            generate_preview: None,
1807            user_gesture: None,
1808            await_promise: None,
1809            throw_on_side_effect: None,
1810            timeout: None,
1811            disable_breaks: None,
1812            repl_mode: None,
1813            allow_unsafe_eval_blocked_by_csp: None,
1814            unique_context_id: None,
1815            serialization_options: None,
1816        }
1817    }
1818    /// Expression to evaluate.
1819    pub fn expression(&self) -> &str { self.expression.as_ref() }
1820    /// Symbolic group name that can be used to release multiple objects.
1821    pub fn object_group(&self) -> Option<&str> { self.object_group.as_deref() }
1822    /// Determines whether Command Line API should be available during the evaluation.
1823    pub fn include_command_line_api(&self) -> Option<bool> { self.include_command_line_api }
1824    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
1825    /// execution. Overrides 'setPauseOnException' state.
1826    pub fn silent(&self) -> Option<bool> { self.silent }
1827    /// Specifies in which execution context to perform evaluation. If the parameter is omitted the
1828    /// evaluation will be performed in the context of the inspected page.
1829    /// This is mutually exclusive with 'uniqueContextId', which offers an
1830    /// alternative way to identify the execution context that is more reliable
1831    /// in a multi-process environment.
1832    pub fn context_id(&self) -> Option<&ExecutionContextId> { self.context_id.as_ref() }
1833    /// Whether the result is expected to be a JSON object that should be sent by value.
1834    pub fn return_by_value(&self) -> Option<bool> { self.return_by_value }
1835    /// Whether preview should be generated for the result.
1836    pub fn generate_preview(&self) -> Option<bool> { self.generate_preview }
1837    /// Whether execution should be treated as initiated by user in the UI.
1838    pub fn user_gesture(&self) -> Option<bool> { self.user_gesture }
1839    /// Whether execution should 'await' for resulting value and return once awaited promise is
1840    /// resolved.
1841    pub fn await_promise(&self) -> Option<bool> { self.await_promise }
1842    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
1843    /// This implies 'disableBreaks' below.
1844    pub fn throw_on_side_effect(&self) -> Option<bool> { self.throw_on_side_effect }
1845    /// Terminate execution after timing out (number of milliseconds).
1846    pub fn timeout(&self) -> Option<&TimeDelta> { self.timeout.as_ref() }
1847    /// Disable breakpoints during execution.
1848    pub fn disable_breaks(&self) -> Option<bool> { self.disable_breaks }
1849    /// Setting this flag to true enables 'let' re-declaration and top-level 'await'.
1850    /// Note that 'let' variables can only be re-declared if they originate from
1851    /// 'replMode' themselves.
1852    pub fn repl_mode(&self) -> Option<bool> { self.repl_mode }
1853    /// The Content Security Policy (CSP) for the target might block 'unsafe-eval'
1854    /// which includes eval(), Function(), setTimeout() and setInterval()
1855    /// when called with non-callable arguments. This flag bypasses CSP for this
1856    /// evaluation and allows unsafe-eval. Defaults to true.
1857    pub fn allow_unsafe_eval_blocked_by_csp(&self) -> Option<bool> { self.allow_unsafe_eval_blocked_by_csp }
1858    /// An alternative way to specify the execution context to evaluate in.
1859    /// Compared to contextId that may be reused across processes, this is guaranteed to be
1860    /// system-unique, so it can be used to prevent accidental evaluation of the expression
1861    /// in context different than intended (e.g. as a result of navigation across process
1862    /// boundaries).
1863    /// This is mutually exclusive with 'contextId'.
1864    pub fn unique_context_id(&self) -> Option<&str> { self.unique_context_id.as_deref() }
1865    /// Specifies the result serialization. If provided, overrides
1866    /// 'generatePreview' and 'returnByValue'.
1867    pub fn serialization_options(&self) -> Option<&SerializationOptions<'a>> { self.serialization_options.as_ref() }
1868}
1869
1870
1871pub struct EvaluateParamsBuilder<'a> {
1872    expression: Cow<'a, str>,
1873    object_group: Option<Cow<'a, str>>,
1874    include_command_line_api: Option<bool>,
1875    silent: Option<bool>,
1876    context_id: Option<ExecutionContextId>,
1877    return_by_value: Option<bool>,
1878    generate_preview: Option<bool>,
1879    user_gesture: Option<bool>,
1880    await_promise: Option<bool>,
1881    throw_on_side_effect: Option<bool>,
1882    timeout: Option<TimeDelta>,
1883    disable_breaks: Option<bool>,
1884    repl_mode: Option<bool>,
1885    allow_unsafe_eval_blocked_by_csp: Option<bool>,
1886    unique_context_id: Option<Cow<'a, str>>,
1887    serialization_options: Option<SerializationOptions<'a>>,
1888}
1889
1890impl<'a> EvaluateParamsBuilder<'a> {
1891    /// Symbolic group name that can be used to release multiple objects.
1892    pub fn object_group(mut self, object_group: impl Into<Cow<'a, str>>) -> Self { self.object_group = Some(object_group.into()); self }
1893    /// Determines whether Command Line API should be available during the evaluation.
1894    pub fn include_command_line_api(mut self, include_command_line_api: bool) -> Self { self.include_command_line_api = Some(include_command_line_api); self }
1895    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
1896    /// execution. Overrides 'setPauseOnException' state.
1897    pub fn silent(mut self, silent: bool) -> Self { self.silent = Some(silent); self }
1898    /// Specifies in which execution context to perform evaluation. If the parameter is omitted the
1899    /// evaluation will be performed in the context of the inspected page.
1900    /// This is mutually exclusive with 'uniqueContextId', which offers an
1901    /// alternative way to identify the execution context that is more reliable
1902    /// in a multi-process environment.
1903    pub fn context_id(mut self, context_id: ExecutionContextId) -> Self { self.context_id = Some(context_id); self }
1904    /// Whether the result is expected to be a JSON object that should be sent by value.
1905    pub fn return_by_value(mut self, return_by_value: bool) -> Self { self.return_by_value = Some(return_by_value); self }
1906    /// Whether preview should be generated for the result.
1907    pub fn generate_preview(mut self, generate_preview: bool) -> Self { self.generate_preview = Some(generate_preview); self }
1908    /// Whether execution should be treated as initiated by user in the UI.
1909    pub fn user_gesture(mut self, user_gesture: bool) -> Self { self.user_gesture = Some(user_gesture); self }
1910    /// Whether execution should 'await' for resulting value and return once awaited promise is
1911    /// resolved.
1912    pub fn await_promise(mut self, await_promise: bool) -> Self { self.await_promise = Some(await_promise); self }
1913    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
1914    /// This implies 'disableBreaks' below.
1915    pub fn throw_on_side_effect(mut self, throw_on_side_effect: bool) -> Self { self.throw_on_side_effect = Some(throw_on_side_effect); self }
1916    /// Terminate execution after timing out (number of milliseconds).
1917    pub fn timeout(mut self, timeout: TimeDelta) -> Self { self.timeout = Some(timeout); self }
1918    /// Disable breakpoints during execution.
1919    pub fn disable_breaks(mut self, disable_breaks: bool) -> Self { self.disable_breaks = Some(disable_breaks); self }
1920    /// Setting this flag to true enables 'let' re-declaration and top-level 'await'.
1921    /// Note that 'let' variables can only be re-declared if they originate from
1922    /// 'replMode' themselves.
1923    pub fn repl_mode(mut self, repl_mode: bool) -> Self { self.repl_mode = Some(repl_mode); self }
1924    /// The Content Security Policy (CSP) for the target might block 'unsafe-eval'
1925    /// which includes eval(), Function(), setTimeout() and setInterval()
1926    /// when called with non-callable arguments. This flag bypasses CSP for this
1927    /// evaluation and allows unsafe-eval. Defaults to true.
1928    pub fn allow_unsafe_eval_blocked_by_csp(mut self, allow_unsafe_eval_blocked_by_csp: bool) -> Self { self.allow_unsafe_eval_blocked_by_csp = Some(allow_unsafe_eval_blocked_by_csp); self }
1929    /// An alternative way to specify the execution context to evaluate in.
1930    /// Compared to contextId that may be reused across processes, this is guaranteed to be
1931    /// system-unique, so it can be used to prevent accidental evaluation of the expression
1932    /// in context different than intended (e.g. as a result of navigation across process
1933    /// boundaries).
1934    /// This is mutually exclusive with 'contextId'.
1935    pub fn unique_context_id(mut self, unique_context_id: impl Into<Cow<'a, str>>) -> Self { self.unique_context_id = Some(unique_context_id.into()); self }
1936    /// Specifies the result serialization. If provided, overrides
1937    /// 'generatePreview' and 'returnByValue'.
1938    pub fn serialization_options(mut self, serialization_options: SerializationOptions<'a>) -> Self { self.serialization_options = Some(serialization_options); self }
1939    pub fn build(self) -> EvaluateParams<'a> {
1940        EvaluateParams {
1941            expression: self.expression,
1942            object_group: self.object_group,
1943            include_command_line_api: self.include_command_line_api,
1944            silent: self.silent,
1945            context_id: self.context_id,
1946            return_by_value: self.return_by_value,
1947            generate_preview: self.generate_preview,
1948            user_gesture: self.user_gesture,
1949            await_promise: self.await_promise,
1950            throw_on_side_effect: self.throw_on_side_effect,
1951            timeout: self.timeout,
1952            disable_breaks: self.disable_breaks,
1953            repl_mode: self.repl_mode,
1954            allow_unsafe_eval_blocked_by_csp: self.allow_unsafe_eval_blocked_by_csp,
1955            unique_context_id: self.unique_context_id,
1956            serialization_options: self.serialization_options,
1957        }
1958    }
1959}
1960
1961/// Evaluates expression on global object.
1962
1963#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1964#[serde(rename_all = "camelCase")]
1965pub struct EvaluateReturns<'a> {
1966    /// Evaluation result.
1967    result: RemoteObject<'a>,
1968    /// Exception details.
1969    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
1970    exception_details: Option<ExceptionDetails<'a>>,
1971}
1972
1973impl<'a> EvaluateReturns<'a> {
1974    /// Creates a builder for this type with the required parameters:
1975    /// * `result`: Evaluation result.
1976    pub fn builder(result: RemoteObject<'a>) -> EvaluateReturnsBuilder<'a> {
1977        EvaluateReturnsBuilder {
1978            result: result,
1979            exception_details: None,
1980        }
1981    }
1982    /// Evaluation result.
1983    pub fn result(&self) -> &RemoteObject<'a> { &self.result }
1984    /// Exception details.
1985    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
1986}
1987
1988
1989pub struct EvaluateReturnsBuilder<'a> {
1990    result: RemoteObject<'a>,
1991    exception_details: Option<ExceptionDetails<'a>>,
1992}
1993
1994impl<'a> EvaluateReturnsBuilder<'a> {
1995    /// Exception details.
1996    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
1997    pub fn build(self) -> EvaluateReturns<'a> {
1998        EvaluateReturns {
1999            result: self.result,
2000            exception_details: self.exception_details,
2001        }
2002    }
2003}
2004
2005impl<'a> EvaluateParams<'a> { pub const METHOD: &'static str = "Runtime.evaluate"; }
2006
2007impl<'a> crate::CdpCommand<'a> for EvaluateParams<'a> {
2008    const METHOD: &'static str = "Runtime.evaluate";
2009    type Response = EvaluateReturns<'a>;
2010}
2011
2012/// Returns the isolate id.
2013
2014#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2015#[serde(rename_all = "camelCase")]
2016pub struct GetIsolateIdReturns<'a> {
2017    /// The isolate id.
2018    id: Cow<'a, str>,
2019}
2020
2021impl<'a> GetIsolateIdReturns<'a> {
2022    /// Creates a builder for this type with the required parameters:
2023    /// * `id`: The isolate id.
2024    pub fn builder(id: impl Into<Cow<'a, str>>) -> GetIsolateIdReturnsBuilder<'a> {
2025        GetIsolateIdReturnsBuilder {
2026            id: id.into(),
2027        }
2028    }
2029    /// The isolate id.
2030    pub fn id(&self) -> &str { self.id.as_ref() }
2031}
2032
2033
2034pub struct GetIsolateIdReturnsBuilder<'a> {
2035    id: Cow<'a, str>,
2036}
2037
2038impl<'a> GetIsolateIdReturnsBuilder<'a> {
2039    pub fn build(self) -> GetIsolateIdReturns<'a> {
2040        GetIsolateIdReturns {
2041            id: self.id,
2042        }
2043    }
2044}
2045
2046#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2047pub struct GetIsolateIdParams {}
2048
2049impl GetIsolateIdParams { pub const METHOD: &'static str = "Runtime.getIsolateId"; }
2050
2051impl<'a> crate::CdpCommand<'a> for GetIsolateIdParams {
2052    const METHOD: &'static str = "Runtime.getIsolateId";
2053    type Response = GetIsolateIdReturns<'a>;
2054}
2055
2056/// Returns the JavaScript heap usage.
2057/// It is the total usage of the corresponding isolate not scoped to a particular Runtime.
2058
2059#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2060#[serde(rename_all = "camelCase")]
2061pub struct GetHeapUsageReturns {
2062    /// Used JavaScript heap size in bytes.
2063    #[serde(rename = "usedSize")]
2064    used_size: f64,
2065    /// Allocated JavaScript heap size in bytes.
2066    #[serde(rename = "totalSize")]
2067    total_size: f64,
2068    /// Used size in bytes in the embedder's garbage-collected heap.
2069    #[serde(rename = "embedderHeapUsedSize")]
2070    embedder_heap_used_size: f64,
2071    /// Size in bytes of backing storage for array buffers and external strings.
2072    #[serde(rename = "backingStorageSize")]
2073    backing_storage_size: f64,
2074}
2075
2076impl GetHeapUsageReturns {
2077    /// Creates a builder for this type with the required parameters:
2078    /// * `used_size`: Used JavaScript heap size in bytes.
2079    /// * `total_size`: Allocated JavaScript heap size in bytes.
2080    /// * `embedder_heap_used_size`: Used size in bytes in the embedder's garbage-collected heap.
2081    /// * `backing_storage_size`: Size in bytes of backing storage for array buffers and external strings.
2082    pub fn builder(used_size: f64, total_size: f64, embedder_heap_used_size: f64, backing_storage_size: f64) -> GetHeapUsageReturnsBuilder {
2083        GetHeapUsageReturnsBuilder {
2084            used_size: used_size,
2085            total_size: total_size,
2086            embedder_heap_used_size: embedder_heap_used_size,
2087            backing_storage_size: backing_storage_size,
2088        }
2089    }
2090    /// Used JavaScript heap size in bytes.
2091    pub fn used_size(&self) -> f64 { self.used_size }
2092    /// Allocated JavaScript heap size in bytes.
2093    pub fn total_size(&self) -> f64 { self.total_size }
2094    /// Used size in bytes in the embedder's garbage-collected heap.
2095    pub fn embedder_heap_used_size(&self) -> f64 { self.embedder_heap_used_size }
2096    /// Size in bytes of backing storage for array buffers and external strings.
2097    pub fn backing_storage_size(&self) -> f64 { self.backing_storage_size }
2098}
2099
2100
2101pub struct GetHeapUsageReturnsBuilder {
2102    used_size: f64,
2103    total_size: f64,
2104    embedder_heap_used_size: f64,
2105    backing_storage_size: f64,
2106}
2107
2108impl GetHeapUsageReturnsBuilder {
2109    pub fn build(self) -> GetHeapUsageReturns {
2110        GetHeapUsageReturns {
2111            used_size: self.used_size,
2112            total_size: self.total_size,
2113            embedder_heap_used_size: self.embedder_heap_used_size,
2114            backing_storage_size: self.backing_storage_size,
2115        }
2116    }
2117}
2118
2119#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2120pub struct GetHeapUsageParams {}
2121
2122impl GetHeapUsageParams { pub const METHOD: &'static str = "Runtime.getHeapUsage"; }
2123
2124impl<'a> crate::CdpCommand<'a> for GetHeapUsageParams {
2125    const METHOD: &'static str = "Runtime.getHeapUsage";
2126    type Response = GetHeapUsageReturns;
2127}
2128
2129/// Returns properties of a given object. Object group of the result is inherited from the target
2130/// object.
2131
2132#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2133#[serde(rename_all = "camelCase")]
2134pub struct GetPropertiesParams<'a> {
2135    /// Identifier of the object to return properties for.
2136    #[serde(rename = "objectId")]
2137    object_id: RemoteObjectId<'a>,
2138    /// If true, returns properties belonging only to the element itself, not to its prototype
2139    /// chain.
2140    #[serde(skip_serializing_if = "Option::is_none", rename = "ownProperties")]
2141    own_properties: Option<bool>,
2142    /// If true, returns accessor properties (with getter/setter) only; internal properties are not
2143    /// returned either.
2144    #[serde(skip_serializing_if = "Option::is_none", rename = "accessorPropertiesOnly")]
2145    accessor_properties_only: Option<bool>,
2146    /// Whether preview should be generated for the results.
2147    #[serde(skip_serializing_if = "Option::is_none", rename = "generatePreview")]
2148    generate_preview: Option<bool>,
2149    /// If true, returns non-indexed properties only.
2150    #[serde(skip_serializing_if = "Option::is_none", rename = "nonIndexedPropertiesOnly")]
2151    non_indexed_properties_only: Option<bool>,
2152}
2153
2154impl<'a> GetPropertiesParams<'a> {
2155    /// Creates a builder for this type with the required parameters:
2156    /// * `object_id`: Identifier of the object to return properties for.
2157    pub fn builder(object_id: impl Into<RemoteObjectId<'a>>) -> GetPropertiesParamsBuilder<'a> {
2158        GetPropertiesParamsBuilder {
2159            object_id: object_id.into(),
2160            own_properties: None,
2161            accessor_properties_only: None,
2162            generate_preview: None,
2163            non_indexed_properties_only: None,
2164        }
2165    }
2166    /// Identifier of the object to return properties for.
2167    pub fn object_id(&self) -> &RemoteObjectId<'a> { &self.object_id }
2168    /// If true, returns properties belonging only to the element itself, not to its prototype
2169    /// chain.
2170    pub fn own_properties(&self) -> Option<bool> { self.own_properties }
2171    /// If true, returns accessor properties (with getter/setter) only; internal properties are not
2172    /// returned either.
2173    pub fn accessor_properties_only(&self) -> Option<bool> { self.accessor_properties_only }
2174    /// Whether preview should be generated for the results.
2175    pub fn generate_preview(&self) -> Option<bool> { self.generate_preview }
2176    /// If true, returns non-indexed properties only.
2177    pub fn non_indexed_properties_only(&self) -> Option<bool> { self.non_indexed_properties_only }
2178}
2179
2180
2181pub struct GetPropertiesParamsBuilder<'a> {
2182    object_id: RemoteObjectId<'a>,
2183    own_properties: Option<bool>,
2184    accessor_properties_only: Option<bool>,
2185    generate_preview: Option<bool>,
2186    non_indexed_properties_only: Option<bool>,
2187}
2188
2189impl<'a> GetPropertiesParamsBuilder<'a> {
2190    /// If true, returns properties belonging only to the element itself, not to its prototype
2191    /// chain.
2192    pub fn own_properties(mut self, own_properties: bool) -> Self { self.own_properties = Some(own_properties); self }
2193    /// If true, returns accessor properties (with getter/setter) only; internal properties are not
2194    /// returned either.
2195    pub fn accessor_properties_only(mut self, accessor_properties_only: bool) -> Self { self.accessor_properties_only = Some(accessor_properties_only); self }
2196    /// Whether preview should be generated for the results.
2197    pub fn generate_preview(mut self, generate_preview: bool) -> Self { self.generate_preview = Some(generate_preview); self }
2198    /// If true, returns non-indexed properties only.
2199    pub fn non_indexed_properties_only(mut self, non_indexed_properties_only: bool) -> Self { self.non_indexed_properties_only = Some(non_indexed_properties_only); self }
2200    pub fn build(self) -> GetPropertiesParams<'a> {
2201        GetPropertiesParams {
2202            object_id: self.object_id,
2203            own_properties: self.own_properties,
2204            accessor_properties_only: self.accessor_properties_only,
2205            generate_preview: self.generate_preview,
2206            non_indexed_properties_only: self.non_indexed_properties_only,
2207        }
2208    }
2209}
2210
2211/// Returns properties of a given object. Object group of the result is inherited from the target
2212/// object.
2213
2214#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2215#[serde(rename_all = "camelCase")]
2216pub struct GetPropertiesReturns<'a> {
2217    /// Object properties.
2218    result: Vec<PropertyDescriptor<'a>>,
2219    /// Internal object properties (only of the element itself).
2220    #[serde(skip_serializing_if = "Option::is_none", rename = "internalProperties")]
2221    internal_properties: Option<Vec<InternalPropertyDescriptor<'a>>>,
2222    /// Object private properties.
2223    #[serde(skip_serializing_if = "Option::is_none", rename = "privateProperties")]
2224    private_properties: Option<Vec<PrivatePropertyDescriptor<'a>>>,
2225    /// Exception details.
2226    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
2227    exception_details: Option<ExceptionDetails<'a>>,
2228}
2229
2230impl<'a> GetPropertiesReturns<'a> {
2231    /// Creates a builder for this type with the required parameters:
2232    /// * `result`: Object properties.
2233    pub fn builder(result: Vec<PropertyDescriptor<'a>>) -> GetPropertiesReturnsBuilder<'a> {
2234        GetPropertiesReturnsBuilder {
2235            result: result,
2236            internal_properties: None,
2237            private_properties: None,
2238            exception_details: None,
2239        }
2240    }
2241    /// Object properties.
2242    pub fn result(&self) -> &[PropertyDescriptor<'a>] { &self.result }
2243    /// Internal object properties (only of the element itself).
2244    pub fn internal_properties(&self) -> Option<&[InternalPropertyDescriptor<'a>]> { self.internal_properties.as_deref() }
2245    /// Object private properties.
2246    pub fn private_properties(&self) -> Option<&[PrivatePropertyDescriptor<'a>]> { self.private_properties.as_deref() }
2247    /// Exception details.
2248    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
2249}
2250
2251
2252pub struct GetPropertiesReturnsBuilder<'a> {
2253    result: Vec<PropertyDescriptor<'a>>,
2254    internal_properties: Option<Vec<InternalPropertyDescriptor<'a>>>,
2255    private_properties: Option<Vec<PrivatePropertyDescriptor<'a>>>,
2256    exception_details: Option<ExceptionDetails<'a>>,
2257}
2258
2259impl<'a> GetPropertiesReturnsBuilder<'a> {
2260    /// Internal object properties (only of the element itself).
2261    pub fn internal_properties(mut self, internal_properties: Vec<InternalPropertyDescriptor<'a>>) -> Self { self.internal_properties = Some(internal_properties); self }
2262    /// Object private properties.
2263    pub fn private_properties(mut self, private_properties: Vec<PrivatePropertyDescriptor<'a>>) -> Self { self.private_properties = Some(private_properties); self }
2264    /// Exception details.
2265    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
2266    pub fn build(self) -> GetPropertiesReturns<'a> {
2267        GetPropertiesReturns {
2268            result: self.result,
2269            internal_properties: self.internal_properties,
2270            private_properties: self.private_properties,
2271            exception_details: self.exception_details,
2272        }
2273    }
2274}
2275
2276impl<'a> GetPropertiesParams<'a> { pub const METHOD: &'static str = "Runtime.getProperties"; }
2277
2278impl<'a> crate::CdpCommand<'a> for GetPropertiesParams<'a> {
2279    const METHOD: &'static str = "Runtime.getProperties";
2280    type Response = GetPropertiesReturns<'a>;
2281}
2282
2283/// Returns all let, const and class variables from global scope.
2284
2285#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2286#[serde(rename_all = "camelCase")]
2287pub struct GlobalLexicalScopeNamesParams {
2288    /// Specifies in which execution context to lookup global scope variables.
2289    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextId")]
2290    execution_context_id: Option<ExecutionContextId>,
2291}
2292
2293impl GlobalLexicalScopeNamesParams {
2294    /// Creates a builder for this type.
2295    pub fn builder() -> GlobalLexicalScopeNamesParamsBuilder {
2296        GlobalLexicalScopeNamesParamsBuilder {
2297            execution_context_id: None,
2298        }
2299    }
2300    /// Specifies in which execution context to lookup global scope variables.
2301    pub fn execution_context_id(&self) -> Option<&ExecutionContextId> { self.execution_context_id.as_ref() }
2302}
2303
2304#[derive(Default)]
2305pub struct GlobalLexicalScopeNamesParamsBuilder {
2306    execution_context_id: Option<ExecutionContextId>,
2307}
2308
2309impl GlobalLexicalScopeNamesParamsBuilder {
2310    /// Specifies in which execution context to lookup global scope variables.
2311    pub fn execution_context_id(mut self, execution_context_id: ExecutionContextId) -> Self { self.execution_context_id = Some(execution_context_id); self }
2312    pub fn build(self) -> GlobalLexicalScopeNamesParams {
2313        GlobalLexicalScopeNamesParams {
2314            execution_context_id: self.execution_context_id,
2315        }
2316    }
2317}
2318
2319/// Returns all let, const and class variables from global scope.
2320
2321#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2322#[serde(rename_all = "camelCase")]
2323pub struct GlobalLexicalScopeNamesReturns<'a> {
2324    names: Vec<Cow<'a, str>>,
2325}
2326
2327impl<'a> GlobalLexicalScopeNamesReturns<'a> {
2328    /// Creates a builder for this type with the required parameters:
2329    /// * `names`: 
2330    pub fn builder(names: Vec<Cow<'a, str>>) -> GlobalLexicalScopeNamesReturnsBuilder<'a> {
2331        GlobalLexicalScopeNamesReturnsBuilder {
2332            names: names,
2333        }
2334    }
2335    pub fn names(&self) -> &[Cow<'a, str>] { &self.names }
2336}
2337
2338
2339pub struct GlobalLexicalScopeNamesReturnsBuilder<'a> {
2340    names: Vec<Cow<'a, str>>,
2341}
2342
2343impl<'a> GlobalLexicalScopeNamesReturnsBuilder<'a> {
2344    pub fn build(self) -> GlobalLexicalScopeNamesReturns<'a> {
2345        GlobalLexicalScopeNamesReturns {
2346            names: self.names,
2347        }
2348    }
2349}
2350
2351impl GlobalLexicalScopeNamesParams { pub const METHOD: &'static str = "Runtime.globalLexicalScopeNames"; }
2352
2353impl<'a> crate::CdpCommand<'a> for GlobalLexicalScopeNamesParams {
2354    const METHOD: &'static str = "Runtime.globalLexicalScopeNames";
2355    type Response = GlobalLexicalScopeNamesReturns<'a>;
2356}
2357
2358
2359#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2360#[serde(rename_all = "camelCase")]
2361pub struct QueryObjectsParams<'a> {
2362    /// Identifier of the prototype to return objects for.
2363    #[serde(rename = "prototypeObjectId")]
2364    prototype_object_id: RemoteObjectId<'a>,
2365    /// Symbolic group name that can be used to release the results.
2366    #[serde(skip_serializing_if = "Option::is_none", rename = "objectGroup")]
2367    object_group: Option<Cow<'a, str>>,
2368}
2369
2370impl<'a> QueryObjectsParams<'a> {
2371    /// Creates a builder for this type with the required parameters:
2372    /// * `prototype_object_id`: Identifier of the prototype to return objects for.
2373    pub fn builder(prototype_object_id: impl Into<RemoteObjectId<'a>>) -> QueryObjectsParamsBuilder<'a> {
2374        QueryObjectsParamsBuilder {
2375            prototype_object_id: prototype_object_id.into(),
2376            object_group: None,
2377        }
2378    }
2379    /// Identifier of the prototype to return objects for.
2380    pub fn prototype_object_id(&self) -> &RemoteObjectId<'a> { &self.prototype_object_id }
2381    /// Symbolic group name that can be used to release the results.
2382    pub fn object_group(&self) -> Option<&str> { self.object_group.as_deref() }
2383}
2384
2385
2386pub struct QueryObjectsParamsBuilder<'a> {
2387    prototype_object_id: RemoteObjectId<'a>,
2388    object_group: Option<Cow<'a, str>>,
2389}
2390
2391impl<'a> QueryObjectsParamsBuilder<'a> {
2392    /// Symbolic group name that can be used to release the results.
2393    pub fn object_group(mut self, object_group: impl Into<Cow<'a, str>>) -> Self { self.object_group = Some(object_group.into()); self }
2394    pub fn build(self) -> QueryObjectsParams<'a> {
2395        QueryObjectsParams {
2396            prototype_object_id: self.prototype_object_id,
2397            object_group: self.object_group,
2398        }
2399    }
2400}
2401
2402
2403#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2404#[serde(rename_all = "camelCase")]
2405pub struct QueryObjectsReturns<'a> {
2406    /// Array with objects.
2407    objects: RemoteObject<'a>,
2408}
2409
2410impl<'a> QueryObjectsReturns<'a> {
2411    /// Creates a builder for this type with the required parameters:
2412    /// * `objects`: Array with objects.
2413    pub fn builder(objects: RemoteObject<'a>) -> QueryObjectsReturnsBuilder<'a> {
2414        QueryObjectsReturnsBuilder {
2415            objects: objects,
2416        }
2417    }
2418    /// Array with objects.
2419    pub fn objects(&self) -> &RemoteObject<'a> { &self.objects }
2420}
2421
2422
2423pub struct QueryObjectsReturnsBuilder<'a> {
2424    objects: RemoteObject<'a>,
2425}
2426
2427impl<'a> QueryObjectsReturnsBuilder<'a> {
2428    pub fn build(self) -> QueryObjectsReturns<'a> {
2429        QueryObjectsReturns {
2430            objects: self.objects,
2431        }
2432    }
2433}
2434
2435impl<'a> QueryObjectsParams<'a> { pub const METHOD: &'static str = "Runtime.queryObjects"; }
2436
2437impl<'a> crate::CdpCommand<'a> for QueryObjectsParams<'a> {
2438    const METHOD: &'static str = "Runtime.queryObjects";
2439    type Response = QueryObjectsReturns<'a>;
2440}
2441
2442/// Releases remote object with given id.
2443
2444#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2445#[serde(rename_all = "camelCase")]
2446pub struct ReleaseObjectParams<'a> {
2447    /// Identifier of the object to release.
2448    #[serde(rename = "objectId")]
2449    object_id: RemoteObjectId<'a>,
2450}
2451
2452impl<'a> ReleaseObjectParams<'a> {
2453    /// Creates a builder for this type with the required parameters:
2454    /// * `object_id`: Identifier of the object to release.
2455    pub fn builder(object_id: impl Into<RemoteObjectId<'a>>) -> ReleaseObjectParamsBuilder<'a> {
2456        ReleaseObjectParamsBuilder {
2457            object_id: object_id.into(),
2458        }
2459    }
2460    /// Identifier of the object to release.
2461    pub fn object_id(&self) -> &RemoteObjectId<'a> { &self.object_id }
2462}
2463
2464
2465pub struct ReleaseObjectParamsBuilder<'a> {
2466    object_id: RemoteObjectId<'a>,
2467}
2468
2469impl<'a> ReleaseObjectParamsBuilder<'a> {
2470    pub fn build(self) -> ReleaseObjectParams<'a> {
2471        ReleaseObjectParams {
2472            object_id: self.object_id,
2473        }
2474    }
2475}
2476
2477impl<'a> ReleaseObjectParams<'a> { pub const METHOD: &'static str = "Runtime.releaseObject"; }
2478
2479impl<'a> crate::CdpCommand<'a> for ReleaseObjectParams<'a> {
2480    const METHOD: &'static str = "Runtime.releaseObject";
2481    type Response = crate::EmptyReturns;
2482}
2483
2484/// Releases all remote objects that belong to a given group.
2485
2486#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2487#[serde(rename_all = "camelCase")]
2488pub struct ReleaseObjectGroupParams<'a> {
2489    /// Symbolic object group name.
2490    #[serde(rename = "objectGroup")]
2491    object_group: Cow<'a, str>,
2492}
2493
2494impl<'a> ReleaseObjectGroupParams<'a> {
2495    /// Creates a builder for this type with the required parameters:
2496    /// * `object_group`: Symbolic object group name.
2497    pub fn builder(object_group: impl Into<Cow<'a, str>>) -> ReleaseObjectGroupParamsBuilder<'a> {
2498        ReleaseObjectGroupParamsBuilder {
2499            object_group: object_group.into(),
2500        }
2501    }
2502    /// Symbolic object group name.
2503    pub fn object_group(&self) -> &str { self.object_group.as_ref() }
2504}
2505
2506
2507pub struct ReleaseObjectGroupParamsBuilder<'a> {
2508    object_group: Cow<'a, str>,
2509}
2510
2511impl<'a> ReleaseObjectGroupParamsBuilder<'a> {
2512    pub fn build(self) -> ReleaseObjectGroupParams<'a> {
2513        ReleaseObjectGroupParams {
2514            object_group: self.object_group,
2515        }
2516    }
2517}
2518
2519impl<'a> ReleaseObjectGroupParams<'a> { pub const METHOD: &'static str = "Runtime.releaseObjectGroup"; }
2520
2521impl<'a> crate::CdpCommand<'a> for ReleaseObjectGroupParams<'a> {
2522    const METHOD: &'static str = "Runtime.releaseObjectGroup";
2523    type Response = crate::EmptyReturns;
2524}
2525
2526#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2527pub struct RunIfWaitingForDebuggerParams {}
2528
2529impl RunIfWaitingForDebuggerParams { pub const METHOD: &'static str = "Runtime.runIfWaitingForDebugger"; }
2530
2531impl<'a> crate::CdpCommand<'a> for RunIfWaitingForDebuggerParams {
2532    const METHOD: &'static str = "Runtime.runIfWaitingForDebugger";
2533    type Response = crate::EmptyReturns;
2534}
2535
2536/// Runs script with given id in a given context.
2537
2538#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2539#[serde(rename_all = "camelCase")]
2540pub struct RunScriptParams<'a> {
2541    /// Id of the script to run.
2542    #[serde(rename = "scriptId")]
2543    script_id: ScriptId<'a>,
2544    /// Specifies in which execution context to perform script run. If the parameter is omitted the
2545    /// evaluation will be performed in the context of the inspected page.
2546    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextId")]
2547    execution_context_id: Option<ExecutionContextId>,
2548    /// Symbolic group name that can be used to release multiple objects.
2549    #[serde(skip_serializing_if = "Option::is_none", rename = "objectGroup")]
2550    object_group: Option<Cow<'a, str>>,
2551    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
2552    /// execution. Overrides 'setPauseOnException' state.
2553    #[serde(skip_serializing_if = "Option::is_none")]
2554    silent: Option<bool>,
2555    /// Determines whether Command Line API should be available during the evaluation.
2556    #[serde(skip_serializing_if = "Option::is_none", rename = "includeCommandLineAPI")]
2557    include_command_line_api: Option<bool>,
2558    /// Whether the result is expected to be a JSON object which should be sent by value.
2559    #[serde(skip_serializing_if = "Option::is_none", rename = "returnByValue")]
2560    return_by_value: Option<bool>,
2561    /// Whether preview should be generated for the result.
2562    #[serde(skip_serializing_if = "Option::is_none", rename = "generatePreview")]
2563    generate_preview: Option<bool>,
2564    /// Whether execution should 'await' for resulting value and return once awaited promise is
2565    /// resolved.
2566    #[serde(skip_serializing_if = "Option::is_none", rename = "awaitPromise")]
2567    await_promise: Option<bool>,
2568}
2569
2570impl<'a> RunScriptParams<'a> {
2571    /// Creates a builder for this type with the required parameters:
2572    /// * `script_id`: Id of the script to run.
2573    pub fn builder(script_id: impl Into<ScriptId<'a>>) -> RunScriptParamsBuilder<'a> {
2574        RunScriptParamsBuilder {
2575            script_id: script_id.into(),
2576            execution_context_id: None,
2577            object_group: None,
2578            silent: None,
2579            include_command_line_api: None,
2580            return_by_value: None,
2581            generate_preview: None,
2582            await_promise: None,
2583        }
2584    }
2585    /// Id of the script to run.
2586    pub fn script_id(&self) -> &ScriptId<'a> { &self.script_id }
2587    /// Specifies in which execution context to perform script run. If the parameter is omitted the
2588    /// evaluation will be performed in the context of the inspected page.
2589    pub fn execution_context_id(&self) -> Option<&ExecutionContextId> { self.execution_context_id.as_ref() }
2590    /// Symbolic group name that can be used to release multiple objects.
2591    pub fn object_group(&self) -> Option<&str> { self.object_group.as_deref() }
2592    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
2593    /// execution. Overrides 'setPauseOnException' state.
2594    pub fn silent(&self) -> Option<bool> { self.silent }
2595    /// Determines whether Command Line API should be available during the evaluation.
2596    pub fn include_command_line_api(&self) -> Option<bool> { self.include_command_line_api }
2597    /// Whether the result is expected to be a JSON object which should be sent by value.
2598    pub fn return_by_value(&self) -> Option<bool> { self.return_by_value }
2599    /// Whether preview should be generated for the result.
2600    pub fn generate_preview(&self) -> Option<bool> { self.generate_preview }
2601    /// Whether execution should 'await' for resulting value and return once awaited promise is
2602    /// resolved.
2603    pub fn await_promise(&self) -> Option<bool> { self.await_promise }
2604}
2605
2606
2607pub struct RunScriptParamsBuilder<'a> {
2608    script_id: ScriptId<'a>,
2609    execution_context_id: Option<ExecutionContextId>,
2610    object_group: Option<Cow<'a, str>>,
2611    silent: Option<bool>,
2612    include_command_line_api: Option<bool>,
2613    return_by_value: Option<bool>,
2614    generate_preview: Option<bool>,
2615    await_promise: Option<bool>,
2616}
2617
2618impl<'a> RunScriptParamsBuilder<'a> {
2619    /// Specifies in which execution context to perform script run. If the parameter is omitted the
2620    /// evaluation will be performed in the context of the inspected page.
2621    pub fn execution_context_id(mut self, execution_context_id: ExecutionContextId) -> Self { self.execution_context_id = Some(execution_context_id); self }
2622    /// Symbolic group name that can be used to release multiple objects.
2623    pub fn object_group(mut self, object_group: impl Into<Cow<'a, str>>) -> Self { self.object_group = Some(object_group.into()); self }
2624    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
2625    /// execution. Overrides 'setPauseOnException' state.
2626    pub fn silent(mut self, silent: bool) -> Self { self.silent = Some(silent); self }
2627    /// Determines whether Command Line API should be available during the evaluation.
2628    pub fn include_command_line_api(mut self, include_command_line_api: bool) -> Self { self.include_command_line_api = Some(include_command_line_api); self }
2629    /// Whether the result is expected to be a JSON object which should be sent by value.
2630    pub fn return_by_value(mut self, return_by_value: bool) -> Self { self.return_by_value = Some(return_by_value); self }
2631    /// Whether preview should be generated for the result.
2632    pub fn generate_preview(mut self, generate_preview: bool) -> Self { self.generate_preview = Some(generate_preview); self }
2633    /// Whether execution should 'await' for resulting value and return once awaited promise is
2634    /// resolved.
2635    pub fn await_promise(mut self, await_promise: bool) -> Self { self.await_promise = Some(await_promise); self }
2636    pub fn build(self) -> RunScriptParams<'a> {
2637        RunScriptParams {
2638            script_id: self.script_id,
2639            execution_context_id: self.execution_context_id,
2640            object_group: self.object_group,
2641            silent: self.silent,
2642            include_command_line_api: self.include_command_line_api,
2643            return_by_value: self.return_by_value,
2644            generate_preview: self.generate_preview,
2645            await_promise: self.await_promise,
2646        }
2647    }
2648}
2649
2650/// Runs script with given id in a given context.
2651
2652#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2653#[serde(rename_all = "camelCase")]
2654pub struct RunScriptReturns<'a> {
2655    /// Run result.
2656    result: RemoteObject<'a>,
2657    /// Exception details.
2658    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
2659    exception_details: Option<ExceptionDetails<'a>>,
2660}
2661
2662impl<'a> RunScriptReturns<'a> {
2663    /// Creates a builder for this type with the required parameters:
2664    /// * `result`: Run result.
2665    pub fn builder(result: RemoteObject<'a>) -> RunScriptReturnsBuilder<'a> {
2666        RunScriptReturnsBuilder {
2667            result: result,
2668            exception_details: None,
2669        }
2670    }
2671    /// Run result.
2672    pub fn result(&self) -> &RemoteObject<'a> { &self.result }
2673    /// Exception details.
2674    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
2675}
2676
2677
2678pub struct RunScriptReturnsBuilder<'a> {
2679    result: RemoteObject<'a>,
2680    exception_details: Option<ExceptionDetails<'a>>,
2681}
2682
2683impl<'a> RunScriptReturnsBuilder<'a> {
2684    /// Exception details.
2685    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
2686    pub fn build(self) -> RunScriptReturns<'a> {
2687        RunScriptReturns {
2688            result: self.result,
2689            exception_details: self.exception_details,
2690        }
2691    }
2692}
2693
2694impl<'a> RunScriptParams<'a> { pub const METHOD: &'static str = "Runtime.runScript"; }
2695
2696impl<'a> crate::CdpCommand<'a> for RunScriptParams<'a> {
2697    const METHOD: &'static str = "Runtime.runScript";
2698    type Response = RunScriptReturns<'a>;
2699}
2700
2701/// Enables or disables async call stacks tracking.
2702
2703#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2704#[serde(rename_all = "camelCase")]
2705pub struct SetAsyncCallStackDepthParams {
2706    /// Maximum depth of async call stacks. Setting to '0' will effectively disable collecting async
2707    /// call stacks (default).
2708    #[serde(rename = "maxDepth")]
2709    max_depth: i64,
2710}
2711
2712impl SetAsyncCallStackDepthParams {
2713    /// Creates a builder for this type with the required parameters:
2714    /// * `max_depth`: Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async call stacks (default).
2715    pub fn builder(max_depth: i64) -> SetAsyncCallStackDepthParamsBuilder {
2716        SetAsyncCallStackDepthParamsBuilder {
2717            max_depth: max_depth,
2718        }
2719    }
2720    /// Maximum depth of async call stacks. Setting to '0' will effectively disable collecting async
2721    /// call stacks (default).
2722    pub fn max_depth(&self) -> i64 { self.max_depth }
2723}
2724
2725
2726pub struct SetAsyncCallStackDepthParamsBuilder {
2727    max_depth: i64,
2728}
2729
2730impl SetAsyncCallStackDepthParamsBuilder {
2731    pub fn build(self) -> SetAsyncCallStackDepthParams {
2732        SetAsyncCallStackDepthParams {
2733            max_depth: self.max_depth,
2734        }
2735    }
2736}
2737
2738impl SetAsyncCallStackDepthParams { pub const METHOD: &'static str = "Runtime.setAsyncCallStackDepth"; }
2739
2740impl<'a> crate::CdpCommand<'a> for SetAsyncCallStackDepthParams {
2741    const METHOD: &'static str = "Runtime.setAsyncCallStackDepth";
2742    type Response = crate::EmptyReturns;
2743}
2744
2745
2746#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2747#[serde(rename_all = "camelCase")]
2748pub struct SetCustomObjectFormatterEnabledParams {
2749    enabled: bool,
2750}
2751
2752impl SetCustomObjectFormatterEnabledParams {
2753    /// Creates a builder for this type with the required parameters:
2754    /// * `enabled`: 
2755    pub fn builder(enabled: bool) -> SetCustomObjectFormatterEnabledParamsBuilder {
2756        SetCustomObjectFormatterEnabledParamsBuilder {
2757            enabled: enabled,
2758        }
2759    }
2760    pub fn enabled(&self) -> bool { self.enabled }
2761}
2762
2763
2764pub struct SetCustomObjectFormatterEnabledParamsBuilder {
2765    enabled: bool,
2766}
2767
2768impl SetCustomObjectFormatterEnabledParamsBuilder {
2769    pub fn build(self) -> SetCustomObjectFormatterEnabledParams {
2770        SetCustomObjectFormatterEnabledParams {
2771            enabled: self.enabled,
2772        }
2773    }
2774}
2775
2776impl SetCustomObjectFormatterEnabledParams { pub const METHOD: &'static str = "Runtime.setCustomObjectFormatterEnabled"; }
2777
2778impl<'a> crate::CdpCommand<'a> for SetCustomObjectFormatterEnabledParams {
2779    const METHOD: &'static str = "Runtime.setCustomObjectFormatterEnabled";
2780    type Response = crate::EmptyReturns;
2781}
2782
2783
2784#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2785#[serde(rename_all = "camelCase")]
2786pub struct SetMaxCallStackSizeToCaptureParams {
2787    size: u64,
2788}
2789
2790impl SetMaxCallStackSizeToCaptureParams {
2791    /// Creates a builder for this type with the required parameters:
2792    /// * `size`: 
2793    pub fn builder(size: u64) -> SetMaxCallStackSizeToCaptureParamsBuilder {
2794        SetMaxCallStackSizeToCaptureParamsBuilder {
2795            size: size,
2796        }
2797    }
2798    pub fn size(&self) -> u64 { self.size }
2799}
2800
2801
2802pub struct SetMaxCallStackSizeToCaptureParamsBuilder {
2803    size: u64,
2804}
2805
2806impl SetMaxCallStackSizeToCaptureParamsBuilder {
2807    pub fn build(self) -> SetMaxCallStackSizeToCaptureParams {
2808        SetMaxCallStackSizeToCaptureParams {
2809            size: self.size,
2810        }
2811    }
2812}
2813
2814impl SetMaxCallStackSizeToCaptureParams { pub const METHOD: &'static str = "Runtime.setMaxCallStackSizeToCapture"; }
2815
2816impl<'a> crate::CdpCommand<'a> for SetMaxCallStackSizeToCaptureParams {
2817    const METHOD: &'static str = "Runtime.setMaxCallStackSizeToCapture";
2818    type Response = crate::EmptyReturns;
2819}
2820
2821#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2822pub struct TerminateExecutionParams {}
2823
2824impl TerminateExecutionParams { pub const METHOD: &'static str = "Runtime.terminateExecution"; }
2825
2826impl<'a> crate::CdpCommand<'a> for TerminateExecutionParams {
2827    const METHOD: &'static str = "Runtime.terminateExecution";
2828    type Response = crate::EmptyReturns;
2829}
2830
2831/// If executionContextId is empty, adds binding with the given name on the
2832/// global objects of all inspected contexts, including those created later,
2833/// bindings survive reloads.
2834/// Binding function takes exactly one argument, this argument should be string,
2835/// in case of any other input, function throws an exception.
2836/// Each binding function call produces Runtime.bindingCalled notification.
2837
2838#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2839#[serde(rename_all = "camelCase")]
2840pub struct AddBindingParams<'a> {
2841    name: Cow<'a, str>,
2842    /// If specified, the binding would only be exposed to the specified
2843    /// execution context. If omitted and 'executionContextName' is not set,
2844    /// the binding is exposed to all execution contexts of the target.
2845    /// This parameter is mutually exclusive with 'executionContextName'.
2846    /// Deprecated in favor of 'executionContextName' due to an unclear use case
2847    /// and bugs in implementation (crbug.com/1169639). 'executionContextId' will be
2848    /// removed in the future.
2849    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextId")]
2850    execution_context_id: Option<ExecutionContextId>,
2851    /// If specified, the binding is exposed to the executionContext with
2852    /// matching name, even for contexts created after the binding is added.
2853    /// See also 'ExecutionContext.name' and 'worldName' parameter to
2854    /// 'Page.addScriptToEvaluateOnNewDocument'.
2855    /// This parameter is mutually exclusive with 'executionContextId'.
2856    #[serde(skip_serializing_if = "Option::is_none", rename = "executionContextName")]
2857    execution_context_name: Option<Cow<'a, str>>,
2858}
2859
2860impl<'a> AddBindingParams<'a> {
2861    /// Creates a builder for this type with the required parameters:
2862    /// * `name`: 
2863    pub fn builder(name: impl Into<Cow<'a, str>>) -> AddBindingParamsBuilder<'a> {
2864        AddBindingParamsBuilder {
2865            name: name.into(),
2866            execution_context_id: None,
2867            execution_context_name: None,
2868        }
2869    }
2870    pub fn name(&self) -> &str { self.name.as_ref() }
2871    /// If specified, the binding would only be exposed to the specified
2872    /// execution context. If omitted and 'executionContextName' is not set,
2873    /// the binding is exposed to all execution contexts of the target.
2874    /// This parameter is mutually exclusive with 'executionContextName'.
2875    /// Deprecated in favor of 'executionContextName' due to an unclear use case
2876    /// and bugs in implementation (crbug.com/1169639). 'executionContextId' will be
2877    /// removed in the future.
2878    pub fn execution_context_id(&self) -> Option<&ExecutionContextId> { self.execution_context_id.as_ref() }
2879    /// If specified, the binding is exposed to the executionContext with
2880    /// matching name, even for contexts created after the binding is added.
2881    /// See also 'ExecutionContext.name' and 'worldName' parameter to
2882    /// 'Page.addScriptToEvaluateOnNewDocument'.
2883    /// This parameter is mutually exclusive with 'executionContextId'.
2884    pub fn execution_context_name(&self) -> Option<&str> { self.execution_context_name.as_deref() }
2885}
2886
2887
2888pub struct AddBindingParamsBuilder<'a> {
2889    name: Cow<'a, str>,
2890    execution_context_id: Option<ExecutionContextId>,
2891    execution_context_name: Option<Cow<'a, str>>,
2892}
2893
2894impl<'a> AddBindingParamsBuilder<'a> {
2895    /// If specified, the binding would only be exposed to the specified
2896    /// execution context. If omitted and 'executionContextName' is not set,
2897    /// the binding is exposed to all execution contexts of the target.
2898    /// This parameter is mutually exclusive with 'executionContextName'.
2899    /// Deprecated in favor of 'executionContextName' due to an unclear use case
2900    /// and bugs in implementation (crbug.com/1169639). 'executionContextId' will be
2901    /// removed in the future.
2902    pub fn execution_context_id(mut self, execution_context_id: ExecutionContextId) -> Self { self.execution_context_id = Some(execution_context_id); self }
2903    /// If specified, the binding is exposed to the executionContext with
2904    /// matching name, even for contexts created after the binding is added.
2905    /// See also 'ExecutionContext.name' and 'worldName' parameter to
2906    /// 'Page.addScriptToEvaluateOnNewDocument'.
2907    /// This parameter is mutually exclusive with 'executionContextId'.
2908    pub fn execution_context_name(mut self, execution_context_name: impl Into<Cow<'a, str>>) -> Self { self.execution_context_name = Some(execution_context_name.into()); self }
2909    pub fn build(self) -> AddBindingParams<'a> {
2910        AddBindingParams {
2911            name: self.name,
2912            execution_context_id: self.execution_context_id,
2913            execution_context_name: self.execution_context_name,
2914        }
2915    }
2916}
2917
2918impl<'a> AddBindingParams<'a> { pub const METHOD: &'static str = "Runtime.addBinding"; }
2919
2920impl<'a> crate::CdpCommand<'a> for AddBindingParams<'a> {
2921    const METHOD: &'static str = "Runtime.addBinding";
2922    type Response = crate::EmptyReturns;
2923}
2924
2925/// This method does not remove binding function from global object but
2926/// unsubscribes current runtime agent from Runtime.bindingCalled notifications.
2927
2928#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2929#[serde(rename_all = "camelCase")]
2930pub struct RemoveBindingParams<'a> {
2931    name: Cow<'a, str>,
2932}
2933
2934impl<'a> RemoveBindingParams<'a> {
2935    /// Creates a builder for this type with the required parameters:
2936    /// * `name`: 
2937    pub fn builder(name: impl Into<Cow<'a, str>>) -> RemoveBindingParamsBuilder<'a> {
2938        RemoveBindingParamsBuilder {
2939            name: name.into(),
2940        }
2941    }
2942    pub fn name(&self) -> &str { self.name.as_ref() }
2943}
2944
2945
2946pub struct RemoveBindingParamsBuilder<'a> {
2947    name: Cow<'a, str>,
2948}
2949
2950impl<'a> RemoveBindingParamsBuilder<'a> {
2951    pub fn build(self) -> RemoveBindingParams<'a> {
2952        RemoveBindingParams {
2953            name: self.name,
2954        }
2955    }
2956}
2957
2958impl<'a> RemoveBindingParams<'a> { pub const METHOD: &'static str = "Runtime.removeBinding"; }
2959
2960impl<'a> crate::CdpCommand<'a> for RemoveBindingParams<'a> {
2961    const METHOD: &'static str = "Runtime.removeBinding";
2962    type Response = crate::EmptyReturns;
2963}
2964
2965/// This method tries to lookup and populate exception details for a
2966/// JavaScript Error object.
2967/// Note that the stackTrace portion of the resulting exceptionDetails will
2968/// only be populated if the Runtime domain was enabled at the time when the
2969/// Error was thrown.
2970
2971#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2972#[serde(rename_all = "camelCase")]
2973pub struct GetExceptionDetailsParams<'a> {
2974    /// The error object for which to resolve the exception details.
2975    #[serde(rename = "errorObjectId")]
2976    error_object_id: RemoteObjectId<'a>,
2977}
2978
2979impl<'a> GetExceptionDetailsParams<'a> {
2980    /// Creates a builder for this type with the required parameters:
2981    /// * `error_object_id`: The error object for which to resolve the exception details.
2982    pub fn builder(error_object_id: impl Into<RemoteObjectId<'a>>) -> GetExceptionDetailsParamsBuilder<'a> {
2983        GetExceptionDetailsParamsBuilder {
2984            error_object_id: error_object_id.into(),
2985        }
2986    }
2987    /// The error object for which to resolve the exception details.
2988    pub fn error_object_id(&self) -> &RemoteObjectId<'a> { &self.error_object_id }
2989}
2990
2991
2992pub struct GetExceptionDetailsParamsBuilder<'a> {
2993    error_object_id: RemoteObjectId<'a>,
2994}
2995
2996impl<'a> GetExceptionDetailsParamsBuilder<'a> {
2997    pub fn build(self) -> GetExceptionDetailsParams<'a> {
2998        GetExceptionDetailsParams {
2999            error_object_id: self.error_object_id,
3000        }
3001    }
3002}
3003
3004/// This method tries to lookup and populate exception details for a
3005/// JavaScript Error object.
3006/// Note that the stackTrace portion of the resulting exceptionDetails will
3007/// only be populated if the Runtime domain was enabled at the time when the
3008/// Error was thrown.
3009
3010#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3011#[serde(rename_all = "camelCase")]
3012pub struct GetExceptionDetailsReturns<'a> {
3013    #[serde(skip_serializing_if = "Option::is_none", rename = "exceptionDetails")]
3014    exception_details: Option<ExceptionDetails<'a>>,
3015}
3016
3017impl<'a> GetExceptionDetailsReturns<'a> {
3018    /// Creates a builder for this type.
3019    pub fn builder() -> GetExceptionDetailsReturnsBuilder<'a> {
3020        GetExceptionDetailsReturnsBuilder {
3021            exception_details: None,
3022        }
3023    }
3024    pub fn exception_details(&self) -> Option<&ExceptionDetails<'a>> { self.exception_details.as_ref() }
3025}
3026
3027#[derive(Default)]
3028pub struct GetExceptionDetailsReturnsBuilder<'a> {
3029    exception_details: Option<ExceptionDetails<'a>>,
3030}
3031
3032impl<'a> GetExceptionDetailsReturnsBuilder<'a> {
3033    pub fn exception_details(mut self, exception_details: ExceptionDetails<'a>) -> Self { self.exception_details = Some(exception_details); self }
3034    pub fn build(self) -> GetExceptionDetailsReturns<'a> {
3035        GetExceptionDetailsReturns {
3036            exception_details: self.exception_details,
3037        }
3038    }
3039}
3040
3041impl<'a> GetExceptionDetailsParams<'a> { pub const METHOD: &'static str = "Runtime.getExceptionDetails"; }
3042
3043impl<'a> crate::CdpCommand<'a> for GetExceptionDetailsParams<'a> {
3044    const METHOD: &'static str = "Runtime.getExceptionDetails";
3045    type Response = GetExceptionDetailsReturns<'a>;
3046}