Skip to main content

rustenium_cdp_definitions/js_protocol/runtime/
command_builders.rs

1use super::commands::*;
2impl AwaitPromise {
3    pub fn builder() -> AwaitPromiseBuilder {
4        <AwaitPromiseBuilder as Default>::default()
5    }
6}
7#[derive(Default, Clone)]
8pub struct AwaitPromiseBuilder {
9    promise_object_id: Option<super::types::RemoteObjectId>,
10    return_by_value: Option<bool>,
11    generate_preview: Option<bool>,
12}
13impl AwaitPromiseBuilder {
14    pub fn promise_object_id(
15        mut self,
16        promise_object_id: impl Into<super::types::RemoteObjectId>,
17    ) -> Self {
18        self.promise_object_id = Some(promise_object_id.into());
19        self
20    }
21    pub fn return_by_value(mut self, return_by_value: impl Into<bool>) -> Self {
22        self.return_by_value = Some(return_by_value.into());
23        self
24    }
25    pub fn generate_preview(mut self, generate_preview: impl Into<bool>) -> Self {
26        self.generate_preview = Some(generate_preview.into());
27        self
28    }
29    pub fn build(self) -> Result<AwaitPromise, String> {
30        Ok(AwaitPromise {
31            method: AwaitPromiseMethod::AwaitPromise,
32            params: AwaitPromiseParams {
33                promise_object_id: self.promise_object_id.ok_or_else(|| {
34                    format!(
35                        "Field `{}` is mandatory.",
36                        std::stringify!(promise_object_id)
37                    )
38                })?,
39                return_by_value: self.return_by_value,
40                generate_preview: self.generate_preview,
41            },
42        })
43    }
44}
45impl CallFunctionOn {
46    pub fn builder() -> CallFunctionOnBuilder {
47        <CallFunctionOnBuilder as Default>::default()
48    }
49}
50#[derive(Default, Clone)]
51pub struct CallFunctionOnBuilder {
52    function_declaration: Option<String>,
53    object_id: Option<super::types::RemoteObjectId>,
54    arguments: Option<Vec<super::types::CallArgument>>,
55    silent: Option<bool>,
56    return_by_value: Option<bool>,
57    generate_preview: Option<bool>,
58    user_gesture: Option<bool>,
59    await_promise: Option<bool>,
60    execution_context_id: Option<super::types::ExecutionContextId>,
61    object_group: Option<String>,
62    throw_on_side_effect: Option<bool>,
63    unique_context_id: Option<String>,
64    serialization_options: Option<super::types::SerializationOptions>,
65}
66impl CallFunctionOnBuilder {
67    pub fn function_declaration(mut self, function_declaration: impl Into<String>) -> Self {
68        self.function_declaration = Some(function_declaration.into());
69        self
70    }
71    pub fn object_id(mut self, object_id: impl Into<super::types::RemoteObjectId>) -> Self {
72        self.object_id = Some(object_id.into());
73        self
74    }
75    pub fn argument(mut self, argument: impl Into<super::types::CallArgument>) -> Self {
76        let v = self.arguments.get_or_insert(Vec::new());
77        v.push(argument.into());
78        self
79    }
80    pub fn arguments<I, S>(mut self, arguments: I) -> Self
81    where
82        I: IntoIterator<Item = S>,
83        S: Into<super::types::CallArgument>,
84    {
85        let v = self.arguments.get_or_insert(Vec::new());
86        for val in arguments {
87            v.push(val.into());
88        }
89        self
90    }
91    pub fn silent(mut self, silent: impl Into<bool>) -> Self {
92        self.silent = Some(silent.into());
93        self
94    }
95    pub fn return_by_value(mut self, return_by_value: impl Into<bool>) -> Self {
96        self.return_by_value = Some(return_by_value.into());
97        self
98    }
99    pub fn generate_preview(mut self, generate_preview: impl Into<bool>) -> Self {
100        self.generate_preview = Some(generate_preview.into());
101        self
102    }
103    pub fn user_gesture(mut self, user_gesture: impl Into<bool>) -> Self {
104        self.user_gesture = Some(user_gesture.into());
105        self
106    }
107    pub fn await_promise(mut self, await_promise: impl Into<bool>) -> Self {
108        self.await_promise = Some(await_promise.into());
109        self
110    }
111    pub fn execution_context_id(
112        mut self,
113        execution_context_id: impl Into<super::types::ExecutionContextId>,
114    ) -> Self {
115        self.execution_context_id = Some(execution_context_id.into());
116        self
117    }
118    pub fn object_group(mut self, object_group: impl Into<String>) -> Self {
119        self.object_group = Some(object_group.into());
120        self
121    }
122    pub fn throw_on_side_effect(mut self, throw_on_side_effect: impl Into<bool>) -> Self {
123        self.throw_on_side_effect = Some(throw_on_side_effect.into());
124        self
125    }
126    pub fn unique_context_id(mut self, unique_context_id: impl Into<String>) -> Self {
127        self.unique_context_id = Some(unique_context_id.into());
128        self
129    }
130    pub fn serialization_options(
131        mut self,
132        serialization_options: impl Into<super::types::SerializationOptions>,
133    ) -> Self {
134        self.serialization_options = Some(serialization_options.into());
135        self
136    }
137    pub fn build(self) -> Result<CallFunctionOn, String> {
138        Ok(CallFunctionOn {
139            method: CallFunctionOnMethod::CallFunctionOn,
140            params: CallFunctionOnParams {
141                function_declaration: self.function_declaration.ok_or_else(|| {
142                    format!(
143                        "Field `{}` is mandatory.",
144                        std::stringify!(function_declaration)
145                    )
146                })?,
147                object_id: self.object_id,
148                arguments: self.arguments,
149                silent: self.silent,
150                return_by_value: self.return_by_value,
151                generate_preview: self.generate_preview,
152                user_gesture: self.user_gesture,
153                await_promise: self.await_promise,
154                execution_context_id: self.execution_context_id,
155                object_group: self.object_group,
156                throw_on_side_effect: self.throw_on_side_effect,
157                unique_context_id: self.unique_context_id,
158                serialization_options: self.serialization_options,
159            },
160        })
161    }
162}
163impl CompileScript {
164    pub fn builder() -> CompileScriptBuilder {
165        <CompileScriptBuilder as Default>::default()
166    }
167}
168#[derive(Default, Clone)]
169pub struct CompileScriptBuilder {
170    expression: Option<String>,
171    source_url: Option<String>,
172    persist_script: Option<bool>,
173    execution_context_id: Option<super::types::ExecutionContextId>,
174}
175impl CompileScriptBuilder {
176    pub fn expression(mut self, expression: impl Into<String>) -> Self {
177        self.expression = Some(expression.into());
178        self
179    }
180    pub fn source_url(mut self, source_url: impl Into<String>) -> Self {
181        self.source_url = Some(source_url.into());
182        self
183    }
184    pub fn persist_script(mut self, persist_script: impl Into<bool>) -> Self {
185        self.persist_script = Some(persist_script.into());
186        self
187    }
188    pub fn execution_context_id(
189        mut self,
190        execution_context_id: impl Into<super::types::ExecutionContextId>,
191    ) -> Self {
192        self.execution_context_id = Some(execution_context_id.into());
193        self
194    }
195    pub fn build(self) -> Result<CompileScript, String> {
196        Ok(CompileScript {
197            method: CompileScriptMethod::CompileScript,
198            params: CompileScriptParams {
199                expression: self.expression.ok_or_else(|| {
200                    format!("Field `{}` is mandatory.", std::stringify!(expression))
201                })?,
202                source_url: self.source_url.ok_or_else(|| {
203                    format!("Field `{}` is mandatory.", std::stringify!(source_url))
204                })?,
205                persist_script: self.persist_script.ok_or_else(|| {
206                    format!("Field `{}` is mandatory.", std::stringify!(persist_script))
207                })?,
208                execution_context_id: self.execution_context_id,
209            },
210        })
211    }
212}
213#[derive(Debug, Clone, Default)]
214pub struct DisableBuilder;
215impl DisableBuilder {
216    pub fn new() -> Self {
217        Self
218    }
219    pub fn build(self) -> Disable {
220        Disable {
221            method: DisableMethod::Disable,
222            params: DisableParams {},
223        }
224    }
225}
226impl Disable {
227    pub fn builder() -> DisableBuilder {
228        DisableBuilder
229    }
230}
231#[derive(Debug, Clone, Default)]
232pub struct DiscardConsoleEntriesBuilder;
233impl DiscardConsoleEntriesBuilder {
234    pub fn new() -> Self {
235        Self
236    }
237    pub fn build(self) -> DiscardConsoleEntries {
238        DiscardConsoleEntries {
239            method: DiscardConsoleEntriesMethod::DiscardConsoleEntries,
240            params: DiscardConsoleEntriesParams {},
241        }
242    }
243}
244impl DiscardConsoleEntries {
245    pub fn builder() -> DiscardConsoleEntriesBuilder {
246        DiscardConsoleEntriesBuilder
247    }
248}
249#[derive(Debug, Clone, Default)]
250pub struct EnableBuilder;
251impl EnableBuilder {
252    pub fn new() -> Self {
253        Self
254    }
255    pub fn build(self) -> Enable {
256        Enable {
257            method: EnableMethod::Enable,
258            params: EnableParams {},
259        }
260    }
261}
262impl Enable {
263    pub fn builder() -> EnableBuilder {
264        EnableBuilder
265    }
266}
267impl Evaluate {
268    pub fn builder() -> EvaluateBuilder {
269        <EvaluateBuilder as Default>::default()
270    }
271}
272#[derive(Default, Clone)]
273pub struct EvaluateBuilder {
274    expression: Option<String>,
275    object_group: Option<String>,
276    include_command_line_api: Option<bool>,
277    silent: Option<bool>,
278    context_id: Option<super::types::ExecutionContextId>,
279    return_by_value: Option<bool>,
280    generate_preview: Option<bool>,
281    user_gesture: Option<bool>,
282    await_promise: Option<bool>,
283    throw_on_side_effect: Option<bool>,
284    timeout: Option<super::types::TimeDelta>,
285    disable_breaks: Option<bool>,
286    repl_mode: Option<bool>,
287    allow_unsafe_eval_blocked_by_csp: Option<bool>,
288    unique_context_id: Option<String>,
289    serialization_options: Option<super::types::SerializationOptions>,
290}
291impl EvaluateBuilder {
292    pub fn expression(mut self, expression: impl Into<String>) -> Self {
293        self.expression = Some(expression.into());
294        self
295    }
296    pub fn object_group(mut self, object_group: impl Into<String>) -> Self {
297        self.object_group = Some(object_group.into());
298        self
299    }
300    pub fn include_command_line_api(mut self, include_command_line_api: impl Into<bool>) -> Self {
301        self.include_command_line_api = Some(include_command_line_api.into());
302        self
303    }
304    pub fn silent(mut self, silent: impl Into<bool>) -> Self {
305        self.silent = Some(silent.into());
306        self
307    }
308    pub fn context_id(mut self, context_id: impl Into<super::types::ExecutionContextId>) -> Self {
309        self.context_id = Some(context_id.into());
310        self
311    }
312    pub fn return_by_value(mut self, return_by_value: impl Into<bool>) -> Self {
313        self.return_by_value = Some(return_by_value.into());
314        self
315    }
316    pub fn generate_preview(mut self, generate_preview: impl Into<bool>) -> Self {
317        self.generate_preview = Some(generate_preview.into());
318        self
319    }
320    pub fn user_gesture(mut self, user_gesture: impl Into<bool>) -> Self {
321        self.user_gesture = Some(user_gesture.into());
322        self
323    }
324    pub fn await_promise(mut self, await_promise: impl Into<bool>) -> Self {
325        self.await_promise = Some(await_promise.into());
326        self
327    }
328    pub fn throw_on_side_effect(mut self, throw_on_side_effect: impl Into<bool>) -> Self {
329        self.throw_on_side_effect = Some(throw_on_side_effect.into());
330        self
331    }
332    pub fn timeout(mut self, timeout: impl Into<super::types::TimeDelta>) -> Self {
333        self.timeout = Some(timeout.into());
334        self
335    }
336    pub fn disable_breaks(mut self, disable_breaks: impl Into<bool>) -> Self {
337        self.disable_breaks = Some(disable_breaks.into());
338        self
339    }
340    pub fn repl_mode(mut self, repl_mode: impl Into<bool>) -> Self {
341        self.repl_mode = Some(repl_mode.into());
342        self
343    }
344    pub fn allow_unsafe_eval_blocked_by_csp(
345        mut self,
346        allow_unsafe_eval_blocked_by_csp: impl Into<bool>,
347    ) -> Self {
348        self.allow_unsafe_eval_blocked_by_csp = Some(allow_unsafe_eval_blocked_by_csp.into());
349        self
350    }
351    pub fn unique_context_id(mut self, unique_context_id: impl Into<String>) -> Self {
352        self.unique_context_id = Some(unique_context_id.into());
353        self
354    }
355    pub fn serialization_options(
356        mut self,
357        serialization_options: impl Into<super::types::SerializationOptions>,
358    ) -> Self {
359        self.serialization_options = Some(serialization_options.into());
360        self
361    }
362    pub fn build(self) -> Result<Evaluate, String> {
363        Ok(Evaluate {
364            method: EvaluateMethod::Evaluate,
365            params: EvaluateParams {
366                expression: self.expression.ok_or_else(|| {
367                    format!("Field `{}` is mandatory.", std::stringify!(expression))
368                })?,
369                object_group: self.object_group,
370                include_command_line_api: self.include_command_line_api,
371                silent: self.silent,
372                context_id: self.context_id,
373                return_by_value: self.return_by_value,
374                generate_preview: self.generate_preview,
375                user_gesture: self.user_gesture,
376                await_promise: self.await_promise,
377                throw_on_side_effect: self.throw_on_side_effect,
378                timeout: self.timeout,
379                disable_breaks: self.disable_breaks,
380                repl_mode: self.repl_mode,
381                allow_unsafe_eval_blocked_by_csp: self.allow_unsafe_eval_blocked_by_csp,
382                unique_context_id: self.unique_context_id,
383                serialization_options: self.serialization_options,
384            },
385        })
386    }
387}
388#[derive(Debug, Clone, Default)]
389pub struct GetIsolateIdBuilder;
390impl GetIsolateIdBuilder {
391    pub fn new() -> Self {
392        Self
393    }
394    pub fn build(self) -> GetIsolateId {
395        GetIsolateId {
396            method: GetIsolateIdMethod::GetIsolateId,
397            params: GetIsolateIdParams {},
398        }
399    }
400}
401impl GetIsolateId {
402    pub fn builder() -> GetIsolateIdBuilder {
403        GetIsolateIdBuilder
404    }
405}
406#[derive(Debug, Clone, Default)]
407pub struct GetHeapUsageBuilder;
408impl GetHeapUsageBuilder {
409    pub fn new() -> Self {
410        Self
411    }
412    pub fn build(self) -> GetHeapUsage {
413        GetHeapUsage {
414            method: GetHeapUsageMethod::GetHeapUsage,
415            params: GetHeapUsageParams {},
416        }
417    }
418}
419impl GetHeapUsage {
420    pub fn builder() -> GetHeapUsageBuilder {
421        GetHeapUsageBuilder
422    }
423}
424impl GetProperties {
425    pub fn builder() -> GetPropertiesBuilder {
426        <GetPropertiesBuilder as Default>::default()
427    }
428}
429#[derive(Default, Clone)]
430pub struct GetPropertiesBuilder {
431    object_id: Option<super::types::RemoteObjectId>,
432    own_properties: Option<bool>,
433    accessor_properties_only: Option<bool>,
434    generate_preview: Option<bool>,
435    non_indexed_properties_only: Option<bool>,
436}
437impl GetPropertiesBuilder {
438    pub fn object_id(mut self, object_id: impl Into<super::types::RemoteObjectId>) -> Self {
439        self.object_id = Some(object_id.into());
440        self
441    }
442    pub fn own_properties(mut self, own_properties: impl Into<bool>) -> Self {
443        self.own_properties = Some(own_properties.into());
444        self
445    }
446    pub fn accessor_properties_only(mut self, accessor_properties_only: impl Into<bool>) -> Self {
447        self.accessor_properties_only = Some(accessor_properties_only.into());
448        self
449    }
450    pub fn generate_preview(mut self, generate_preview: impl Into<bool>) -> Self {
451        self.generate_preview = Some(generate_preview.into());
452        self
453    }
454    pub fn non_indexed_properties_only(
455        mut self,
456        non_indexed_properties_only: impl Into<bool>,
457    ) -> Self {
458        self.non_indexed_properties_only = Some(non_indexed_properties_only.into());
459        self
460    }
461    pub fn build(self) -> Result<GetProperties, String> {
462        Ok(GetProperties {
463            method: GetPropertiesMethod::GetProperties,
464            params: GetPropertiesParams {
465                object_id: self.object_id.ok_or_else(|| {
466                    format!("Field `{}` is mandatory.", std::stringify!(object_id))
467                })?,
468                own_properties: self.own_properties,
469                accessor_properties_only: self.accessor_properties_only,
470                generate_preview: self.generate_preview,
471                non_indexed_properties_only: self.non_indexed_properties_only,
472            },
473        })
474    }
475}
476impl GlobalLexicalScopeNames {
477    pub fn builder() -> GlobalLexicalScopeNamesBuilder {
478        <GlobalLexicalScopeNamesBuilder as Default>::default()
479    }
480}
481#[derive(Default, Clone)]
482pub struct GlobalLexicalScopeNamesBuilder {
483    execution_context_id: Option<super::types::ExecutionContextId>,
484}
485impl GlobalLexicalScopeNamesBuilder {
486    pub fn execution_context_id(
487        mut self,
488        execution_context_id: impl Into<super::types::ExecutionContextId>,
489    ) -> Self {
490        self.execution_context_id = Some(execution_context_id.into());
491        self
492    }
493    pub fn build(self) -> GlobalLexicalScopeNames {
494        GlobalLexicalScopeNames {
495            method: GlobalLexicalScopeNamesMethod::GlobalLexicalScopeNames,
496            params: GlobalLexicalScopeNamesParams {
497                execution_context_id: self.execution_context_id,
498            },
499        }
500    }
501}
502impl QueryObjects {
503    pub fn builder() -> QueryObjectsBuilder {
504        <QueryObjectsBuilder as Default>::default()
505    }
506}
507#[derive(Default, Clone)]
508pub struct QueryObjectsBuilder {
509    prototype_object_id: Option<super::types::RemoteObjectId>,
510    object_group: Option<String>,
511}
512impl QueryObjectsBuilder {
513    pub fn prototype_object_id(
514        mut self,
515        prototype_object_id: impl Into<super::types::RemoteObjectId>,
516    ) -> Self {
517        self.prototype_object_id = Some(prototype_object_id.into());
518        self
519    }
520    pub fn object_group(mut self, object_group: impl Into<String>) -> Self {
521        self.object_group = Some(object_group.into());
522        self
523    }
524    pub fn build(self) -> Result<QueryObjects, String> {
525        Ok(QueryObjects {
526            method: QueryObjectsMethod::QueryObjects,
527            params: QueryObjectsParams {
528                prototype_object_id: self.prototype_object_id.ok_or_else(|| {
529                    format!(
530                        "Field `{}` is mandatory.",
531                        std::stringify!(prototype_object_id)
532                    )
533                })?,
534                object_group: self.object_group,
535            },
536        })
537    }
538}
539impl ReleaseObject {
540    pub fn builder() -> ReleaseObjectBuilder {
541        <ReleaseObjectBuilder as Default>::default()
542    }
543}
544#[derive(Default, Clone)]
545pub struct ReleaseObjectBuilder {
546    object_id: Option<super::types::RemoteObjectId>,
547}
548impl ReleaseObjectBuilder {
549    pub fn object_id(mut self, object_id: impl Into<super::types::RemoteObjectId>) -> Self {
550        self.object_id = Some(object_id.into());
551        self
552    }
553    pub fn build(self) -> Result<ReleaseObject, String> {
554        Ok(ReleaseObject {
555            method: ReleaseObjectMethod::ReleaseObject,
556            params: ReleaseObjectParams {
557                object_id: self.object_id.ok_or_else(|| {
558                    format!("Field `{}` is mandatory.", std::stringify!(object_id))
559                })?,
560            },
561        })
562    }
563}
564impl ReleaseObjectGroup {
565    pub fn builder() -> ReleaseObjectGroupBuilder {
566        <ReleaseObjectGroupBuilder as Default>::default()
567    }
568}
569#[derive(Default, Clone)]
570pub struct ReleaseObjectGroupBuilder {
571    object_group: Option<String>,
572}
573impl ReleaseObjectGroupBuilder {
574    pub fn object_group(mut self, object_group: impl Into<String>) -> Self {
575        self.object_group = Some(object_group.into());
576        self
577    }
578    pub fn build(self) -> Result<ReleaseObjectGroup, String> {
579        Ok(ReleaseObjectGroup {
580            method: ReleaseObjectGroupMethod::ReleaseObjectGroup,
581            params: ReleaseObjectGroupParams {
582                object_group: self.object_group.ok_or_else(|| {
583                    format!("Field `{}` is mandatory.", std::stringify!(object_group))
584                })?,
585            },
586        })
587    }
588}
589#[derive(Debug, Clone, Default)]
590pub struct RunIfWaitingForDebuggerBuilder;
591impl RunIfWaitingForDebuggerBuilder {
592    pub fn new() -> Self {
593        Self
594    }
595    pub fn build(self) -> RunIfWaitingForDebugger {
596        RunIfWaitingForDebugger {
597            method: RunIfWaitingForDebuggerMethod::RunIfWaitingForDebugger,
598            params: RunIfWaitingForDebuggerParams {},
599        }
600    }
601}
602impl RunIfWaitingForDebugger {
603    pub fn builder() -> RunIfWaitingForDebuggerBuilder {
604        RunIfWaitingForDebuggerBuilder
605    }
606}
607impl RunScript {
608    pub fn builder() -> RunScriptBuilder {
609        <RunScriptBuilder as Default>::default()
610    }
611}
612#[derive(Default, Clone)]
613pub struct RunScriptBuilder {
614    script_id: Option<super::types::ScriptId>,
615    execution_context_id: Option<super::types::ExecutionContextId>,
616    object_group: Option<String>,
617    silent: Option<bool>,
618    include_command_line_api: Option<bool>,
619    return_by_value: Option<bool>,
620    generate_preview: Option<bool>,
621    await_promise: Option<bool>,
622}
623impl RunScriptBuilder {
624    pub fn script_id(mut self, script_id: impl Into<super::types::ScriptId>) -> Self {
625        self.script_id = Some(script_id.into());
626        self
627    }
628    pub fn execution_context_id(
629        mut self,
630        execution_context_id: impl Into<super::types::ExecutionContextId>,
631    ) -> Self {
632        self.execution_context_id = Some(execution_context_id.into());
633        self
634    }
635    pub fn object_group(mut self, object_group: impl Into<String>) -> Self {
636        self.object_group = Some(object_group.into());
637        self
638    }
639    pub fn silent(mut self, silent: impl Into<bool>) -> Self {
640        self.silent = Some(silent.into());
641        self
642    }
643    pub fn include_command_line_api(mut self, include_command_line_api: impl Into<bool>) -> Self {
644        self.include_command_line_api = Some(include_command_line_api.into());
645        self
646    }
647    pub fn return_by_value(mut self, return_by_value: impl Into<bool>) -> Self {
648        self.return_by_value = Some(return_by_value.into());
649        self
650    }
651    pub fn generate_preview(mut self, generate_preview: impl Into<bool>) -> Self {
652        self.generate_preview = Some(generate_preview.into());
653        self
654    }
655    pub fn await_promise(mut self, await_promise: impl Into<bool>) -> Self {
656        self.await_promise = Some(await_promise.into());
657        self
658    }
659    pub fn build(self) -> Result<RunScript, String> {
660        Ok(RunScript {
661            method: RunScriptMethod::RunScript,
662            params: RunScriptParams {
663                script_id: self.script_id.ok_or_else(|| {
664                    format!("Field `{}` is mandatory.", std::stringify!(script_id))
665                })?,
666                execution_context_id: self.execution_context_id,
667                object_group: self.object_group,
668                silent: self.silent,
669                include_command_line_api: self.include_command_line_api,
670                return_by_value: self.return_by_value,
671                generate_preview: self.generate_preview,
672                await_promise: self.await_promise,
673            },
674        })
675    }
676}
677impl SetAsyncCallStackDepth {
678    pub fn builder() -> SetAsyncCallStackDepthBuilder {
679        <SetAsyncCallStackDepthBuilder as Default>::default()
680    }
681}
682#[derive(Default, Clone)]
683pub struct SetAsyncCallStackDepthBuilder {
684    max_depth: Option<i64>,
685}
686impl SetAsyncCallStackDepthBuilder {
687    pub fn max_depth(mut self, max_depth: impl Into<i64>) -> Self {
688        self.max_depth = Some(max_depth.into());
689        self
690    }
691    pub fn build(self) -> Result<SetAsyncCallStackDepth, String> {
692        Ok(SetAsyncCallStackDepth {
693            method: SetAsyncCallStackDepthMethod::SetAsyncCallStackDepth,
694            params: SetAsyncCallStackDepthParams {
695                max_depth: self.max_depth.ok_or_else(|| {
696                    format!("Field `{}` is mandatory.", std::stringify!(max_depth))
697                })?,
698            },
699        })
700    }
701}
702impl SetCustomObjectFormatterEnabled {
703    pub fn builder() -> SetCustomObjectFormatterEnabledBuilder {
704        <SetCustomObjectFormatterEnabledBuilder as Default>::default()
705    }
706}
707#[derive(Default, Clone)]
708pub struct SetCustomObjectFormatterEnabledBuilder {
709    enabled: Option<bool>,
710}
711impl SetCustomObjectFormatterEnabledBuilder {
712    pub fn enabled(mut self, enabled: impl Into<bool>) -> Self {
713        self.enabled = Some(enabled.into());
714        self
715    }
716    pub fn build(self) -> Result<SetCustomObjectFormatterEnabled, String> {
717        Ok(SetCustomObjectFormatterEnabled {
718            method: SetCustomObjectFormatterEnabledMethod::SetCustomObjectFormatterEnabled,
719            params: SetCustomObjectFormatterEnabledParams {
720                enabled: self
721                    .enabled
722                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(enabled)))?,
723            },
724        })
725    }
726}
727impl SetMaxCallStackSizeToCapture {
728    pub fn builder() -> SetMaxCallStackSizeToCaptureBuilder {
729        <SetMaxCallStackSizeToCaptureBuilder as Default>::default()
730    }
731}
732#[derive(Default, Clone)]
733pub struct SetMaxCallStackSizeToCaptureBuilder {
734    size: Option<i64>,
735}
736impl SetMaxCallStackSizeToCaptureBuilder {
737    pub fn size(mut self, size: impl Into<i64>) -> Self {
738        self.size = Some(size.into());
739        self
740    }
741    pub fn build(self) -> Result<SetMaxCallStackSizeToCapture, String> {
742        Ok(SetMaxCallStackSizeToCapture {
743            method: SetMaxCallStackSizeToCaptureMethod::SetMaxCallStackSizeToCapture,
744            params: SetMaxCallStackSizeToCaptureParams {
745                size: self
746                    .size
747                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(size)))?,
748            },
749        })
750    }
751}
752#[derive(Debug, Clone, Default)]
753pub struct TerminateExecutionBuilder;
754impl TerminateExecutionBuilder {
755    pub fn new() -> Self {
756        Self
757    }
758    pub fn build(self) -> TerminateExecution {
759        TerminateExecution {
760            method: TerminateExecutionMethod::TerminateExecution,
761            params: TerminateExecutionParams {},
762        }
763    }
764}
765impl TerminateExecution {
766    pub fn builder() -> TerminateExecutionBuilder {
767        TerminateExecutionBuilder
768    }
769}
770impl AddBinding {
771    pub fn builder() -> AddBindingBuilder {
772        <AddBindingBuilder as Default>::default()
773    }
774}
775#[derive(Default, Clone)]
776pub struct AddBindingBuilder {
777    name: Option<String>,
778    execution_context_name: Option<String>,
779}
780impl AddBindingBuilder {
781    pub fn name(mut self, name: impl Into<String>) -> Self {
782        self.name = Some(name.into());
783        self
784    }
785    pub fn execution_context_name(mut self, execution_context_name: impl Into<String>) -> Self {
786        self.execution_context_name = Some(execution_context_name.into());
787        self
788    }
789    pub fn build(self) -> Result<AddBinding, String> {
790        Ok(AddBinding {
791            method: AddBindingMethod::AddBinding,
792            params: AddBindingParams {
793                name: self
794                    .name
795                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(name)))?,
796                execution_context_name: self.execution_context_name,
797            },
798        })
799    }
800}
801impl RemoveBinding {
802    pub fn builder() -> RemoveBindingBuilder {
803        <RemoveBindingBuilder as Default>::default()
804    }
805}
806#[derive(Default, Clone)]
807pub struct RemoveBindingBuilder {
808    name: Option<String>,
809}
810impl RemoveBindingBuilder {
811    pub fn name(mut self, name: impl Into<String>) -> Self {
812        self.name = Some(name.into());
813        self
814    }
815    pub fn build(self) -> Result<RemoveBinding, String> {
816        Ok(RemoveBinding {
817            method: RemoveBindingMethod::RemoveBinding,
818            params: RemoveBindingParams {
819                name: self
820                    .name
821                    .ok_or_else(|| format!("Field `{}` is mandatory.", std::stringify!(name)))?,
822            },
823        })
824    }
825}
826impl GetExceptionDetails {
827    pub fn builder() -> GetExceptionDetailsBuilder {
828        <GetExceptionDetailsBuilder as Default>::default()
829    }
830}
831#[derive(Default, Clone)]
832pub struct GetExceptionDetailsBuilder {
833    error_object_id: Option<super::types::RemoteObjectId>,
834}
835impl GetExceptionDetailsBuilder {
836    pub fn error_object_id(
837        mut self,
838        error_object_id: impl Into<super::types::RemoteObjectId>,
839    ) -> Self {
840        self.error_object_id = Some(error_object_id.into());
841        self
842    }
843    pub fn build(self) -> Result<GetExceptionDetails, String> {
844        Ok(GetExceptionDetails {
845            method: GetExceptionDetailsMethod::GetExceptionDetails,
846            params: GetExceptionDetailsParams {
847                error_object_id: self.error_object_id.ok_or_else(|| {
848                    format!("Field `{}` is mandatory.", std::stringify!(error_object_id))
849                })?,
850            },
851        })
852    }
853}