Skip to main content

jacquard_api/place_stream/metadata/
configuration.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.metadata.configuration
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};
28use crate::place_stream::metadata::content_rights::ContentRights;
29use crate::place_stream::metadata::content_warnings::ContentWarnings;
30use crate::place_stream::metadata::distribution_policy::DistributionPolicy;
31/// Default metadata record for livestream including content warnings, rights, and distribution policy
32
33#[lexicon]
34#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
35#[serde(
36    rename_all = "camelCase",
37    rename = "place.stream.metadata.configuration",
38    tag = "$type"
39)]
40pub struct Configuration<'a> {
41    #[serde(skip_serializing_if = "Option::is_none")]
42    #[serde(borrow)]
43    pub content_rights: Option<ContentRights<'a>>,
44    #[serde(skip_serializing_if = "Option::is_none")]
45    #[serde(borrow)]
46    pub content_warnings: Option<ContentWarnings<'a>>,
47    #[serde(skip_serializing_if = "Option::is_none")]
48    #[serde(borrow)]
49    pub distribution_policy: Option<DistributionPolicy<'a>>,
50}
51
52/// Typed wrapper for GetRecord response with this collection's record type.
53
54#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
55#[serde(rename_all = "camelCase")]
56pub struct ConfigurationGetRecordOutput<'a> {
57    #[serde(skip_serializing_if = "Option::is_none")]
58    #[serde(borrow)]
59    pub cid: Option<Cid<'a>>,
60    #[serde(borrow)]
61    pub uri: AtUri<'a>,
62    #[serde(borrow)]
63    pub value: Configuration<'a>,
64}
65
66impl<'a> Configuration<'a> {
67    pub fn uri(
68        uri: impl Into<CowStr<'a>>,
69    ) -> Result<RecordUri<'a, ConfigurationRecord>, UriError> {
70        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
71    }
72}
73
74/// Marker type for deserializing records from this collection.
75
76#[derive(Debug, Serialize, Deserialize)]
77pub struct ConfigurationRecord;
78impl XrpcResp for ConfigurationRecord {
79    const NSID: &'static str = "place.stream.metadata.configuration";
80    const ENCODING: &'static str = "application/json";
81    type Output<'de> = ConfigurationGetRecordOutput<'de>;
82    type Err<'de> = RecordError<'de>;
83}
84
85impl From<ConfigurationGetRecordOutput<'_>> for Configuration<'_> {
86    fn from(output: ConfigurationGetRecordOutput<'_>) -> Self {
87        use jacquard_common::IntoStatic;
88        output.value.into_static()
89    }
90}
91
92impl Collection for Configuration<'_> {
93    const NSID: &'static str = "place.stream.metadata.configuration";
94    type Record = ConfigurationRecord;
95}
96
97impl Collection for ConfigurationRecord {
98    const NSID: &'static str = "place.stream.metadata.configuration";
99    type Record = ConfigurationRecord;
100}
101
102impl<'a> LexiconSchema for Configuration<'a> {
103    fn nsid() -> &'static str {
104        "place.stream.metadata.configuration"
105    }
106    fn def_name() -> &'static str {
107        "main"
108    }
109    fn lexicon_doc() -> LexiconDoc<'static> {
110        lexicon_doc_place_stream_metadata_configuration()
111    }
112    fn validate(&self) -> Result<(), ConstraintError> {
113        Ok(())
114    }
115}
116
117pub mod configuration_state {
118
119    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
120    #[allow(unused)]
121    use ::core::marker::PhantomData;
122    mod sealed {
123        pub trait Sealed {}
124    }
125    /// State trait tracking which required fields have been set
126    pub trait State: sealed::Sealed {}
127    /// Empty state - all required fields are unset
128    pub struct Empty(());
129    impl sealed::Sealed for Empty {}
130    impl State for Empty {}
131    /// Marker types for field names
132    #[allow(non_camel_case_types)]
133    pub mod members {}
134}
135
136/// Builder for constructing an instance of this type
137pub struct ConfigurationBuilder<'a, S: configuration_state::State> {
138    _state: PhantomData<fn() -> S>,
139    _fields: (
140        Option<ContentRights<'a>>,
141        Option<ContentWarnings<'a>>,
142        Option<DistributionPolicy<'a>>,
143    ),
144    _lifetime: PhantomData<&'a ()>,
145}
146
147impl<'a> Configuration<'a> {
148    /// Create a new builder for this type
149    pub fn new() -> ConfigurationBuilder<'a, configuration_state::Empty> {
150        ConfigurationBuilder::new()
151    }
152}
153
154impl<'a> ConfigurationBuilder<'a, configuration_state::Empty> {
155    /// Create a new builder with all fields unset
156    pub fn new() -> Self {
157        ConfigurationBuilder {
158            _state: PhantomData,
159            _fields: (None, None, None),
160            _lifetime: PhantomData,
161        }
162    }
163}
164
165impl<'a, S: configuration_state::State> ConfigurationBuilder<'a, S> {
166    /// Set the `contentRights` field (optional)
167    pub fn content_rights(
168        mut self,
169        value: impl Into<Option<ContentRights<'a>>>,
170    ) -> Self {
171        self._fields.0 = value.into();
172        self
173    }
174    /// Set the `contentRights` field to an Option value (optional)
175    pub fn maybe_content_rights(mut self, value: Option<ContentRights<'a>>) -> Self {
176        self._fields.0 = value;
177        self
178    }
179}
180
181impl<'a, S: configuration_state::State> ConfigurationBuilder<'a, S> {
182    /// Set the `contentWarnings` field (optional)
183    pub fn content_warnings(
184        mut self,
185        value: impl Into<Option<ContentWarnings<'a>>>,
186    ) -> Self {
187        self._fields.1 = value.into();
188        self
189    }
190    /// Set the `contentWarnings` field to an Option value (optional)
191    pub fn maybe_content_warnings(mut self, value: Option<ContentWarnings<'a>>) -> Self {
192        self._fields.1 = value;
193        self
194    }
195}
196
197impl<'a, S: configuration_state::State> ConfigurationBuilder<'a, S> {
198    /// Set the `distributionPolicy` field (optional)
199    pub fn distribution_policy(
200        mut self,
201        value: impl Into<Option<DistributionPolicy<'a>>>,
202    ) -> Self {
203        self._fields.2 = value.into();
204        self
205    }
206    /// Set the `distributionPolicy` field to an Option value (optional)
207    pub fn maybe_distribution_policy(
208        mut self,
209        value: Option<DistributionPolicy<'a>>,
210    ) -> Self {
211        self._fields.2 = value;
212        self
213    }
214}
215
216impl<'a, S> ConfigurationBuilder<'a, S>
217where
218    S: configuration_state::State,
219{
220    /// Build the final struct
221    pub fn build(self) -> Configuration<'a> {
222        Configuration {
223            content_rights: self._fields.0,
224            content_warnings: self._fields.1,
225            distribution_policy: self._fields.2,
226            extra_data: Default::default(),
227        }
228    }
229    /// Build the final struct with custom extra_data
230    pub fn build_with_data(
231        self,
232        extra_data: BTreeMap<
233            jacquard_common::deps::smol_str::SmolStr,
234            jacquard_common::types::value::Data<'a>,
235        >,
236    ) -> Configuration<'a> {
237        Configuration {
238            content_rights: self._fields.0,
239            content_warnings: self._fields.1,
240            distribution_policy: self._fields.2,
241            extra_data: Some(extra_data),
242        }
243    }
244}
245
246fn lexicon_doc_place_stream_metadata_configuration() -> LexiconDoc<'static> {
247    #[allow(unused_imports)]
248    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
249    use jacquard_lexicon::lexicon::*;
250    use alloc::collections::BTreeMap;
251    LexiconDoc {
252        lexicon: Lexicon::Lexicon1,
253        id: CowStr::new_static("place.stream.metadata.configuration"),
254        defs: {
255            let mut map = BTreeMap::new();
256            map.insert(
257                SmolStr::new_static("main"),
258                LexUserType::Record(LexRecord {
259                    description: Some(
260                        CowStr::new_static(
261                            "Default metadata record for livestream including content warnings, rights, and distribution policy",
262                        ),
263                    ),
264                    key: Some(CowStr::new_static("literal:self")),
265                    record: LexRecordRecord::Object(LexObject {
266                        properties: {
267                            #[allow(unused_mut)]
268                            let mut map = BTreeMap::new();
269                            map.insert(
270                                SmolStr::new_static("contentRights"),
271                                LexObjectProperty::Ref(LexRef {
272                                    r#ref: CowStr::new_static(
273                                        "place.stream.metadata.contentRights",
274                                    ),
275                                    ..Default::default()
276                                }),
277                            );
278                            map.insert(
279                                SmolStr::new_static("contentWarnings"),
280                                LexObjectProperty::Ref(LexRef {
281                                    r#ref: CowStr::new_static(
282                                        "place.stream.metadata.contentWarnings",
283                                    ),
284                                    ..Default::default()
285                                }),
286                            );
287                            map.insert(
288                                SmolStr::new_static("distributionPolicy"),
289                                LexObjectProperty::Ref(LexRef {
290                                    r#ref: CowStr::new_static(
291                                        "place.stream.metadata.distributionPolicy",
292                                    ),
293                                    ..Default::default()
294                                }),
295                            );
296                            map
297                        },
298                        ..Default::default()
299                    }),
300                    ..Default::default()
301                }),
302            );
303            map
304        },
305        ..Default::default()
306    }
307}