jacquard_api/network_slices/
actor.rs1pub mod profile;
9
10
11#[allow(unused_imports)]
12use alloc::collections::BTreeMap;
13
14#[allow(unused_imports)]
15use core::marker::PhantomData;
16use jacquard_common::CowStr;
17
18#[allow(unused_imports)]
19use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
20use jacquard_common::types::string::{Did, Handle};
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
29#[lexicon]
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
31#[serde(rename_all = "camelCase")]
32pub struct ProfileViewBasic<'a> {
33 #[serde(skip_serializing_if = "Option::is_none")]
34 #[serde(borrow)]
35 pub avatar: Option<CowStr<'a>>,
36 #[serde(skip_serializing_if = "Option::is_none")]
38 #[serde(borrow)]
39 pub description: Option<CowStr<'a>>,
40 #[serde(borrow)]
41 pub did: Did<'a>,
42 #[serde(skip_serializing_if = "Option::is_none")]
43 #[serde(borrow)]
44 pub display_name: Option<CowStr<'a>>,
45 #[serde(borrow)]
46 pub handle: Handle<'a>,
47}
48
49impl<'a> LexiconSchema for ProfileViewBasic<'a> {
50 fn nsid() -> &'static str {
51 "network.slices.actor.defs"
52 }
53 fn def_name() -> &'static str {
54 "profileViewBasic"
55 }
56 fn lexicon_doc() -> LexiconDoc<'static> {
57 lexicon_doc_network_slices_actor_defs()
58 }
59 fn validate(&self) -> Result<(), ConstraintError> {
60 if let Some(ref value) = self.description {
61 #[allow(unused_comparisons)]
62 if <str>::len(value.as_ref()) > 2560usize {
63 return Err(ConstraintError::MaxLength {
64 path: ValidationPath::from_field("description"),
65 max: 2560usize,
66 actual: <str>::len(value.as_ref()),
67 });
68 }
69 }
70 if let Some(ref value) = self.description {
71 {
72 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
73 if count > 256usize {
74 return Err(ConstraintError::MaxGraphemes {
75 path: ValidationPath::from_field("description"),
76 max: 256usize,
77 actual: count,
78 });
79 }
80 }
81 }
82 if let Some(ref value) = self.display_name {
83 #[allow(unused_comparisons)]
84 if <str>::len(value.as_ref()) > 640usize {
85 return Err(ConstraintError::MaxLength {
86 path: ValidationPath::from_field("display_name"),
87 max: 640usize,
88 actual: <str>::len(value.as_ref()),
89 });
90 }
91 }
92 if let Some(ref value) = self.display_name {
93 {
94 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
95 if count > 64usize {
96 return Err(ConstraintError::MaxGraphemes {
97 path: ValidationPath::from_field("display_name"),
98 max: 64usize,
99 actual: count,
100 });
101 }
102 }
103 }
104 Ok(())
105 }
106}
107
108pub mod profile_view_basic_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 pub trait State: sealed::Sealed {
118 type Did;
119 type Handle;
120 }
121 pub struct Empty(());
123 impl sealed::Sealed for Empty {}
124 impl State for Empty {
125 type Did = Unset;
126 type Handle = Unset;
127 }
128 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
130 impl<S: State> sealed::Sealed for SetDid<S> {}
131 impl<S: State> State for SetDid<S> {
132 type Did = Set<members::did>;
133 type Handle = S::Handle;
134 }
135 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
137 impl<S: State> sealed::Sealed for SetHandle<S> {}
138 impl<S: State> State for SetHandle<S> {
139 type Did = S::Did;
140 type Handle = Set<members::handle>;
141 }
142 #[allow(non_camel_case_types)]
144 pub mod members {
145 pub struct did(());
147 pub struct handle(());
149 }
150}
151
152pub struct ProfileViewBasicBuilder<'a, S: profile_view_basic_state::State> {
154 _state: PhantomData<fn() -> S>,
155 _fields: (
156 Option<CowStr<'a>>,
157 Option<CowStr<'a>>,
158 Option<Did<'a>>,
159 Option<CowStr<'a>>,
160 Option<Handle<'a>>,
161 ),
162 _lifetime: PhantomData<&'a ()>,
163}
164
165impl<'a> ProfileViewBasic<'a> {
166 pub fn new() -> ProfileViewBasicBuilder<'a, profile_view_basic_state::Empty> {
168 ProfileViewBasicBuilder::new()
169 }
170}
171
172impl<'a> ProfileViewBasicBuilder<'a, profile_view_basic_state::Empty> {
173 pub fn new() -> Self {
175 ProfileViewBasicBuilder {
176 _state: PhantomData,
177 _fields: (None, None, None, None, None),
178 _lifetime: PhantomData,
179 }
180 }
181}
182
183impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
184 pub fn avatar(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
186 self._fields.0 = value.into();
187 self
188 }
189 pub fn maybe_avatar(mut self, value: Option<CowStr<'a>>) -> Self {
191 self._fields.0 = value;
192 self
193 }
194}
195
196impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
197 pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
199 self._fields.1 = value.into();
200 self
201 }
202 pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
204 self._fields.1 = value;
205 self
206 }
207}
208
209impl<'a, S> ProfileViewBasicBuilder<'a, S>
210where
211 S: profile_view_basic_state::State,
212 S::Did: profile_view_basic_state::IsUnset,
213{
214 pub fn did(
216 mut self,
217 value: impl Into<Did<'a>>,
218 ) -> ProfileViewBasicBuilder<'a, profile_view_basic_state::SetDid<S>> {
219 self._fields.2 = Option::Some(value.into());
220 ProfileViewBasicBuilder {
221 _state: PhantomData,
222 _fields: self._fields,
223 _lifetime: PhantomData,
224 }
225 }
226}
227
228impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
229 pub fn display_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
231 self._fields.3 = value.into();
232 self
233 }
234 pub fn maybe_display_name(mut self, value: Option<CowStr<'a>>) -> Self {
236 self._fields.3 = value;
237 self
238 }
239}
240
241impl<'a, S> ProfileViewBasicBuilder<'a, S>
242where
243 S: profile_view_basic_state::State,
244 S::Handle: profile_view_basic_state::IsUnset,
245{
246 pub fn handle(
248 mut self,
249 value: impl Into<Handle<'a>>,
250 ) -> ProfileViewBasicBuilder<'a, profile_view_basic_state::SetHandle<S>> {
251 self._fields.4 = Option::Some(value.into());
252 ProfileViewBasicBuilder {
253 _state: PhantomData,
254 _fields: self._fields,
255 _lifetime: PhantomData,
256 }
257 }
258}
259
260impl<'a, S> ProfileViewBasicBuilder<'a, S>
261where
262 S: profile_view_basic_state::State,
263 S::Did: profile_view_basic_state::IsSet,
264 S::Handle: profile_view_basic_state::IsSet,
265{
266 pub fn build(self) -> ProfileViewBasic<'a> {
268 ProfileViewBasic {
269 avatar: self._fields.0,
270 description: self._fields.1,
271 did: self._fields.2.unwrap(),
272 display_name: self._fields.3,
273 handle: self._fields.4.unwrap(),
274 extra_data: Default::default(),
275 }
276 }
277 pub fn build_with_data(
279 self,
280 extra_data: BTreeMap<
281 jacquard_common::deps::smol_str::SmolStr,
282 jacquard_common::types::value::Data<'a>,
283 >,
284 ) -> ProfileViewBasic<'a> {
285 ProfileViewBasic {
286 avatar: self._fields.0,
287 description: self._fields.1,
288 did: self._fields.2.unwrap(),
289 display_name: self._fields.3,
290 handle: self._fields.4.unwrap(),
291 extra_data: Some(extra_data),
292 }
293 }
294}
295
296fn lexicon_doc_network_slices_actor_defs() -> LexiconDoc<'static> {
297 #[allow(unused_imports)]
298 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
299 use jacquard_lexicon::lexicon::*;
300 use alloc::collections::BTreeMap;
301 LexiconDoc {
302 lexicon: Lexicon::Lexicon1,
303 id: CowStr::new_static("network.slices.actor.defs"),
304 defs: {
305 let mut map = BTreeMap::new();
306 map.insert(
307 SmolStr::new_static("profileViewBasic"),
308 LexUserType::Object(LexObject {
309 required: Some(
310 vec![SmolStr::new_static("did"), SmolStr::new_static("handle")],
311 ),
312 properties: {
313 #[allow(unused_mut)]
314 let mut map = BTreeMap::new();
315 map.insert(
316 SmolStr::new_static("avatar"),
317 LexObjectProperty::String(LexString { ..Default::default() }),
318 );
319 map.insert(
320 SmolStr::new_static("description"),
321 LexObjectProperty::String(LexString {
322 description: Some(
323 CowStr::new_static("Free-form profile description text."),
324 ),
325 max_length: Some(2560usize),
326 max_graphemes: Some(256usize),
327 ..Default::default()
328 }),
329 );
330 map.insert(
331 SmolStr::new_static("did"),
332 LexObjectProperty::String(LexString {
333 format: Some(LexStringFormat::Did),
334 ..Default::default()
335 }),
336 );
337 map.insert(
338 SmolStr::new_static("displayName"),
339 LexObjectProperty::String(LexString {
340 max_length: Some(640usize),
341 max_graphemes: Some(64usize),
342 ..Default::default()
343 }),
344 );
345 map.insert(
346 SmolStr::new_static("handle"),
347 LexObjectProperty::String(LexString {
348 format: Some(LexStringFormat::Handle),
349 ..Default::default()
350 }),
351 );
352 map
353 },
354 ..Default::default()
355 }),
356 );
357 map
358 },
359 ..Default::default()
360 }
361}