Skip to main content

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