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