jacquard_api/network_slices/slice/
stats.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.slice.stats
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct CollectionStats<'a> {
20    /// Collection NSID
21    #[serde(borrow)]
22    pub collection: jacquard_common::types::string::Nsid<'a>,
23    /// Number of records in this collection
24    pub record_count: i64,
25    /// Number of unique actors with records in this collection
26    pub unique_actors: i64,
27}
28
29pub mod collection_stats_state {
30
31    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
32    #[allow(unused)]
33    use ::core::marker::PhantomData;
34    mod sealed {
35        pub trait Sealed {}
36    }
37    /// State trait tracking which required fields have been set
38    pub trait State: sealed::Sealed {
39        type Collection;
40        type RecordCount;
41        type UniqueActors;
42    }
43    /// Empty state - all required fields are unset
44    pub struct Empty(());
45    impl sealed::Sealed for Empty {}
46    impl State for Empty {
47        type Collection = Unset;
48        type RecordCount = Unset;
49        type UniqueActors = Unset;
50    }
51    ///State transition - sets the `collection` field to Set
52    pub struct SetCollection<S: State = Empty>(PhantomData<fn() -> S>);
53    impl<S: State> sealed::Sealed for SetCollection<S> {}
54    impl<S: State> State for SetCollection<S> {
55        type Collection = Set<members::collection>;
56        type RecordCount = S::RecordCount;
57        type UniqueActors = S::UniqueActors;
58    }
59    ///State transition - sets the `record_count` field to Set
60    pub struct SetRecordCount<S: State = Empty>(PhantomData<fn() -> S>);
61    impl<S: State> sealed::Sealed for SetRecordCount<S> {}
62    impl<S: State> State for SetRecordCount<S> {
63        type Collection = S::Collection;
64        type RecordCount = Set<members::record_count>;
65        type UniqueActors = S::UniqueActors;
66    }
67    ///State transition - sets the `unique_actors` field to Set
68    pub struct SetUniqueActors<S: State = Empty>(PhantomData<fn() -> S>);
69    impl<S: State> sealed::Sealed for SetUniqueActors<S> {}
70    impl<S: State> State for SetUniqueActors<S> {
71        type Collection = S::Collection;
72        type RecordCount = S::RecordCount;
73        type UniqueActors = Set<members::unique_actors>;
74    }
75    /// Marker types for field names
76    #[allow(non_camel_case_types)]
77    pub mod members {
78        ///Marker type for the `collection` field
79        pub struct collection(());
80        ///Marker type for the `record_count` field
81        pub struct record_count(());
82        ///Marker type for the `unique_actors` field
83        pub struct unique_actors(());
84    }
85}
86
87/// Builder for constructing an instance of this type
88pub struct CollectionStatsBuilder<'a, S: collection_stats_state::State> {
89    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
90    __unsafe_private_named: (
91        ::core::option::Option<jacquard_common::types::string::Nsid<'a>>,
92        ::core::option::Option<i64>,
93        ::core::option::Option<i64>,
94    ),
95    _phantom: ::core::marker::PhantomData<&'a ()>,
96}
97
98impl<'a> CollectionStats<'a> {
99    /// Create a new builder for this type
100    pub fn new() -> CollectionStatsBuilder<'a, collection_stats_state::Empty> {
101        CollectionStatsBuilder::new()
102    }
103}
104
105impl<'a> CollectionStatsBuilder<'a, collection_stats_state::Empty> {
106    /// Create a new builder with all fields unset
107    pub fn new() -> Self {
108        CollectionStatsBuilder {
109            _phantom_state: ::core::marker::PhantomData,
110            __unsafe_private_named: (None, None, None),
111            _phantom: ::core::marker::PhantomData,
112        }
113    }
114}
115
116impl<'a, S> CollectionStatsBuilder<'a, S>
117where
118    S: collection_stats_state::State,
119    S::Collection: collection_stats_state::IsUnset,
120{
121    /// Set the `collection` field (required)
122    pub fn collection(
123        mut self,
124        value: impl Into<jacquard_common::types::string::Nsid<'a>>,
125    ) -> CollectionStatsBuilder<'a, collection_stats_state::SetCollection<S>> {
126        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
127        CollectionStatsBuilder {
128            _phantom_state: ::core::marker::PhantomData,
129            __unsafe_private_named: self.__unsafe_private_named,
130            _phantom: ::core::marker::PhantomData,
131        }
132    }
133}
134
135impl<'a, S> CollectionStatsBuilder<'a, S>
136where
137    S: collection_stats_state::State,
138    S::RecordCount: collection_stats_state::IsUnset,
139{
140    /// Set the `recordCount` field (required)
141    pub fn record_count(
142        mut self,
143        value: impl Into<i64>,
144    ) -> CollectionStatsBuilder<'a, collection_stats_state::SetRecordCount<S>> {
145        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
146        CollectionStatsBuilder {
147            _phantom_state: ::core::marker::PhantomData,
148            __unsafe_private_named: self.__unsafe_private_named,
149            _phantom: ::core::marker::PhantomData,
150        }
151    }
152}
153
154impl<'a, S> CollectionStatsBuilder<'a, S>
155where
156    S: collection_stats_state::State,
157    S::UniqueActors: collection_stats_state::IsUnset,
158{
159    /// Set the `uniqueActors` field (required)
160    pub fn unique_actors(
161        mut self,
162        value: impl Into<i64>,
163    ) -> CollectionStatsBuilder<'a, collection_stats_state::SetUniqueActors<S>> {
164        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
165        CollectionStatsBuilder {
166            _phantom_state: ::core::marker::PhantomData,
167            __unsafe_private_named: self.__unsafe_private_named,
168            _phantom: ::core::marker::PhantomData,
169        }
170    }
171}
172
173impl<'a, S> CollectionStatsBuilder<'a, S>
174where
175    S: collection_stats_state::State,
176    S::Collection: collection_stats_state::IsSet,
177    S::RecordCount: collection_stats_state::IsSet,
178    S::UniqueActors: collection_stats_state::IsSet,
179{
180    /// Build the final struct
181    pub fn build(self) -> CollectionStats<'a> {
182        CollectionStats {
183            collection: self.__unsafe_private_named.0.unwrap(),
184            record_count: self.__unsafe_private_named.1.unwrap(),
185            unique_actors: self.__unsafe_private_named.2.unwrap(),
186            extra_data: Default::default(),
187        }
188    }
189    /// Build the final struct with custom extra_data
190    pub fn build_with_data(
191        self,
192        extra_data: std::collections::BTreeMap<
193            jacquard_common::smol_str::SmolStr,
194            jacquard_common::types::value::Data<'a>,
195        >,
196    ) -> CollectionStats<'a> {
197        CollectionStats {
198            collection: self.__unsafe_private_named.0.unwrap(),
199            record_count: self.__unsafe_private_named.1.unwrap(),
200            unique_actors: self.__unsafe_private_named.2.unwrap(),
201            extra_data: Some(extra_data),
202        }
203    }
204}
205
206fn lexicon_doc_network_slices_slice_stats() -> ::jacquard_lexicon::lexicon::LexiconDoc<
207    'static,
208> {
209    ::jacquard_lexicon::lexicon::LexiconDoc {
210        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
211        id: ::jacquard_common::CowStr::new_static("network.slices.slice.stats"),
212        revision: None,
213        description: None,
214        defs: {
215            let mut map = ::std::collections::BTreeMap::new();
216            map.insert(
217                ::jacquard_common::smol_str::SmolStr::new_static("collectionStats"),
218                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
219                    description: None,
220                    required: Some(
221                        vec![
222                            ::jacquard_common::smol_str::SmolStr::new_static("collection"),
223                            ::jacquard_common::smol_str::SmolStr::new_static("recordCount"),
224                            ::jacquard_common::smol_str::SmolStr::new_static("uniqueActors")
225                        ],
226                    ),
227                    nullable: None,
228                    properties: {
229                        #[allow(unused_mut)]
230                        let mut map = ::std::collections::BTreeMap::new();
231                        map.insert(
232                            ::jacquard_common::smol_str::SmolStr::new_static(
233                                "collection",
234                            ),
235                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
236                                description: Some(
237                                    ::jacquard_common::CowStr::new_static("Collection NSID"),
238                                ),
239                                format: Some(
240                                    ::jacquard_lexicon::lexicon::LexStringFormat::Nsid,
241                                ),
242                                default: None,
243                                min_length: None,
244                                max_length: None,
245                                min_graphemes: None,
246                                max_graphemes: None,
247                                r#enum: None,
248                                r#const: None,
249                                known_values: None,
250                            }),
251                        );
252                        map.insert(
253                            ::jacquard_common::smol_str::SmolStr::new_static(
254                                "recordCount",
255                            ),
256                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
257                                description: None,
258                                default: None,
259                                minimum: None,
260                                maximum: None,
261                                r#enum: None,
262                                r#const: None,
263                            }),
264                        );
265                        map.insert(
266                            ::jacquard_common::smol_str::SmolStr::new_static(
267                                "uniqueActors",
268                            ),
269                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
270                                description: None,
271                                default: None,
272                                minimum: None,
273                                maximum: None,
274                                r#enum: None,
275                                r#const: None,
276                            }),
277                        );
278                        map
279                    },
280                }),
281            );
282            map.insert(
283                ::jacquard_common::smol_str::SmolStr::new_static("main"),
284                ::jacquard_lexicon::lexicon::LexUserType::XrpcQuery(::jacquard_lexicon::lexicon::LexXrpcQuery {
285                    description: None,
286                    parameters: Some(
287                        ::jacquard_lexicon::lexicon::LexXrpcQueryParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters {
288                            description: None,
289                            required: Some(
290                                vec![
291                                    ::jacquard_common::smol_str::SmolStr::new_static("slice")
292                                ],
293                            ),
294                            properties: {
295                                #[allow(unused_mut)]
296                                let mut map = ::std::collections::BTreeMap::new();
297                                map.insert(
298                                    ::jacquard_common::smol_str::SmolStr::new_static("slice"),
299                                    ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString {
300                                        description: Some(
301                                            ::jacquard_common::CowStr::new_static(
302                                                "AT-URI of the slice to get statistics for",
303                                            ),
304                                        ),
305                                        format: None,
306                                        default: None,
307                                        min_length: None,
308                                        max_length: None,
309                                        min_graphemes: None,
310                                        max_graphemes: None,
311                                        r#enum: None,
312                                        r#const: None,
313                                        known_values: None,
314                                    }),
315                                );
316                                map
317                            },
318                        }),
319                    ),
320                    output: None,
321                    errors: None,
322                }),
323            );
324            map
325        },
326    }
327}
328
329impl<'a> ::jacquard_lexicon::schema::LexiconSchema for CollectionStats<'a> {
330    fn nsid() -> &'static str {
331        "network.slices.slice.stats"
332    }
333    fn def_name() -> &'static str {
334        "collectionStats"
335    }
336    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
337        lexicon_doc_network_slices_slice_stats()
338    }
339    fn validate(
340        &self,
341    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
342        Ok(())
343    }
344}
345
346#[derive(
347    serde::Serialize,
348    serde::Deserialize,
349    Debug,
350    Clone,
351    PartialEq,
352    Eq,
353    jacquard_derive::IntoStatic
354)]
355#[serde(rename_all = "camelCase")]
356pub struct Stats<'a> {
357    #[serde(borrow)]
358    pub slice: jacquard_common::CowStr<'a>,
359}
360
361pub mod stats_state {
362
363    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
364    #[allow(unused)]
365    use ::core::marker::PhantomData;
366    mod sealed {
367        pub trait Sealed {}
368    }
369    /// State trait tracking which required fields have been set
370    pub trait State: sealed::Sealed {
371        type Slice;
372    }
373    /// Empty state - all required fields are unset
374    pub struct Empty(());
375    impl sealed::Sealed for Empty {}
376    impl State for Empty {
377        type Slice = Unset;
378    }
379    ///State transition - sets the `slice` field to Set
380    pub struct SetSlice<S: State = Empty>(PhantomData<fn() -> S>);
381    impl<S: State> sealed::Sealed for SetSlice<S> {}
382    impl<S: State> State for SetSlice<S> {
383        type Slice = Set<members::slice>;
384    }
385    /// Marker types for field names
386    #[allow(non_camel_case_types)]
387    pub mod members {
388        ///Marker type for the `slice` field
389        pub struct slice(());
390    }
391}
392
393/// Builder for constructing an instance of this type
394pub struct StatsBuilder<'a, S: stats_state::State> {
395    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
396    __unsafe_private_named: (::core::option::Option<jacquard_common::CowStr<'a>>,),
397    _phantom: ::core::marker::PhantomData<&'a ()>,
398}
399
400impl<'a> Stats<'a> {
401    /// Create a new builder for this type
402    pub fn new() -> StatsBuilder<'a, stats_state::Empty> {
403        StatsBuilder::new()
404    }
405}
406
407impl<'a> StatsBuilder<'a, stats_state::Empty> {
408    /// Create a new builder with all fields unset
409    pub fn new() -> Self {
410        StatsBuilder {
411            _phantom_state: ::core::marker::PhantomData,
412            __unsafe_private_named: (None,),
413            _phantom: ::core::marker::PhantomData,
414        }
415    }
416}
417
418impl<'a, S> StatsBuilder<'a, S>
419where
420    S: stats_state::State,
421    S::Slice: stats_state::IsUnset,
422{
423    /// Set the `slice` field (required)
424    pub fn slice(
425        mut self,
426        value: impl Into<jacquard_common::CowStr<'a>>,
427    ) -> StatsBuilder<'a, stats_state::SetSlice<S>> {
428        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
429        StatsBuilder {
430            _phantom_state: ::core::marker::PhantomData,
431            __unsafe_private_named: self.__unsafe_private_named,
432            _phantom: ::core::marker::PhantomData,
433        }
434    }
435}
436
437impl<'a, S> StatsBuilder<'a, S>
438where
439    S: stats_state::State,
440    S::Slice: stats_state::IsSet,
441{
442    /// Build the final struct
443    pub fn build(self) -> Stats<'a> {
444        Stats {
445            slice: self.__unsafe_private_named.0.unwrap(),
446        }
447    }
448}
449
450#[jacquard_derive::lexicon]
451#[derive(
452    serde::Serialize,
453    serde::Deserialize,
454    Debug,
455    Clone,
456    PartialEq,
457    Eq,
458    jacquard_derive::IntoStatic
459)]
460#[serde(rename_all = "camelCase")]
461pub struct StatsOutput<'a> {
462    /// Per-collection statistics
463    #[serde(borrow)]
464    pub collection_stats: Vec<crate::network_slices::slice::stats::CollectionStats<'a>>,
465    /// List of collection NSIDs indexed in this slice
466    #[serde(borrow)]
467    pub collections: Vec<jacquard_common::types::string::Nsid<'a>>,
468    /// Total number of unique actors indexed in this slice
469    pub total_actors: i64,
470    /// Total number of lexicons defined for this slice
471    pub total_lexicons: i64,
472    /// Total number of records indexed in this slice
473    pub total_records: i64,
474}
475
476/// Response type for
477///network.slices.slice.stats
478pub struct StatsResponse;
479impl jacquard_common::xrpc::XrpcResp for StatsResponse {
480    const NSID: &'static str = "network.slices.slice.stats";
481    const ENCODING: &'static str = "application/json";
482    type Output<'de> = StatsOutput<'de>;
483    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
484}
485
486impl<'a> jacquard_common::xrpc::XrpcRequest for Stats<'a> {
487    const NSID: &'static str = "network.slices.slice.stats";
488    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
489    type Response = StatsResponse;
490}
491
492/// Endpoint type for
493///network.slices.slice.stats
494pub struct StatsRequest;
495impl jacquard_common::xrpc::XrpcEndpoint for StatsRequest {
496    const PATH: &'static str = "/xrpc/network.slices.slice.stats";
497    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
498    type Request<'de> = Stats<'de>;
499    type Response = StatsResponse;
500}