rustenium_cdp_definitions/browser_protocol/web_audio/
command_builders.rs1use super::commands::*;
2#[derive(Debug, Clone, Default)]
3pub struct EnableBuilder;
4impl EnableBuilder {
5 pub fn new() -> Self {
6 Self
7 }
8 pub fn build(self) -> Enable {
9 Enable {
10 method: EnableMethod::Enable,
11 params: EnableParams {},
12 }
13 }
14}
15impl Enable {
16 pub fn builder() -> EnableBuilder {
17 EnableBuilder
18 }
19}
20#[derive(Debug, Clone, Default)]
21pub struct DisableBuilder;
22impl DisableBuilder {
23 pub fn new() -> Self {
24 Self
25 }
26 pub fn build(self) -> Disable {
27 Disable {
28 method: DisableMethod::Disable,
29 params: DisableParams {},
30 }
31 }
32}
33impl Disable {
34 pub fn builder() -> DisableBuilder {
35 DisableBuilder
36 }
37}
38impl GetRealtimeData {
39 pub fn builder() -> GetRealtimeDataBuilder {
40 <GetRealtimeDataBuilder as Default>::default()
41 }
42}
43#[derive(Default, Clone)]
44pub struct GetRealtimeDataBuilder {
45 context_id: Option<super::types::GraphObjectId>,
46}
47impl GetRealtimeDataBuilder {
48 pub fn context_id(mut self, context_id: impl Into<super::types::GraphObjectId>) -> Self {
49 self.context_id = Some(context_id.into());
50 self
51 }
52 pub fn build(self) -> Result<GetRealtimeData, String> {
53 Ok(GetRealtimeData {
54 method: GetRealtimeDataMethod::GetRealtimeData,
55 params: GetRealtimeDataParams {
56 context_id: self.context_id.ok_or_else(|| {
57 format!("Field `{}` is mandatory.", std::stringify!(context_id))
58 })?,
59 },
60 })
61 }
62}