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