jacquard_api/network_slices/
actor.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.actor.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod profile;
9
10#[jacquard_derive::lexicon]
11#[derive(
12    serde::Serialize,
13    serde::Deserialize,
14    Debug,
15    Clone,
16    PartialEq,
17    Eq,
18    jacquard_derive::IntoStatic
19)]
20#[serde(rename_all = "camelCase")]
21pub struct ProfileViewBasic<'a> {
22    #[serde(skip_serializing_if = "std::option::Option::is_none")]
23    #[serde(borrow)]
24    pub avatar: Option<jacquard_common::CowStr<'a>>,
25    /// Free-form profile description text.
26    #[serde(skip_serializing_if = "std::option::Option::is_none")]
27    #[serde(borrow)]
28    pub description: Option<jacquard_common::CowStr<'a>>,
29    #[serde(borrow)]
30    pub did: jacquard_common::types::string::Did<'a>,
31    #[serde(skip_serializing_if = "std::option::Option::is_none")]
32    #[serde(borrow)]
33    pub display_name: Option<jacquard_common::CowStr<'a>>,
34    #[serde(borrow)]
35    pub handle: jacquard_common::types::string::Handle<'a>,
36}
37
38pub mod profile_view_basic_state {
39
40    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
41    #[allow(unused)]
42    use ::core::marker::PhantomData;
43    mod sealed {
44        pub trait Sealed {}
45    }
46    /// State trait tracking which required fields have been set
47    pub trait State: sealed::Sealed {
48        type Did;
49        type Handle;
50    }
51    /// Empty state - all required fields are unset
52    pub struct Empty(());
53    impl sealed::Sealed for Empty {}
54    impl State for Empty {
55        type Did = Unset;
56        type Handle = Unset;
57    }
58    ///State transition - sets the `did` field to Set
59    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
60    impl<S: State> sealed::Sealed for SetDid<S> {}
61    impl<S: State> State for SetDid<S> {
62        type Did = Set<members::did>;
63        type Handle = S::Handle;
64    }
65    ///State transition - sets the `handle` field to Set
66    pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
67    impl<S: State> sealed::Sealed for SetHandle<S> {}
68    impl<S: State> State for SetHandle<S> {
69        type Did = S::Did;
70        type Handle = Set<members::handle>;
71    }
72    /// Marker types for field names
73    #[allow(non_camel_case_types)]
74    pub mod members {
75        ///Marker type for the `did` field
76        pub struct did(());
77        ///Marker type for the `handle` field
78        pub struct handle(());
79    }
80}
81
82/// Builder for constructing an instance of this type
83pub struct ProfileViewBasicBuilder<'a, S: profile_view_basic_state::State> {
84    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
85    __unsafe_private_named: (
86        ::core::option::Option<jacquard_common::CowStr<'a>>,
87        ::core::option::Option<jacquard_common::CowStr<'a>>,
88        ::core::option::Option<jacquard_common::types::string::Did<'a>>,
89        ::core::option::Option<jacquard_common::CowStr<'a>>,
90        ::core::option::Option<jacquard_common::types::string::Handle<'a>>,
91    ),
92    _phantom: ::core::marker::PhantomData<&'a ()>,
93}
94
95impl<'a> ProfileViewBasic<'a> {
96    /// Create a new builder for this type
97    pub fn new() -> ProfileViewBasicBuilder<'a, profile_view_basic_state::Empty> {
98        ProfileViewBasicBuilder::new()
99    }
100}
101
102impl<'a> ProfileViewBasicBuilder<'a, profile_view_basic_state::Empty> {
103    /// Create a new builder with all fields unset
104    pub fn new() -> Self {
105        ProfileViewBasicBuilder {
106            _phantom_state: ::core::marker::PhantomData,
107            __unsafe_private_named: (None, None, None, None, None),
108            _phantom: ::core::marker::PhantomData,
109        }
110    }
111}
112
113impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
114    /// Set the `avatar` field (optional)
115    pub fn avatar(
116        mut self,
117        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
118    ) -> Self {
119        self.__unsafe_private_named.0 = value.into();
120        self
121    }
122    /// Set the `avatar` field to an Option value (optional)
123    pub fn maybe_avatar(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
124        self.__unsafe_private_named.0 = value;
125        self
126    }
127}
128
129impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
130    /// Set the `description` field (optional)
131    pub fn description(
132        mut self,
133        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
134    ) -> Self {
135        self.__unsafe_private_named.1 = value.into();
136        self
137    }
138    /// Set the `description` field to an Option value (optional)
139    pub fn maybe_description(
140        mut self,
141        value: Option<jacquard_common::CowStr<'a>>,
142    ) -> Self {
143        self.__unsafe_private_named.1 = value;
144        self
145    }
146}
147
148impl<'a, S> ProfileViewBasicBuilder<'a, S>
149where
150    S: profile_view_basic_state::State,
151    S::Did: profile_view_basic_state::IsUnset,
152{
153    /// Set the `did` field (required)
154    pub fn did(
155        mut self,
156        value: impl Into<jacquard_common::types::string::Did<'a>>,
157    ) -> ProfileViewBasicBuilder<'a, profile_view_basic_state::SetDid<S>> {
158        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
159        ProfileViewBasicBuilder {
160            _phantom_state: ::core::marker::PhantomData,
161            __unsafe_private_named: self.__unsafe_private_named,
162            _phantom: ::core::marker::PhantomData,
163        }
164    }
165}
166
167impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
168    /// Set the `displayName` field (optional)
169    pub fn display_name(
170        mut self,
171        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
172    ) -> Self {
173        self.__unsafe_private_named.3 = value.into();
174        self
175    }
176    /// Set the `displayName` field to an Option value (optional)
177    pub fn maybe_display_name(
178        mut self,
179        value: Option<jacquard_common::CowStr<'a>>,
180    ) -> Self {
181        self.__unsafe_private_named.3 = value;
182        self
183    }
184}
185
186impl<'a, S> ProfileViewBasicBuilder<'a, S>
187where
188    S: profile_view_basic_state::State,
189    S::Handle: profile_view_basic_state::IsUnset,
190{
191    /// Set the `handle` field (required)
192    pub fn handle(
193        mut self,
194        value: impl Into<jacquard_common::types::string::Handle<'a>>,
195    ) -> ProfileViewBasicBuilder<'a, profile_view_basic_state::SetHandle<S>> {
196        self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
197        ProfileViewBasicBuilder {
198            _phantom_state: ::core::marker::PhantomData,
199            __unsafe_private_named: self.__unsafe_private_named,
200            _phantom: ::core::marker::PhantomData,
201        }
202    }
203}
204
205impl<'a, S> ProfileViewBasicBuilder<'a, S>
206where
207    S: profile_view_basic_state::State,
208    S::Did: profile_view_basic_state::IsSet,
209    S::Handle: profile_view_basic_state::IsSet,
210{
211    /// Build the final struct
212    pub fn build(self) -> ProfileViewBasic<'a> {
213        ProfileViewBasic {
214            avatar: self.__unsafe_private_named.0,
215            description: self.__unsafe_private_named.1,
216            did: self.__unsafe_private_named.2.unwrap(),
217            display_name: self.__unsafe_private_named.3,
218            handle: self.__unsafe_private_named.4.unwrap(),
219            extra_data: Default::default(),
220        }
221    }
222    /// Build the final struct with custom extra_data
223    pub fn build_with_data(
224        self,
225        extra_data: std::collections::BTreeMap<
226            jacquard_common::smol_str::SmolStr,
227            jacquard_common::types::value::Data<'a>,
228        >,
229    ) -> ProfileViewBasic<'a> {
230        ProfileViewBasic {
231            avatar: self.__unsafe_private_named.0,
232            description: self.__unsafe_private_named.1,
233            did: self.__unsafe_private_named.2.unwrap(),
234            display_name: self.__unsafe_private_named.3,
235            handle: self.__unsafe_private_named.4.unwrap(),
236            extra_data: Some(extra_data),
237        }
238    }
239}
240
241fn lexicon_doc_network_slices_actor_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
242    'static,
243> {
244    ::jacquard_lexicon::lexicon::LexiconDoc {
245        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
246        id: ::jacquard_common::CowStr::new_static("network.slices.actor.defs"),
247        revision: None,
248        description: None,
249        defs: {
250            let mut map = ::std::collections::BTreeMap::new();
251            map.insert(
252                ::jacquard_common::smol_str::SmolStr::new_static("profileViewBasic"),
253                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
254                    description: None,
255                    required: Some(
256                        vec![
257                            ::jacquard_common::smol_str::SmolStr::new_static("did"),
258                            ::jacquard_common::smol_str::SmolStr::new_static("handle")
259                        ],
260                    ),
261                    nullable: None,
262                    properties: {
263                        #[allow(unused_mut)]
264                        let mut map = ::std::collections::BTreeMap::new();
265                        map.insert(
266                            ::jacquard_common::smol_str::SmolStr::new_static("avatar"),
267                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
268                                description: None,
269                                format: None,
270                                default: None,
271                                min_length: None,
272                                max_length: None,
273                                min_graphemes: None,
274                                max_graphemes: None,
275                                r#enum: None,
276                                r#const: None,
277                                known_values: None,
278                            }),
279                        );
280                        map.insert(
281                            ::jacquard_common::smol_str::SmolStr::new_static(
282                                "description",
283                            ),
284                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
285                                description: Some(
286                                    ::jacquard_common::CowStr::new_static(
287                                        "Free-form profile description text.",
288                                    ),
289                                ),
290                                format: None,
291                                default: None,
292                                min_length: None,
293                                max_length: Some(2560usize),
294                                min_graphemes: None,
295                                max_graphemes: Some(256usize),
296                                r#enum: None,
297                                r#const: None,
298                                known_values: None,
299                            }),
300                        );
301                        map.insert(
302                            ::jacquard_common::smol_str::SmolStr::new_static("did"),
303                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
304                                description: None,
305                                format: Some(
306                                    ::jacquard_lexicon::lexicon::LexStringFormat::Did,
307                                ),
308                                default: None,
309                                min_length: None,
310                                max_length: None,
311                                min_graphemes: None,
312                                max_graphemes: None,
313                                r#enum: None,
314                                r#const: None,
315                                known_values: None,
316                            }),
317                        );
318                        map.insert(
319                            ::jacquard_common::smol_str::SmolStr::new_static(
320                                "displayName",
321                            ),
322                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
323                                description: None,
324                                format: None,
325                                default: None,
326                                min_length: None,
327                                max_length: Some(640usize),
328                                min_graphemes: None,
329                                max_graphemes: Some(64usize),
330                                r#enum: None,
331                                r#const: None,
332                                known_values: None,
333                            }),
334                        );
335                        map.insert(
336                            ::jacquard_common::smol_str::SmolStr::new_static("handle"),
337                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
338                                description: None,
339                                format: Some(
340                                    ::jacquard_lexicon::lexicon::LexStringFormat::Handle,
341                                ),
342                                default: None,
343                                min_length: None,
344                                max_length: None,
345                                min_graphemes: None,
346                                max_graphemes: None,
347                                r#enum: None,
348                                r#const: None,
349                                known_values: None,
350                            }),
351                        );
352                        map
353                    },
354                }),
355            );
356            map
357        },
358    }
359}
360
361impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ProfileViewBasic<'a> {
362    fn nsid() -> &'static str {
363        "network.slices.actor.defs"
364    }
365    fn def_name() -> &'static str {
366        "profileViewBasic"
367    }
368    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
369        lexicon_doc_network_slices_actor_defs()
370    }
371    fn validate(
372        &self,
373    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
374        if let Some(ref value) = self.description {
375            #[allow(unused_comparisons)]
376            if <str>::len(value.as_ref()) > 2560usize {
377                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
378                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
379                        "description",
380                    ),
381                    max: 2560usize,
382                    actual: <str>::len(value.as_ref()),
383                });
384            }
385        }
386        if let Some(ref value) = self.description {
387            {
388                let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
389                        value.as_ref(),
390                        true,
391                    )
392                    .count();
393                if count > 256usize {
394                    return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
395                        path: ::jacquard_lexicon::validation::ValidationPath::from_field(
396                            "description",
397                        ),
398                        max: 256usize,
399                        actual: count,
400                    });
401                }
402            }
403        }
404        if let Some(ref value) = self.display_name {
405            #[allow(unused_comparisons)]
406            if <str>::len(value.as_ref()) > 640usize {
407                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
408                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
409                        "display_name",
410                    ),
411                    max: 640usize,
412                    actual: <str>::len(value.as_ref()),
413                });
414            }
415        }
416        if let Some(ref value) = self.display_name {
417            {
418                let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
419                        value.as_ref(),
420                        true,
421                    )
422                    .count();
423                if count > 64usize {
424                    return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
425                        path: ::jacquard_lexicon::validation::ValidationPath::from_field(
426                            "display_name",
427                        ),
428                        max: 64usize,
429                        actual: count,
430                    });
431                }
432            }
433        }
434        Ok(())
435    }
436}