Skip to main content

jacquard_api/network_slices/
slice.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.slice.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8//! Generated bindings for the `network.slices.slice` Lexicon namespace/module.
9pub mod clear_slice_records;
10pub mod create_o_auth_client;
11pub mod delete_o_auth_client;
12pub mod get_actors;
13pub mod get_jetstream_logs;
14pub mod get_jetstream_status;
15pub mod get_job_logs;
16pub mod get_job_status;
17pub mod get_o_auth_clients;
18pub mod get_slice_records;
19pub mod get_sparklines;
20pub mod get_sync_summary;
21pub mod start_sync;
22pub mod stats;
23pub mod sync_user_collections;
24pub mod update_o_auth_client;
25
26
27#[allow(unused_imports)]
28use alloc::collections::BTreeMap;
29
30#[allow(unused_imports)]
31use core::marker::PhantomData;
32use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
33
34#[allow(unused_imports)]
35use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
36use jacquard_common::deps::smol_str::SmolStr;
37use jacquard_common::types::collection::{Collection, RecordError};
38use jacquard_common::types::string::{AtUri, Cid, Datetime};
39use jacquard_common::types::uri::{RecordUri, UriError};
40use jacquard_common::types::value::Data;
41use jacquard_common::xrpc::XrpcResp;
42use jacquard_derive::{IntoStatic, lexicon};
43use jacquard_lexicon::lexicon::LexiconDoc;
44use jacquard_lexicon::schema::LexiconSchema;
45
46#[allow(unused_imports)]
47use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
48use serde::{Serialize, Deserialize};
49use crate::network_slices::actor::ProfileViewBasic;
50use crate::network_slices::slice;
51
52#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
53#[serde(
54    rename_all = "camelCase",
55    rename = "network.slices.slice",
56    tag = "$type",
57    bound(deserialize = "S: Deserialize<'de> + BosStr")
58)]
59pub struct Slice<S: BosStr = DefaultStr> {
60    ///When the slice was created
61    pub created_at: Datetime,
62    ///Primary domain namespace for this slice (e.g. social.grain)
63    pub domain: S,
64    ///Name of the slice
65    pub name: S,
66    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
67    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
68}
69
70/// Typed wrapper for GetRecord response with this collection's record type.
71
72#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
73#[serde(rename_all = "camelCase")]
74pub struct SliceGetRecordOutput<S: BosStr = DefaultStr> {
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub cid: Option<Cid<S>>,
77    pub uri: AtUri<S>,
78    pub value: Slice<S>,
79}
80
81
82#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
83#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
84pub struct SliceView<S: BosStr = DefaultStr> {
85    pub cid: Cid<S>,
86    pub created_at: Datetime,
87    ///Profile of the slice creator
88    pub creator: ProfileViewBasic<S>,
89    ///Primary domain namespace for this slice (e.g. social.grain)
90    pub domain: S,
91    ///Total number of unique indexed actors in this slice
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub indexed_actor_count: Option<i64>,
94    ///Number of collections with indexed records
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub indexed_collection_count: Option<i64>,
97    ///Total number of indexed records in this slice
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub indexed_record_count: Option<i64>,
100    ///Display name of the slice
101    pub name: S,
102    ///Recent activity sparkline data points for the last 24 hours
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub sparkline: Option<Vec<slice::SparklinePoint<S>>>,
105    pub uri: AtUri<S>,
106    ///Total number of waitlist invites for this slice
107    #[serde(skip_serializing_if = "Option::is_none")]
108    pub waitlist_invite_count: Option<i64>,
109    ///Total number of waitlist requests for this slice
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub waitlist_request_count: Option<i64>,
112    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
113    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
114}
115
116
117#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
118#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
119pub struct SparklinePoint<S: BosStr = DefaultStr> {
120    pub count: i64,
121    pub timestamp: Datetime,
122    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
123    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
124}
125
126impl<S: BosStr> Slice<S> {
127    pub fn uri(uri: S) -> Result<RecordUri<S, SliceRecord>, UriError> {
128        RecordUri::try_from_uri(AtUri::new(uri)?)
129    }
130}
131
132/// Marker type for deserializing records from this collection.
133
134#[derive(Debug, Serialize, Deserialize)]
135pub struct SliceRecord;
136impl XrpcResp for SliceRecord {
137    const NSID: &'static str = "network.slices.slice";
138    const ENCODING: &'static str = "application/json";
139    type Output<S: BosStr> = SliceGetRecordOutput<S>;
140    type Err = RecordError;
141}
142
143impl<S: BosStr> From<SliceGetRecordOutput<S>> for Slice<S> {
144    fn from(output: SliceGetRecordOutput<S>) -> Self {
145        output.value
146    }
147}
148
149impl<S: BosStr> Collection for Slice<S> {
150    const NSID: &'static str = "network.slices.slice";
151    type Record = SliceRecord;
152}
153
154impl Collection for SliceRecord {
155    const NSID: &'static str = "network.slices.slice";
156    type Record = SliceRecord;
157}
158
159impl<S: BosStr> LexiconSchema for Slice<S> {
160    fn nsid() -> &'static str {
161        "network.slices.slice"
162    }
163    fn def_name() -> &'static str {
164        "main"
165    }
166    fn lexicon_doc() -> LexiconDoc<'static> {
167        lexicon_doc_network_slices_slice()
168    }
169    fn validate(&self) -> Result<(), ConstraintError> {
170        {
171            let value = &self.domain;
172            #[allow(unused_comparisons)]
173            if <str>::len(value.as_ref()) > 256usize {
174                return Err(ConstraintError::MaxLength {
175                    path: ValidationPath::from_field("domain"),
176                    max: 256usize,
177                    actual: <str>::len(value.as_ref()),
178                });
179            }
180        }
181        {
182            let value = &self.name;
183            #[allow(unused_comparisons)]
184            if <str>::len(value.as_ref()) > 256usize {
185                return Err(ConstraintError::MaxLength {
186                    path: ValidationPath::from_field("name"),
187                    max: 256usize,
188                    actual: <str>::len(value.as_ref()),
189                });
190            }
191        }
192        Ok(())
193    }
194}
195
196impl<S: BosStr> LexiconSchema for SliceView<S> {
197    fn nsid() -> &'static str {
198        "network.slices.slice.defs"
199    }
200    fn def_name() -> &'static str {
201        "sliceView"
202    }
203    fn lexicon_doc() -> LexiconDoc<'static> {
204        lexicon_doc_network_slices_slice_defs()
205    }
206    fn validate(&self) -> Result<(), ConstraintError> {
207        Ok(())
208    }
209}
210
211impl<S: BosStr> LexiconSchema for SparklinePoint<S> {
212    fn nsid() -> &'static str {
213        "network.slices.slice.defs"
214    }
215    fn def_name() -> &'static str {
216        "sparklinePoint"
217    }
218    fn lexicon_doc() -> LexiconDoc<'static> {
219        lexicon_doc_network_slices_slice_defs()
220    }
221    fn validate(&self) -> Result<(), ConstraintError> {
222        {
223            let value = &self.count;
224            if *value < 0i64 {
225                return Err(ConstraintError::Minimum {
226                    path: ValidationPath::from_field("count"),
227                    min: 0i64,
228                    actual: *value,
229                });
230            }
231        }
232        Ok(())
233    }
234}
235
236pub mod slice_state {
237
238    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
239    #[allow(unused)]
240    use ::core::marker::PhantomData;
241    mod sealed {
242        pub trait Sealed {}
243    }
244    /// State trait tracking which required fields have been set
245    pub trait State: sealed::Sealed {
246        type CreatedAt;
247        type Domain;
248        type Name;
249    }
250    /// Empty state - all required fields are unset
251    pub struct Empty(());
252    impl sealed::Sealed for Empty {}
253    impl State for Empty {
254        type CreatedAt = Unset;
255        type Domain = Unset;
256        type Name = Unset;
257    }
258    ///State transition - sets the `created_at` field to Set
259    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
260    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
261    impl<St: State> State for SetCreatedAt<St> {
262        type CreatedAt = Set<members::created_at>;
263        type Domain = St::Domain;
264        type Name = St::Name;
265    }
266    ///State transition - sets the `domain` field to Set
267    pub struct SetDomain<St: State = Empty>(PhantomData<fn() -> St>);
268    impl<St: State> sealed::Sealed for SetDomain<St> {}
269    impl<St: State> State for SetDomain<St> {
270        type CreatedAt = St::CreatedAt;
271        type Domain = Set<members::domain>;
272        type Name = St::Name;
273    }
274    ///State transition - sets the `name` field to Set
275    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
276    impl<St: State> sealed::Sealed for SetName<St> {}
277    impl<St: State> State for SetName<St> {
278        type CreatedAt = St::CreatedAt;
279        type Domain = St::Domain;
280        type Name = Set<members::name>;
281    }
282    /// Marker types for field names
283    #[allow(non_camel_case_types)]
284    pub mod members {
285        ///Marker type for the `created_at` field
286        pub struct created_at(());
287        ///Marker type for the `domain` field
288        pub struct domain(());
289        ///Marker type for the `name` field
290        pub struct name(());
291    }
292}
293
294/// Builder for constructing an instance of this type.
295pub struct SliceBuilder<St: slice_state::State, S: BosStr = DefaultStr> {
296    _state: PhantomData<fn() -> St>,
297    _fields: (Option<Datetime>, Option<S>, Option<S>),
298    _type: PhantomData<fn() -> S>,
299}
300
301impl Slice<DefaultStr> {
302    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
303    pub fn new() -> SliceBuilder<slice_state::Empty, DefaultStr> {
304        SliceBuilder::new()
305    }
306}
307
308impl<S: BosStr> Slice<S> {
309    /// Create a new builder for this type
310    pub fn builder() -> SliceBuilder<slice_state::Empty, S> {
311        SliceBuilder::builder()
312    }
313}
314
315impl SliceBuilder<slice_state::Empty, DefaultStr> {
316    /// Create a new builder with all fields unset, using the default string type, if needed
317    pub fn new() -> Self {
318        SliceBuilder {
319            _state: PhantomData,
320            _fields: (None, None, None),
321            _type: PhantomData,
322        }
323    }
324}
325
326impl<S: BosStr> SliceBuilder<slice_state::Empty, S> {
327    /// Create a new builder with all fields unset
328    pub fn builder() -> Self {
329        SliceBuilder {
330            _state: PhantomData,
331            _fields: (None, None, None),
332            _type: PhantomData,
333        }
334    }
335}
336
337impl<St, S: BosStr> SliceBuilder<St, S>
338where
339    St: slice_state::State,
340    St::CreatedAt: slice_state::IsUnset,
341{
342    /// Set the `createdAt` field (required)
343    pub fn created_at(
344        mut self,
345        value: impl Into<Datetime>,
346    ) -> SliceBuilder<slice_state::SetCreatedAt<St>, S> {
347        self._fields.0 = Option::Some(value.into());
348        SliceBuilder {
349            _state: PhantomData,
350            _fields: self._fields,
351            _type: PhantomData,
352        }
353    }
354}
355
356impl<St, S: BosStr> SliceBuilder<St, S>
357where
358    St: slice_state::State,
359    St::Domain: slice_state::IsUnset,
360{
361    /// Set the `domain` field (required)
362    pub fn domain(
363        mut self,
364        value: impl Into<S>,
365    ) -> SliceBuilder<slice_state::SetDomain<St>, S> {
366        self._fields.1 = Option::Some(value.into());
367        SliceBuilder {
368            _state: PhantomData,
369            _fields: self._fields,
370            _type: PhantomData,
371        }
372    }
373}
374
375impl<St, S: BosStr> SliceBuilder<St, S>
376where
377    St: slice_state::State,
378    St::Name: slice_state::IsUnset,
379{
380    /// Set the `name` field (required)
381    pub fn name(
382        mut self,
383        value: impl Into<S>,
384    ) -> SliceBuilder<slice_state::SetName<St>, S> {
385        self._fields.2 = Option::Some(value.into());
386        SliceBuilder {
387            _state: PhantomData,
388            _fields: self._fields,
389            _type: PhantomData,
390        }
391    }
392}
393
394impl<St, S: BosStr> SliceBuilder<St, S>
395where
396    St: slice_state::State,
397    St::CreatedAt: slice_state::IsSet,
398    St::Domain: slice_state::IsSet,
399    St::Name: slice_state::IsSet,
400{
401    /// Build the final struct.
402    pub fn build(self) -> Slice<S> {
403        Slice {
404            created_at: self._fields.0.unwrap(),
405            domain: self._fields.1.unwrap(),
406            name: self._fields.2.unwrap(),
407            extra_data: Default::default(),
408        }
409    }
410    /// Build the final struct with custom extra_data.
411    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Slice<S> {
412        Slice {
413            created_at: self._fields.0.unwrap(),
414            domain: self._fields.1.unwrap(),
415            name: self._fields.2.unwrap(),
416            extra_data: Some(extra_data),
417        }
418    }
419}
420
421fn lexicon_doc_network_slices_slice() -> LexiconDoc<'static> {
422    #[allow(unused_imports)]
423    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
424    use jacquard_lexicon::lexicon::*;
425    use alloc::collections::BTreeMap;
426    LexiconDoc {
427        lexicon: Lexicon::Lexicon1,
428        id: CowStr::new_static("network.slices.slice"),
429        defs: {
430            let mut map = BTreeMap::new();
431            map.insert(
432                SmolStr::new_static("main"),
433                LexUserType::Record(LexRecord {
434                    key: Some(CowStr::new_static("tid")),
435                    record: LexRecordRecord::Object(LexObject {
436                        required: Some(
437                            vec![
438                                SmolStr::new_static("name"), SmolStr::new_static("domain"),
439                                SmolStr::new_static("createdAt")
440                            ],
441                        ),
442                        properties: {
443                            #[allow(unused_mut)]
444                            let mut map = BTreeMap::new();
445                            map.insert(
446                                SmolStr::new_static("createdAt"),
447                                LexObjectProperty::String(LexString {
448                                    description: Some(
449                                        CowStr::new_static("When the slice was created"),
450                                    ),
451                                    format: Some(LexStringFormat::Datetime),
452                                    ..Default::default()
453                                }),
454                            );
455                            map.insert(
456                                SmolStr::new_static("domain"),
457                                LexObjectProperty::String(LexString {
458                                    description: Some(
459                                        CowStr::new_static(
460                                            "Primary domain namespace for this slice (e.g. social.grain)",
461                                        ),
462                                    ),
463                                    max_length: Some(256usize),
464                                    ..Default::default()
465                                }),
466                            );
467                            map.insert(
468                                SmolStr::new_static("name"),
469                                LexObjectProperty::String(LexString {
470                                    description: Some(CowStr::new_static("Name of the slice")),
471                                    max_length: Some(256usize),
472                                    ..Default::default()
473                                }),
474                            );
475                            map
476                        },
477                        ..Default::default()
478                    }),
479                    ..Default::default()
480                }),
481            );
482            map
483        },
484        ..Default::default()
485    }
486}
487
488pub mod slice_view_state {
489
490    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
491    #[allow(unused)]
492    use ::core::marker::PhantomData;
493    mod sealed {
494        pub trait Sealed {}
495    }
496    /// State trait tracking which required fields have been set
497    pub trait State: sealed::Sealed {
498        type Cid;
499        type CreatedAt;
500        type Creator;
501        type Domain;
502        type Name;
503        type Uri;
504    }
505    /// Empty state - all required fields are unset
506    pub struct Empty(());
507    impl sealed::Sealed for Empty {}
508    impl State for Empty {
509        type Cid = Unset;
510        type CreatedAt = Unset;
511        type Creator = Unset;
512        type Domain = Unset;
513        type Name = Unset;
514        type Uri = Unset;
515    }
516    ///State transition - sets the `cid` field to Set
517    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
518    impl<St: State> sealed::Sealed for SetCid<St> {}
519    impl<St: State> State for SetCid<St> {
520        type Cid = Set<members::cid>;
521        type CreatedAt = St::CreatedAt;
522        type Creator = St::Creator;
523        type Domain = St::Domain;
524        type Name = St::Name;
525        type Uri = St::Uri;
526    }
527    ///State transition - sets the `created_at` field to Set
528    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
529    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
530    impl<St: State> State for SetCreatedAt<St> {
531        type Cid = St::Cid;
532        type CreatedAt = Set<members::created_at>;
533        type Creator = St::Creator;
534        type Domain = St::Domain;
535        type Name = St::Name;
536        type Uri = St::Uri;
537    }
538    ///State transition - sets the `creator` field to Set
539    pub struct SetCreator<St: State = Empty>(PhantomData<fn() -> St>);
540    impl<St: State> sealed::Sealed for SetCreator<St> {}
541    impl<St: State> State for SetCreator<St> {
542        type Cid = St::Cid;
543        type CreatedAt = St::CreatedAt;
544        type Creator = Set<members::creator>;
545        type Domain = St::Domain;
546        type Name = St::Name;
547        type Uri = St::Uri;
548    }
549    ///State transition - sets the `domain` field to Set
550    pub struct SetDomain<St: State = Empty>(PhantomData<fn() -> St>);
551    impl<St: State> sealed::Sealed for SetDomain<St> {}
552    impl<St: State> State for SetDomain<St> {
553        type Cid = St::Cid;
554        type CreatedAt = St::CreatedAt;
555        type Creator = St::Creator;
556        type Domain = Set<members::domain>;
557        type Name = St::Name;
558        type Uri = St::Uri;
559    }
560    ///State transition - sets the `name` field to Set
561    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
562    impl<St: State> sealed::Sealed for SetName<St> {}
563    impl<St: State> State for SetName<St> {
564        type Cid = St::Cid;
565        type CreatedAt = St::CreatedAt;
566        type Creator = St::Creator;
567        type Domain = St::Domain;
568        type Name = Set<members::name>;
569        type Uri = St::Uri;
570    }
571    ///State transition - sets the `uri` field to Set
572    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
573    impl<St: State> sealed::Sealed for SetUri<St> {}
574    impl<St: State> State for SetUri<St> {
575        type Cid = St::Cid;
576        type CreatedAt = St::CreatedAt;
577        type Creator = St::Creator;
578        type Domain = St::Domain;
579        type Name = St::Name;
580        type Uri = Set<members::uri>;
581    }
582    /// Marker types for field names
583    #[allow(non_camel_case_types)]
584    pub mod members {
585        ///Marker type for the `cid` field
586        pub struct cid(());
587        ///Marker type for the `created_at` field
588        pub struct created_at(());
589        ///Marker type for the `creator` field
590        pub struct creator(());
591        ///Marker type for the `domain` field
592        pub struct domain(());
593        ///Marker type for the `name` field
594        pub struct name(());
595        ///Marker type for the `uri` field
596        pub struct uri(());
597    }
598}
599
600/// Builder for constructing an instance of this type.
601pub struct SliceViewBuilder<St: slice_view_state::State, S: BosStr = DefaultStr> {
602    _state: PhantomData<fn() -> St>,
603    _fields: (
604        Option<Cid<S>>,
605        Option<Datetime>,
606        Option<ProfileViewBasic<S>>,
607        Option<S>,
608        Option<i64>,
609        Option<i64>,
610        Option<i64>,
611        Option<S>,
612        Option<Vec<slice::SparklinePoint<S>>>,
613        Option<AtUri<S>>,
614        Option<i64>,
615        Option<i64>,
616    ),
617    _type: PhantomData<fn() -> S>,
618}
619
620impl SliceView<DefaultStr> {
621    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
622    pub fn new() -> SliceViewBuilder<slice_view_state::Empty, DefaultStr> {
623        SliceViewBuilder::new()
624    }
625}
626
627impl<S: BosStr> SliceView<S> {
628    /// Create a new builder for this type
629    pub fn builder() -> SliceViewBuilder<slice_view_state::Empty, S> {
630        SliceViewBuilder::builder()
631    }
632}
633
634impl SliceViewBuilder<slice_view_state::Empty, DefaultStr> {
635    /// Create a new builder with all fields unset, using the default string type, if needed
636    pub fn new() -> Self {
637        SliceViewBuilder {
638            _state: PhantomData,
639            _fields: (
640                None,
641                None,
642                None,
643                None,
644                None,
645                None,
646                None,
647                None,
648                None,
649                None,
650                None,
651                None,
652            ),
653            _type: PhantomData,
654        }
655    }
656}
657
658impl<S: BosStr> SliceViewBuilder<slice_view_state::Empty, S> {
659    /// Create a new builder with all fields unset
660    pub fn builder() -> Self {
661        SliceViewBuilder {
662            _state: PhantomData,
663            _fields: (
664                None,
665                None,
666                None,
667                None,
668                None,
669                None,
670                None,
671                None,
672                None,
673                None,
674                None,
675                None,
676            ),
677            _type: PhantomData,
678        }
679    }
680}
681
682impl<St, S: BosStr> SliceViewBuilder<St, S>
683where
684    St: slice_view_state::State,
685    St::Cid: slice_view_state::IsUnset,
686{
687    /// Set the `cid` field (required)
688    pub fn cid(
689        mut self,
690        value: impl Into<Cid<S>>,
691    ) -> SliceViewBuilder<slice_view_state::SetCid<St>, S> {
692        self._fields.0 = Option::Some(value.into());
693        SliceViewBuilder {
694            _state: PhantomData,
695            _fields: self._fields,
696            _type: PhantomData,
697        }
698    }
699}
700
701impl<St, S: BosStr> SliceViewBuilder<St, S>
702where
703    St: slice_view_state::State,
704    St::CreatedAt: slice_view_state::IsUnset,
705{
706    /// Set the `createdAt` field (required)
707    pub fn created_at(
708        mut self,
709        value: impl Into<Datetime>,
710    ) -> SliceViewBuilder<slice_view_state::SetCreatedAt<St>, S> {
711        self._fields.1 = Option::Some(value.into());
712        SliceViewBuilder {
713            _state: PhantomData,
714            _fields: self._fields,
715            _type: PhantomData,
716        }
717    }
718}
719
720impl<St, S: BosStr> SliceViewBuilder<St, S>
721where
722    St: slice_view_state::State,
723    St::Creator: slice_view_state::IsUnset,
724{
725    /// Set the `creator` field (required)
726    pub fn creator(
727        mut self,
728        value: impl Into<ProfileViewBasic<S>>,
729    ) -> SliceViewBuilder<slice_view_state::SetCreator<St>, S> {
730        self._fields.2 = Option::Some(value.into());
731        SliceViewBuilder {
732            _state: PhantomData,
733            _fields: self._fields,
734            _type: PhantomData,
735        }
736    }
737}
738
739impl<St, S: BosStr> SliceViewBuilder<St, S>
740where
741    St: slice_view_state::State,
742    St::Domain: slice_view_state::IsUnset,
743{
744    /// Set the `domain` field (required)
745    pub fn domain(
746        mut self,
747        value: impl Into<S>,
748    ) -> SliceViewBuilder<slice_view_state::SetDomain<St>, S> {
749        self._fields.3 = Option::Some(value.into());
750        SliceViewBuilder {
751            _state: PhantomData,
752            _fields: self._fields,
753            _type: PhantomData,
754        }
755    }
756}
757
758impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
759    /// Set the `indexedActorCount` field (optional)
760    pub fn indexed_actor_count(mut self, value: impl Into<Option<i64>>) -> Self {
761        self._fields.4 = value.into();
762        self
763    }
764    /// Set the `indexedActorCount` field to an Option value (optional)
765    pub fn maybe_indexed_actor_count(mut self, value: Option<i64>) -> Self {
766        self._fields.4 = value;
767        self
768    }
769}
770
771impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
772    /// Set the `indexedCollectionCount` field (optional)
773    pub fn indexed_collection_count(mut self, value: impl Into<Option<i64>>) -> Self {
774        self._fields.5 = value.into();
775        self
776    }
777    /// Set the `indexedCollectionCount` field to an Option value (optional)
778    pub fn maybe_indexed_collection_count(mut self, value: Option<i64>) -> Self {
779        self._fields.5 = value;
780        self
781    }
782}
783
784impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
785    /// Set the `indexedRecordCount` field (optional)
786    pub fn indexed_record_count(mut self, value: impl Into<Option<i64>>) -> Self {
787        self._fields.6 = value.into();
788        self
789    }
790    /// Set the `indexedRecordCount` field to an Option value (optional)
791    pub fn maybe_indexed_record_count(mut self, value: Option<i64>) -> Self {
792        self._fields.6 = value;
793        self
794    }
795}
796
797impl<St, S: BosStr> SliceViewBuilder<St, S>
798where
799    St: slice_view_state::State,
800    St::Name: slice_view_state::IsUnset,
801{
802    /// Set the `name` field (required)
803    pub fn name(
804        mut self,
805        value: impl Into<S>,
806    ) -> SliceViewBuilder<slice_view_state::SetName<St>, S> {
807        self._fields.7 = Option::Some(value.into());
808        SliceViewBuilder {
809            _state: PhantomData,
810            _fields: self._fields,
811            _type: PhantomData,
812        }
813    }
814}
815
816impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
817    /// Set the `sparkline` field (optional)
818    pub fn sparkline(
819        mut self,
820        value: impl Into<Option<Vec<slice::SparklinePoint<S>>>>,
821    ) -> Self {
822        self._fields.8 = value.into();
823        self
824    }
825    /// Set the `sparkline` field to an Option value (optional)
826    pub fn maybe_sparkline(
827        mut self,
828        value: Option<Vec<slice::SparklinePoint<S>>>,
829    ) -> Self {
830        self._fields.8 = value;
831        self
832    }
833}
834
835impl<St, S: BosStr> SliceViewBuilder<St, S>
836where
837    St: slice_view_state::State,
838    St::Uri: slice_view_state::IsUnset,
839{
840    /// Set the `uri` field (required)
841    pub fn uri(
842        mut self,
843        value: impl Into<AtUri<S>>,
844    ) -> SliceViewBuilder<slice_view_state::SetUri<St>, S> {
845        self._fields.9 = Option::Some(value.into());
846        SliceViewBuilder {
847            _state: PhantomData,
848            _fields: self._fields,
849            _type: PhantomData,
850        }
851    }
852}
853
854impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
855    /// Set the `waitlistInviteCount` field (optional)
856    pub fn waitlist_invite_count(mut self, value: impl Into<Option<i64>>) -> Self {
857        self._fields.10 = value.into();
858        self
859    }
860    /// Set the `waitlistInviteCount` field to an Option value (optional)
861    pub fn maybe_waitlist_invite_count(mut self, value: Option<i64>) -> Self {
862        self._fields.10 = value;
863        self
864    }
865}
866
867impl<St: slice_view_state::State, S: BosStr> SliceViewBuilder<St, S> {
868    /// Set the `waitlistRequestCount` field (optional)
869    pub fn waitlist_request_count(mut self, value: impl Into<Option<i64>>) -> Self {
870        self._fields.11 = value.into();
871        self
872    }
873    /// Set the `waitlistRequestCount` field to an Option value (optional)
874    pub fn maybe_waitlist_request_count(mut self, value: Option<i64>) -> Self {
875        self._fields.11 = value;
876        self
877    }
878}
879
880impl<St, S: BosStr> SliceViewBuilder<St, S>
881where
882    St: slice_view_state::State,
883    St::Cid: slice_view_state::IsSet,
884    St::CreatedAt: slice_view_state::IsSet,
885    St::Creator: slice_view_state::IsSet,
886    St::Domain: slice_view_state::IsSet,
887    St::Name: slice_view_state::IsSet,
888    St::Uri: slice_view_state::IsSet,
889{
890    /// Build the final struct.
891    pub fn build(self) -> SliceView<S> {
892        SliceView {
893            cid: self._fields.0.unwrap(),
894            created_at: self._fields.1.unwrap(),
895            creator: self._fields.2.unwrap(),
896            domain: self._fields.3.unwrap(),
897            indexed_actor_count: self._fields.4,
898            indexed_collection_count: self._fields.5,
899            indexed_record_count: self._fields.6,
900            name: self._fields.7.unwrap(),
901            sparkline: self._fields.8,
902            uri: self._fields.9.unwrap(),
903            waitlist_invite_count: self._fields.10,
904            waitlist_request_count: self._fields.11,
905            extra_data: Default::default(),
906        }
907    }
908    /// Build the final struct with custom extra_data.
909    pub fn build_with_data(
910        self,
911        extra_data: BTreeMap<SmolStr, Data<S>>,
912    ) -> SliceView<S> {
913        SliceView {
914            cid: self._fields.0.unwrap(),
915            created_at: self._fields.1.unwrap(),
916            creator: self._fields.2.unwrap(),
917            domain: self._fields.3.unwrap(),
918            indexed_actor_count: self._fields.4,
919            indexed_collection_count: self._fields.5,
920            indexed_record_count: self._fields.6,
921            name: self._fields.7.unwrap(),
922            sparkline: self._fields.8,
923            uri: self._fields.9.unwrap(),
924            waitlist_invite_count: self._fields.10,
925            waitlist_request_count: self._fields.11,
926            extra_data: Some(extra_data),
927        }
928    }
929}
930
931fn lexicon_doc_network_slices_slice_defs() -> LexiconDoc<'static> {
932    #[allow(unused_imports)]
933    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
934    use jacquard_lexicon::lexicon::*;
935    use alloc::collections::BTreeMap;
936    LexiconDoc {
937        lexicon: Lexicon::Lexicon1,
938        id: CowStr::new_static("network.slices.slice.defs"),
939        defs: {
940            let mut map = BTreeMap::new();
941            map.insert(
942                SmolStr::new_static("sliceView"),
943                LexUserType::Object(LexObject {
944                    required: Some(
945                        vec![
946                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
947                            SmolStr::new_static("name"), SmolStr::new_static("domain"),
948                            SmolStr::new_static("creator"),
949                            SmolStr::new_static("createdAt")
950                        ],
951                    ),
952                    properties: {
953                        #[allow(unused_mut)]
954                        let mut map = BTreeMap::new();
955                        map.insert(
956                            SmolStr::new_static("cid"),
957                            LexObjectProperty::String(LexString {
958                                format: Some(LexStringFormat::Cid),
959                                ..Default::default()
960                            }),
961                        );
962                        map.insert(
963                            SmolStr::new_static("createdAt"),
964                            LexObjectProperty::String(LexString {
965                                format: Some(LexStringFormat::Datetime),
966                                ..Default::default()
967                            }),
968                        );
969                        map.insert(
970                            SmolStr::new_static("creator"),
971                            LexObjectProperty::Ref(LexRef {
972                                r#ref: CowStr::new_static(
973                                    "network.slices.actor.defs#profileViewBasic",
974                                ),
975                                ..Default::default()
976                            }),
977                        );
978                        map.insert(
979                            SmolStr::new_static("domain"),
980                            LexObjectProperty::String(LexString {
981                                description: Some(
982                                    CowStr::new_static(
983                                        "Primary domain namespace for this slice (e.g. social.grain)",
984                                    ),
985                                ),
986                                ..Default::default()
987                            }),
988                        );
989                        map.insert(
990                            SmolStr::new_static("indexedActorCount"),
991                            LexObjectProperty::Integer(LexInteger {
992                                ..Default::default()
993                            }),
994                        );
995                        map.insert(
996                            SmolStr::new_static("indexedCollectionCount"),
997                            LexObjectProperty::Integer(LexInteger {
998                                ..Default::default()
999                            }),
1000                        );
1001                        map.insert(
1002                            SmolStr::new_static("indexedRecordCount"),
1003                            LexObjectProperty::Integer(LexInteger {
1004                                ..Default::default()
1005                            }),
1006                        );
1007                        map.insert(
1008                            SmolStr::new_static("name"),
1009                            LexObjectProperty::String(LexString {
1010                                description: Some(
1011                                    CowStr::new_static("Display name of the slice"),
1012                                ),
1013                                ..Default::default()
1014                            }),
1015                        );
1016                        map.insert(
1017                            SmolStr::new_static("sparkline"),
1018                            LexObjectProperty::Array(LexArray {
1019                                description: Some(
1020                                    CowStr::new_static(
1021                                        "Recent activity sparkline data points for the last 24 hours",
1022                                    ),
1023                                ),
1024                                items: LexArrayItem::Ref(LexRef {
1025                                    r#ref: CowStr::new_static("#sparklinePoint"),
1026                                    ..Default::default()
1027                                }),
1028                                ..Default::default()
1029                            }),
1030                        );
1031                        map.insert(
1032                            SmolStr::new_static("uri"),
1033                            LexObjectProperty::String(LexString {
1034                                format: Some(LexStringFormat::AtUri),
1035                                ..Default::default()
1036                            }),
1037                        );
1038                        map.insert(
1039                            SmolStr::new_static("waitlistInviteCount"),
1040                            LexObjectProperty::Integer(LexInteger {
1041                                ..Default::default()
1042                            }),
1043                        );
1044                        map.insert(
1045                            SmolStr::new_static("waitlistRequestCount"),
1046                            LexObjectProperty::Integer(LexInteger {
1047                                ..Default::default()
1048                            }),
1049                        );
1050                        map
1051                    },
1052                    ..Default::default()
1053                }),
1054            );
1055            map.insert(
1056                SmolStr::new_static("sparklinePoint"),
1057                LexUserType::Object(LexObject {
1058                    required: Some(
1059                        vec![
1060                            SmolStr::new_static("timestamp"),
1061                            SmolStr::new_static("count")
1062                        ],
1063                    ),
1064                    properties: {
1065                        #[allow(unused_mut)]
1066                        let mut map = BTreeMap::new();
1067                        map.insert(
1068                            SmolStr::new_static("count"),
1069                            LexObjectProperty::Integer(LexInteger {
1070                                minimum: Some(0i64),
1071                                ..Default::default()
1072                            }),
1073                        );
1074                        map.insert(
1075                            SmolStr::new_static("timestamp"),
1076                            LexObjectProperty::String(LexString {
1077                                format: Some(LexStringFormat::Datetime),
1078                                ..Default::default()
1079                            }),
1080                        );
1081                        map
1082                    },
1083                    ..Default::default()
1084                }),
1085            );
1086            map
1087        },
1088        ..Default::default()
1089    }
1090}
1091
1092pub mod sparkline_point_state {
1093
1094    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1095    #[allow(unused)]
1096    use ::core::marker::PhantomData;
1097    mod sealed {
1098        pub trait Sealed {}
1099    }
1100    /// State trait tracking which required fields have been set
1101    pub trait State: sealed::Sealed {
1102        type Count;
1103        type Timestamp;
1104    }
1105    /// Empty state - all required fields are unset
1106    pub struct Empty(());
1107    impl sealed::Sealed for Empty {}
1108    impl State for Empty {
1109        type Count = Unset;
1110        type Timestamp = Unset;
1111    }
1112    ///State transition - sets the `count` field to Set
1113    pub struct SetCount<St: State = Empty>(PhantomData<fn() -> St>);
1114    impl<St: State> sealed::Sealed for SetCount<St> {}
1115    impl<St: State> State for SetCount<St> {
1116        type Count = Set<members::count>;
1117        type Timestamp = St::Timestamp;
1118    }
1119    ///State transition - sets the `timestamp` field to Set
1120    pub struct SetTimestamp<St: State = Empty>(PhantomData<fn() -> St>);
1121    impl<St: State> sealed::Sealed for SetTimestamp<St> {}
1122    impl<St: State> State for SetTimestamp<St> {
1123        type Count = St::Count;
1124        type Timestamp = Set<members::timestamp>;
1125    }
1126    /// Marker types for field names
1127    #[allow(non_camel_case_types)]
1128    pub mod members {
1129        ///Marker type for the `count` field
1130        pub struct count(());
1131        ///Marker type for the `timestamp` field
1132        pub struct timestamp(());
1133    }
1134}
1135
1136/// Builder for constructing an instance of this type.
1137pub struct SparklinePointBuilder<
1138    St: sparkline_point_state::State,
1139    S: BosStr = DefaultStr,
1140> {
1141    _state: PhantomData<fn() -> St>,
1142    _fields: (Option<i64>, Option<Datetime>),
1143    _type: PhantomData<fn() -> S>,
1144}
1145
1146impl SparklinePoint<DefaultStr> {
1147    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
1148    pub fn new() -> SparklinePointBuilder<sparkline_point_state::Empty, DefaultStr> {
1149        SparklinePointBuilder::new()
1150    }
1151}
1152
1153impl<S: BosStr> SparklinePoint<S> {
1154    /// Create a new builder for this type
1155    pub fn builder() -> SparklinePointBuilder<sparkline_point_state::Empty, S> {
1156        SparklinePointBuilder::builder()
1157    }
1158}
1159
1160impl SparklinePointBuilder<sparkline_point_state::Empty, DefaultStr> {
1161    /// Create a new builder with all fields unset, using the default string type, if needed
1162    pub fn new() -> Self {
1163        SparklinePointBuilder {
1164            _state: PhantomData,
1165            _fields: (None, None),
1166            _type: PhantomData,
1167        }
1168    }
1169}
1170
1171impl<S: BosStr> SparklinePointBuilder<sparkline_point_state::Empty, S> {
1172    /// Create a new builder with all fields unset
1173    pub fn builder() -> Self {
1174        SparklinePointBuilder {
1175            _state: PhantomData,
1176            _fields: (None, None),
1177            _type: PhantomData,
1178        }
1179    }
1180}
1181
1182impl<St, S: BosStr> SparklinePointBuilder<St, S>
1183where
1184    St: sparkline_point_state::State,
1185    St::Count: sparkline_point_state::IsUnset,
1186{
1187    /// Set the `count` field (required)
1188    pub fn count(
1189        mut self,
1190        value: impl Into<i64>,
1191    ) -> SparklinePointBuilder<sparkline_point_state::SetCount<St>, S> {
1192        self._fields.0 = Option::Some(value.into());
1193        SparklinePointBuilder {
1194            _state: PhantomData,
1195            _fields: self._fields,
1196            _type: PhantomData,
1197        }
1198    }
1199}
1200
1201impl<St, S: BosStr> SparklinePointBuilder<St, S>
1202where
1203    St: sparkline_point_state::State,
1204    St::Timestamp: sparkline_point_state::IsUnset,
1205{
1206    /// Set the `timestamp` field (required)
1207    pub fn timestamp(
1208        mut self,
1209        value: impl Into<Datetime>,
1210    ) -> SparklinePointBuilder<sparkline_point_state::SetTimestamp<St>, S> {
1211        self._fields.1 = Option::Some(value.into());
1212        SparklinePointBuilder {
1213            _state: PhantomData,
1214            _fields: self._fields,
1215            _type: PhantomData,
1216        }
1217    }
1218}
1219
1220impl<St, S: BosStr> SparklinePointBuilder<St, S>
1221where
1222    St: sparkline_point_state::State,
1223    St::Count: sparkline_point_state::IsSet,
1224    St::Timestamp: sparkline_point_state::IsSet,
1225{
1226    /// Build the final struct.
1227    pub fn build(self) -> SparklinePoint<S> {
1228        SparklinePoint {
1229            count: self._fields.0.unwrap(),
1230            timestamp: self._fields.1.unwrap(),
1231            extra_data: Default::default(),
1232        }
1233    }
1234    /// Build the final struct with custom extra_data.
1235    pub fn build_with_data(
1236        self,
1237        extra_data: BTreeMap<SmolStr, Data<S>>,
1238    ) -> SparklinePoint<S> {
1239        SparklinePoint {
1240            count: self._fields.0.unwrap(),
1241            timestamp: self._fields.1.unwrap(),
1242            extra_data: Some(extra_data),
1243        }
1244    }
1245}