jacquard_api/place_stream/server/
settings.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.server.settings
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record containing user settings for a particular Streamplace node
9#[jacquard_derive::lexicon]
10#[derive(
11    serde::Serialize,
12    serde::Deserialize,
13    Debug,
14    Clone,
15    PartialEq,
16    Eq,
17    jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Settings<'a> {
21    /// Whether this node may archive your livestream for improving the service
22    #[serde(skip_serializing_if = "std::option::Option::is_none")]
23    pub debug_recording: Option<bool>,
24}
25
26pub mod settings_state {
27
28    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
29    #[allow(unused)]
30    use ::core::marker::PhantomData;
31    mod sealed {
32        pub trait Sealed {}
33    }
34    /// State trait tracking which required fields have been set
35    pub trait State: sealed::Sealed {}
36    /// Empty state - all required fields are unset
37    pub struct Empty(());
38    impl sealed::Sealed for Empty {}
39    impl State for Empty {}
40    /// Marker types for field names
41    #[allow(non_camel_case_types)]
42    pub mod members {}
43}
44
45/// Builder for constructing an instance of this type
46pub struct SettingsBuilder<'a, S: settings_state::State> {
47    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
48    __unsafe_private_named: (::core::option::Option<bool>,),
49    _phantom: ::core::marker::PhantomData<&'a ()>,
50}
51
52impl<'a> Settings<'a> {
53    /// Create a new builder for this type
54    pub fn new() -> SettingsBuilder<'a, settings_state::Empty> {
55        SettingsBuilder::new()
56    }
57}
58
59impl<'a> SettingsBuilder<'a, settings_state::Empty> {
60    /// Create a new builder with all fields unset
61    pub fn new() -> Self {
62        SettingsBuilder {
63            _phantom_state: ::core::marker::PhantomData,
64            __unsafe_private_named: (None,),
65            _phantom: ::core::marker::PhantomData,
66        }
67    }
68}
69
70impl<'a, S: settings_state::State> SettingsBuilder<'a, S> {
71    /// Set the `debugRecording` field (optional)
72    pub fn debug_recording(mut self, value: impl Into<Option<bool>>) -> Self {
73        self.__unsafe_private_named.0 = value.into();
74        self
75    }
76    /// Set the `debugRecording` field to an Option value (optional)
77    pub fn maybe_debug_recording(mut self, value: Option<bool>) -> Self {
78        self.__unsafe_private_named.0 = value;
79        self
80    }
81}
82
83impl<'a, S> SettingsBuilder<'a, S>
84where
85    S: settings_state::State,
86{
87    /// Build the final struct
88    pub fn build(self) -> Settings<'a> {
89        Settings {
90            debug_recording: self.__unsafe_private_named.0,
91            extra_data: Default::default(),
92        }
93    }
94    /// Build the final struct with custom extra_data
95    pub fn build_with_data(
96        self,
97        extra_data: std::collections::BTreeMap<
98            jacquard_common::smol_str::SmolStr,
99            jacquard_common::types::value::Data<'a>,
100        >,
101    ) -> Settings<'a> {
102        Settings {
103            debug_recording: self.__unsafe_private_named.0,
104            extra_data: Some(extra_data),
105        }
106    }
107}
108
109impl<'a> Settings<'a> {
110    pub fn uri(
111        uri: impl Into<jacquard_common::CowStr<'a>>,
112    ) -> Result<
113        jacquard_common::types::uri::RecordUri<'a, SettingsRecord>,
114        jacquard_common::types::uri::UriError,
115    > {
116        jacquard_common::types::uri::RecordUri::try_from_uri(
117            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
118        )
119    }
120}
121
122/// Typed wrapper for GetRecord response with this collection's record type.
123#[derive(
124    serde::Serialize,
125    serde::Deserialize,
126    Debug,
127    Clone,
128    PartialEq,
129    Eq,
130    jacquard_derive::IntoStatic
131)]
132#[serde(rename_all = "camelCase")]
133pub struct SettingsGetRecordOutput<'a> {
134    #[serde(skip_serializing_if = "std::option::Option::is_none")]
135    #[serde(borrow)]
136    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
137    #[serde(borrow)]
138    pub uri: jacquard_common::types::string::AtUri<'a>,
139    #[serde(borrow)]
140    pub value: Settings<'a>,
141}
142
143impl From<SettingsGetRecordOutput<'_>> for Settings<'_> {
144    fn from(output: SettingsGetRecordOutput<'_>) -> Self {
145        use jacquard_common::IntoStatic;
146        output.value.into_static()
147    }
148}
149
150impl jacquard_common::types::collection::Collection for Settings<'_> {
151    const NSID: &'static str = "place.stream.server.settings";
152    type Record = SettingsRecord;
153}
154
155/// Marker type for deserializing records from this collection.
156#[derive(Debug, serde::Serialize, serde::Deserialize)]
157pub struct SettingsRecord;
158impl jacquard_common::xrpc::XrpcResp for SettingsRecord {
159    const NSID: &'static str = "place.stream.server.settings";
160    const ENCODING: &'static str = "application/json";
161    type Output<'de> = SettingsGetRecordOutput<'de>;
162    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
163}
164
165impl jacquard_common::types::collection::Collection for SettingsRecord {
166    const NSID: &'static str = "place.stream.server.settings";
167    type Record = SettingsRecord;
168}
169
170impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Settings<'a> {
171    fn nsid() -> &'static str {
172        "place.stream.server.settings"
173    }
174    fn def_name() -> &'static str {
175        "main"
176    }
177    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
178        lexicon_doc_place_stream_server_settings()
179    }
180    fn validate(
181        &self,
182    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
183        Ok(())
184    }
185}
186
187fn lexicon_doc_place_stream_server_settings() -> ::jacquard_lexicon::lexicon::LexiconDoc<
188    'static,
189> {
190    ::jacquard_lexicon::lexicon::LexiconDoc {
191        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
192        id: ::jacquard_common::CowStr::new_static("place.stream.server.settings"),
193        revision: None,
194        description: None,
195        defs: {
196            let mut map = ::std::collections::BTreeMap::new();
197            map.insert(
198                ::jacquard_common::smol_str::SmolStr::new_static("main"),
199                ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
200                    description: Some(
201                        ::jacquard_common::CowStr::new_static(
202                            "Record containing user settings for a particular Streamplace node",
203                        ),
204                    ),
205                    key: Some(::jacquard_common::CowStr::new_static("any")),
206                    record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
207                        description: None,
208                        required: Some(vec![]),
209                        nullable: None,
210                        properties: {
211                            #[allow(unused_mut)]
212                            let mut map = ::std::collections::BTreeMap::new();
213                            map.insert(
214                                ::jacquard_common::smol_str::SmolStr::new_static(
215                                    "debugRecording",
216                                ),
217                                ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
218                                    description: None,
219                                    default: None,
220                                    r#const: None,
221                                }),
222                            );
223                            map
224                        },
225                    }),
226                }),
227            );
228            map
229        },
230    }
231}