jacquard_api/place_stream/chat/
profile.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.chat.profile
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Customizations for the color of a user's name in chat
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 Color<'a> {
21    pub blue: i64,
22    pub green: i64,
23    pub red: i64,
24}
25
26pub mod color_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        type Red;
37        type Green;
38        type Blue;
39    }
40    /// Empty state - all required fields are unset
41    pub struct Empty(());
42    impl sealed::Sealed for Empty {}
43    impl State for Empty {
44        type Red = Unset;
45        type Green = Unset;
46        type Blue = Unset;
47    }
48    ///State transition - sets the `red` field to Set
49    pub struct SetRed<S: State = Empty>(PhantomData<fn() -> S>);
50    impl<S: State> sealed::Sealed for SetRed<S> {}
51    impl<S: State> State for SetRed<S> {
52        type Red = Set<members::red>;
53        type Green = S::Green;
54        type Blue = S::Blue;
55    }
56    ///State transition - sets the `green` field to Set
57    pub struct SetGreen<S: State = Empty>(PhantomData<fn() -> S>);
58    impl<S: State> sealed::Sealed for SetGreen<S> {}
59    impl<S: State> State for SetGreen<S> {
60        type Red = S::Red;
61        type Green = Set<members::green>;
62        type Blue = S::Blue;
63    }
64    ///State transition - sets the `blue` field to Set
65    pub struct SetBlue<S: State = Empty>(PhantomData<fn() -> S>);
66    impl<S: State> sealed::Sealed for SetBlue<S> {}
67    impl<S: State> State for SetBlue<S> {
68        type Red = S::Red;
69        type Green = S::Green;
70        type Blue = Set<members::blue>;
71    }
72    /// Marker types for field names
73    #[allow(non_camel_case_types)]
74    pub mod members {
75        ///Marker type for the `red` field
76        pub struct red(());
77        ///Marker type for the `green` field
78        pub struct green(());
79        ///Marker type for the `blue` field
80        pub struct blue(());
81    }
82}
83
84/// Builder for constructing an instance of this type
85pub struct ColorBuilder<'a, S: color_state::State> {
86    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
87    __unsafe_private_named: (
88        ::core::option::Option<i64>,
89        ::core::option::Option<i64>,
90        ::core::option::Option<i64>,
91    ),
92    _phantom: ::core::marker::PhantomData<&'a ()>,
93}
94
95impl<'a> Color<'a> {
96    /// Create a new builder for this type
97    pub fn new() -> ColorBuilder<'a, color_state::Empty> {
98        ColorBuilder::new()
99    }
100}
101
102impl<'a> ColorBuilder<'a, color_state::Empty> {
103    /// Create a new builder with all fields unset
104    pub fn new() -> Self {
105        ColorBuilder {
106            _phantom_state: ::core::marker::PhantomData,
107            __unsafe_private_named: (None, None, None),
108            _phantom: ::core::marker::PhantomData,
109        }
110    }
111}
112
113impl<'a, S> ColorBuilder<'a, S>
114where
115    S: color_state::State,
116    S::Blue: color_state::IsUnset,
117{
118    /// Set the `blue` field (required)
119    pub fn blue(
120        mut self,
121        value: impl Into<i64>,
122    ) -> ColorBuilder<'a, color_state::SetBlue<S>> {
123        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
124        ColorBuilder {
125            _phantom_state: ::core::marker::PhantomData,
126            __unsafe_private_named: self.__unsafe_private_named,
127            _phantom: ::core::marker::PhantomData,
128        }
129    }
130}
131
132impl<'a, S> ColorBuilder<'a, S>
133where
134    S: color_state::State,
135    S::Green: color_state::IsUnset,
136{
137    /// Set the `green` field (required)
138    pub fn green(
139        mut self,
140        value: impl Into<i64>,
141    ) -> ColorBuilder<'a, color_state::SetGreen<S>> {
142        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
143        ColorBuilder {
144            _phantom_state: ::core::marker::PhantomData,
145            __unsafe_private_named: self.__unsafe_private_named,
146            _phantom: ::core::marker::PhantomData,
147        }
148    }
149}
150
151impl<'a, S> ColorBuilder<'a, S>
152where
153    S: color_state::State,
154    S::Red: color_state::IsUnset,
155{
156    /// Set the `red` field (required)
157    pub fn red(
158        mut self,
159        value: impl Into<i64>,
160    ) -> ColorBuilder<'a, color_state::SetRed<S>> {
161        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
162        ColorBuilder {
163            _phantom_state: ::core::marker::PhantomData,
164            __unsafe_private_named: self.__unsafe_private_named,
165            _phantom: ::core::marker::PhantomData,
166        }
167    }
168}
169
170impl<'a, S> ColorBuilder<'a, S>
171where
172    S: color_state::State,
173    S::Red: color_state::IsSet,
174    S::Green: color_state::IsSet,
175    S::Blue: color_state::IsSet,
176{
177    /// Build the final struct
178    pub fn build(self) -> Color<'a> {
179        Color {
180            blue: self.__unsafe_private_named.0.unwrap(),
181            green: self.__unsafe_private_named.1.unwrap(),
182            red: self.__unsafe_private_named.2.unwrap(),
183            extra_data: Default::default(),
184        }
185    }
186    /// Build the final struct with custom extra_data
187    pub fn build_with_data(
188        self,
189        extra_data: std::collections::BTreeMap<
190            jacquard_common::smol_str::SmolStr,
191            jacquard_common::types::value::Data<'a>,
192        >,
193    ) -> Color<'a> {
194        Color {
195            blue: self.__unsafe_private_named.0.unwrap(),
196            green: self.__unsafe_private_named.1.unwrap(),
197            red: self.__unsafe_private_named.2.unwrap(),
198            extra_data: Some(extra_data),
199        }
200    }
201}
202
203fn lexicon_doc_place_stream_chat_profile() -> ::jacquard_lexicon::lexicon::LexiconDoc<
204    'static,
205> {
206    ::jacquard_lexicon::lexicon::LexiconDoc {
207        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
208        id: ::jacquard_common::CowStr::new_static("place.stream.chat.profile"),
209        revision: None,
210        description: None,
211        defs: {
212            let mut map = ::std::collections::BTreeMap::new();
213            map.insert(
214                ::jacquard_common::smol_str::SmolStr::new_static("color"),
215                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
216                    description: Some(
217                        ::jacquard_common::CowStr::new_static(
218                            "Customizations for the color of a user's name in chat",
219                        ),
220                    ),
221                    required: Some(
222                        vec![
223                            ::jacquard_common::smol_str::SmolStr::new_static("red"),
224                            ::jacquard_common::smol_str::SmolStr::new_static("green"),
225                            ::jacquard_common::smol_str::SmolStr::new_static("blue")
226                        ],
227                    ),
228                    nullable: None,
229                    properties: {
230                        #[allow(unused_mut)]
231                        let mut map = ::std::collections::BTreeMap::new();
232                        map.insert(
233                            ::jacquard_common::smol_str::SmolStr::new_static("blue"),
234                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
235                                description: None,
236                                default: None,
237                                minimum: Some(0i64),
238                                maximum: Some(255i64),
239                                r#enum: None,
240                                r#const: None,
241                            }),
242                        );
243                        map.insert(
244                            ::jacquard_common::smol_str::SmolStr::new_static("green"),
245                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
246                                description: None,
247                                default: None,
248                                minimum: Some(0i64),
249                                maximum: Some(255i64),
250                                r#enum: None,
251                                r#const: None,
252                            }),
253                        );
254                        map.insert(
255                            ::jacquard_common::smol_str::SmolStr::new_static("red"),
256                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
257                                description: None,
258                                default: None,
259                                minimum: Some(0i64),
260                                maximum: Some(255i64),
261                                r#enum: None,
262                                r#const: None,
263                            }),
264                        );
265                        map
266                    },
267                }),
268            );
269            map.insert(
270                ::jacquard_common::smol_str::SmolStr::new_static("main"),
271                ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
272                    description: Some(
273                        ::jacquard_common::CowStr::new_static(
274                            "Record containing customizations for a user's chat profile.",
275                        ),
276                    ),
277                    key: Some(::jacquard_common::CowStr::new_static("literal:self")),
278                    record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
279                        description: None,
280                        required: None,
281                        nullable: None,
282                        properties: {
283                            #[allow(unused_mut)]
284                            let mut map = ::std::collections::BTreeMap::new();
285                            map.insert(
286                                ::jacquard_common::smol_str::SmolStr::new_static("color"),
287                                ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
288                                    description: None,
289                                    r#ref: ::jacquard_common::CowStr::new_static("#color"),
290                                }),
291                            );
292                            map
293                        },
294                    }),
295                }),
296            );
297            map
298        },
299    }
300}
301
302impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Color<'a> {
303    fn nsid() -> &'static str {
304        "place.stream.chat.profile"
305    }
306    fn def_name() -> &'static str {
307        "color"
308    }
309    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
310        lexicon_doc_place_stream_chat_profile()
311    }
312    fn validate(
313        &self,
314    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
315        {
316            let value = &self.blue;
317            if *value > 255i64 {
318                return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
319                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
320                        "blue",
321                    ),
322                    max: 255i64,
323                    actual: *value,
324                });
325            }
326        }
327        {
328            let value = &self.blue;
329            if *value < 0i64 {
330                return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
331                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
332                        "blue",
333                    ),
334                    min: 0i64,
335                    actual: *value,
336                });
337            }
338        }
339        {
340            let value = &self.green;
341            if *value > 255i64 {
342                return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
343                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
344                        "green",
345                    ),
346                    max: 255i64,
347                    actual: *value,
348                });
349            }
350        }
351        {
352            let value = &self.green;
353            if *value < 0i64 {
354                return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
355                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
356                        "green",
357                    ),
358                    min: 0i64,
359                    actual: *value,
360                });
361            }
362        }
363        {
364            let value = &self.red;
365            if *value > 255i64 {
366                return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
367                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
368                        "red",
369                    ),
370                    max: 255i64,
371                    actual: *value,
372                });
373            }
374        }
375        {
376            let value = &self.red;
377            if *value < 0i64 {
378                return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
379                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
380                        "red",
381                    ),
382                    min: 0i64,
383                    actual: *value,
384                });
385            }
386        }
387        Ok(())
388    }
389}
390
391/// Record containing customizations for a user's chat profile.
392#[jacquard_derive::lexicon]
393#[derive(
394    serde::Serialize,
395    serde::Deserialize,
396    Debug,
397    Clone,
398    PartialEq,
399    Eq,
400    jacquard_derive::IntoStatic
401)]
402#[serde(rename_all = "camelCase")]
403pub struct Profile<'a> {
404    #[serde(skip_serializing_if = "std::option::Option::is_none")]
405    #[serde(borrow)]
406    pub color: Option<crate::place_stream::chat::profile::Color<'a>>,
407}
408
409pub mod profile_state {
410
411    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
412    #[allow(unused)]
413    use ::core::marker::PhantomData;
414    mod sealed {
415        pub trait Sealed {}
416    }
417    /// State trait tracking which required fields have been set
418    pub trait State: sealed::Sealed {}
419    /// Empty state - all required fields are unset
420    pub struct Empty(());
421    impl sealed::Sealed for Empty {}
422    impl State for Empty {}
423    /// Marker types for field names
424    #[allow(non_camel_case_types)]
425    pub mod members {}
426}
427
428/// Builder for constructing an instance of this type
429pub struct ProfileBuilder<'a, S: profile_state::State> {
430    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
431    __unsafe_private_named: (
432        ::core::option::Option<crate::place_stream::chat::profile::Color<'a>>,
433    ),
434    _phantom: ::core::marker::PhantomData<&'a ()>,
435}
436
437impl<'a> Profile<'a> {
438    /// Create a new builder for this type
439    pub fn new() -> ProfileBuilder<'a, profile_state::Empty> {
440        ProfileBuilder::new()
441    }
442}
443
444impl<'a> ProfileBuilder<'a, profile_state::Empty> {
445    /// Create a new builder with all fields unset
446    pub fn new() -> Self {
447        ProfileBuilder {
448            _phantom_state: ::core::marker::PhantomData,
449            __unsafe_private_named: (None,),
450            _phantom: ::core::marker::PhantomData,
451        }
452    }
453}
454
455impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
456    /// Set the `color` field (optional)
457    pub fn color(
458        mut self,
459        value: impl Into<Option<crate::place_stream::chat::profile::Color<'a>>>,
460    ) -> Self {
461        self.__unsafe_private_named.0 = value.into();
462        self
463    }
464    /// Set the `color` field to an Option value (optional)
465    pub fn maybe_color(
466        mut self,
467        value: Option<crate::place_stream::chat::profile::Color<'a>>,
468    ) -> Self {
469        self.__unsafe_private_named.0 = value;
470        self
471    }
472}
473
474impl<'a, S> ProfileBuilder<'a, S>
475where
476    S: profile_state::State,
477{
478    /// Build the final struct
479    pub fn build(self) -> Profile<'a> {
480        Profile {
481            color: self.__unsafe_private_named.0,
482            extra_data: Default::default(),
483        }
484    }
485    /// Build the final struct with custom extra_data
486    pub fn build_with_data(
487        self,
488        extra_data: std::collections::BTreeMap<
489            jacquard_common::smol_str::SmolStr,
490            jacquard_common::types::value::Data<'a>,
491        >,
492    ) -> Profile<'a> {
493        Profile {
494            color: self.__unsafe_private_named.0,
495            extra_data: Some(extra_data),
496        }
497    }
498}
499
500impl<'a> Profile<'a> {
501    pub fn uri(
502        uri: impl Into<jacquard_common::CowStr<'a>>,
503    ) -> Result<
504        jacquard_common::types::uri::RecordUri<'a, ProfileRecord>,
505        jacquard_common::types::uri::UriError,
506    > {
507        jacquard_common::types::uri::RecordUri::try_from_uri(
508            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
509        )
510    }
511}
512
513/// Typed wrapper for GetRecord response with this collection's record type.
514#[derive(
515    serde::Serialize,
516    serde::Deserialize,
517    Debug,
518    Clone,
519    PartialEq,
520    Eq,
521    jacquard_derive::IntoStatic
522)]
523#[serde(rename_all = "camelCase")]
524pub struct ProfileGetRecordOutput<'a> {
525    #[serde(skip_serializing_if = "std::option::Option::is_none")]
526    #[serde(borrow)]
527    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
528    #[serde(borrow)]
529    pub uri: jacquard_common::types::string::AtUri<'a>,
530    #[serde(borrow)]
531    pub value: Profile<'a>,
532}
533
534impl From<ProfileGetRecordOutput<'_>> for Profile<'_> {
535    fn from(output: ProfileGetRecordOutput<'_>) -> Self {
536        use jacquard_common::IntoStatic;
537        output.value.into_static()
538    }
539}
540
541impl jacquard_common::types::collection::Collection for Profile<'_> {
542    const NSID: &'static str = "place.stream.chat.profile";
543    type Record = ProfileRecord;
544}
545
546/// Marker type for deserializing records from this collection.
547#[derive(Debug, serde::Serialize, serde::Deserialize)]
548pub struct ProfileRecord;
549impl jacquard_common::xrpc::XrpcResp for ProfileRecord {
550    const NSID: &'static str = "place.stream.chat.profile";
551    const ENCODING: &'static str = "application/json";
552    type Output<'de> = ProfileGetRecordOutput<'de>;
553    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
554}
555
556impl jacquard_common::types::collection::Collection for ProfileRecord {
557    const NSID: &'static str = "place.stream.chat.profile";
558    type Record = ProfileRecord;
559}
560
561impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Profile<'a> {
562    fn nsid() -> &'static str {
563        "place.stream.chat.profile"
564    }
565    fn def_name() -> &'static str {
566        "main"
567    }
568    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
569        lexicon_doc_place_stream_chat_profile()
570    }
571    fn validate(
572        &self,
573    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
574        Ok(())
575    }
576}