jacquard_api/network_slices/waitlist/
request.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.waitlist.request
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// A request to join the waitlist
9#[jacquard_derive::lexicon]
10#[derive(
11    serde::Serialize,
12    serde::Deserialize,
13    Debug,
14    Clone,
15    PartialEq,
16    Eq,
17    jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Request<'a> {
21    /// When the user joined the waitlist
22    pub created_at: jacquard_common::types::string::Datetime,
23    /// The AT URI of the slice being requested access to
24    #[serde(borrow)]
25    pub slice: jacquard_common::types::string::AtUri<'a>,
26}
27
28pub mod request_state {
29
30    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
31    #[allow(unused)]
32    use ::core::marker::PhantomData;
33    mod sealed {
34        pub trait Sealed {}
35    }
36    /// State trait tracking which required fields have been set
37    pub trait State: sealed::Sealed {
38        type Slice;
39        type CreatedAt;
40    }
41    /// Empty state - all required fields are unset
42    pub struct Empty(());
43    impl sealed::Sealed for Empty {}
44    impl State for Empty {
45        type Slice = Unset;
46        type CreatedAt = Unset;
47    }
48    ///State transition - sets the `slice` field to Set
49    pub struct SetSlice<S: State = Empty>(PhantomData<fn() -> S>);
50    impl<S: State> sealed::Sealed for SetSlice<S> {}
51    impl<S: State> State for SetSlice<S> {
52        type Slice = Set<members::slice>;
53        type CreatedAt = S::CreatedAt;
54    }
55    ///State transition - sets the `created_at` field to Set
56    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
57    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
58    impl<S: State> State for SetCreatedAt<S> {
59        type Slice = S::Slice;
60        type CreatedAt = Set<members::created_at>;
61    }
62    /// Marker types for field names
63    #[allow(non_camel_case_types)]
64    pub mod members {
65        ///Marker type for the `slice` field
66        pub struct slice(());
67        ///Marker type for the `created_at` field
68        pub struct created_at(());
69    }
70}
71
72/// Builder for constructing an instance of this type
73pub struct RequestBuilder<'a, S: request_state::State> {
74    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
75    __unsafe_private_named: (
76        ::core::option::Option<jacquard_common::types::string::Datetime>,
77        ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
78    ),
79    _phantom: ::core::marker::PhantomData<&'a ()>,
80}
81
82impl<'a> Request<'a> {
83    /// Create a new builder for this type
84    pub fn new() -> RequestBuilder<'a, request_state::Empty> {
85        RequestBuilder::new()
86    }
87}
88
89impl<'a> RequestBuilder<'a, request_state::Empty> {
90    /// Create a new builder with all fields unset
91    pub fn new() -> Self {
92        RequestBuilder {
93            _phantom_state: ::core::marker::PhantomData,
94            __unsafe_private_named: (None, None),
95            _phantom: ::core::marker::PhantomData,
96        }
97    }
98}
99
100impl<'a, S> RequestBuilder<'a, S>
101where
102    S: request_state::State,
103    S::CreatedAt: request_state::IsUnset,
104{
105    /// Set the `createdAt` field (required)
106    pub fn created_at(
107        mut self,
108        value: impl Into<jacquard_common::types::string::Datetime>,
109    ) -> RequestBuilder<'a, request_state::SetCreatedAt<S>> {
110        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
111        RequestBuilder {
112            _phantom_state: ::core::marker::PhantomData,
113            __unsafe_private_named: self.__unsafe_private_named,
114            _phantom: ::core::marker::PhantomData,
115        }
116    }
117}
118
119impl<'a, S> RequestBuilder<'a, S>
120where
121    S: request_state::State,
122    S::Slice: request_state::IsUnset,
123{
124    /// Set the `slice` field (required)
125    pub fn slice(
126        mut self,
127        value: impl Into<jacquard_common::types::string::AtUri<'a>>,
128    ) -> RequestBuilder<'a, request_state::SetSlice<S>> {
129        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
130        RequestBuilder {
131            _phantom_state: ::core::marker::PhantomData,
132            __unsafe_private_named: self.__unsafe_private_named,
133            _phantom: ::core::marker::PhantomData,
134        }
135    }
136}
137
138impl<'a, S> RequestBuilder<'a, S>
139where
140    S: request_state::State,
141    S::Slice: request_state::IsSet,
142    S::CreatedAt: request_state::IsSet,
143{
144    /// Build the final struct
145    pub fn build(self) -> Request<'a> {
146        Request {
147            created_at: self.__unsafe_private_named.0.unwrap(),
148            slice: self.__unsafe_private_named.1.unwrap(),
149            extra_data: Default::default(),
150        }
151    }
152    /// Build the final struct with custom extra_data
153    pub fn build_with_data(
154        self,
155        extra_data: std::collections::BTreeMap<
156            jacquard_common::smol_str::SmolStr,
157            jacquard_common::types::value::Data<'a>,
158        >,
159    ) -> Request<'a> {
160        Request {
161            created_at: self.__unsafe_private_named.0.unwrap(),
162            slice: self.__unsafe_private_named.1.unwrap(),
163            extra_data: Some(extra_data),
164        }
165    }
166}
167
168impl<'a> Request<'a> {
169    pub fn uri(
170        uri: impl Into<jacquard_common::CowStr<'a>>,
171    ) -> Result<
172        jacquard_common::types::uri::RecordUri<'a, RequestRecord>,
173        jacquard_common::types::uri::UriError,
174    > {
175        jacquard_common::types::uri::RecordUri::try_from_uri(
176            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
177        )
178    }
179}
180
181/// Typed wrapper for GetRecord response with this collection's record type.
182#[derive(
183    serde::Serialize,
184    serde::Deserialize,
185    Debug,
186    Clone,
187    PartialEq,
188    Eq,
189    jacquard_derive::IntoStatic
190)]
191#[serde(rename_all = "camelCase")]
192pub struct RequestGetRecordOutput<'a> {
193    #[serde(skip_serializing_if = "std::option::Option::is_none")]
194    #[serde(borrow)]
195    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
196    #[serde(borrow)]
197    pub uri: jacquard_common::types::string::AtUri<'a>,
198    #[serde(borrow)]
199    pub value: Request<'a>,
200}
201
202impl From<RequestGetRecordOutput<'_>> for Request<'_> {
203    fn from(output: RequestGetRecordOutput<'_>) -> Self {
204        use jacquard_common::IntoStatic;
205        output.value.into_static()
206    }
207}
208
209impl jacquard_common::types::collection::Collection for Request<'_> {
210    const NSID: &'static str = "network.slices.waitlist.request";
211    type Record = RequestRecord;
212}
213
214/// Marker type for deserializing records from this collection.
215#[derive(Debug, serde::Serialize, serde::Deserialize)]
216pub struct RequestRecord;
217impl jacquard_common::xrpc::XrpcResp for RequestRecord {
218    const NSID: &'static str = "network.slices.waitlist.request";
219    const ENCODING: &'static str = "application/json";
220    type Output<'de> = RequestGetRecordOutput<'de>;
221    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
222}
223
224impl jacquard_common::types::collection::Collection for RequestRecord {
225    const NSID: &'static str = "network.slices.waitlist.request";
226    type Record = RequestRecord;
227}
228
229impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Request<'a> {
230    fn nsid() -> &'static str {
231        "network.slices.waitlist.request"
232    }
233    fn def_name() -> &'static str {
234        "main"
235    }
236    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
237        lexicon_doc_network_slices_waitlist_request()
238    }
239    fn validate(
240        &self,
241    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
242        Ok(())
243    }
244}
245
246fn lexicon_doc_network_slices_waitlist_request() -> ::jacquard_lexicon::lexicon::LexiconDoc<
247    'static,
248> {
249    ::jacquard_lexicon::lexicon::LexiconDoc {
250        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
251        id: ::jacquard_common::CowStr::new_static("network.slices.waitlist.request"),
252        revision: None,
253        description: None,
254        defs: {
255            let mut map = ::std::collections::BTreeMap::new();
256            map.insert(
257                ::jacquard_common::smol_str::SmolStr::new_static("main"),
258                ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
259                    description: Some(
260                        ::jacquard_common::CowStr::new_static(
261                            "A request to join the waitlist",
262                        ),
263                    ),
264                    key: Some(::jacquard_common::CowStr::new_static("literal:self")),
265                    record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
266                        description: None,
267                        required: Some(
268                            vec![
269                                ::jacquard_common::smol_str::SmolStr::new_static("slice"),
270                                ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
271                            ],
272                        ),
273                        nullable: None,
274                        properties: {
275                            #[allow(unused_mut)]
276                            let mut map = ::std::collections::BTreeMap::new();
277                            map.insert(
278                                ::jacquard_common::smol_str::SmolStr::new_static(
279                                    "createdAt",
280                                ),
281                                ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
282                                    description: Some(
283                                        ::jacquard_common::CowStr::new_static(
284                                            "When the user joined the waitlist",
285                                        ),
286                                    ),
287                                    format: Some(
288                                        ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
289                                    ),
290                                    default: None,
291                                    min_length: None,
292                                    max_length: None,
293                                    min_graphemes: None,
294                                    max_graphemes: None,
295                                    r#enum: None,
296                                    r#const: None,
297                                    known_values: None,
298                                }),
299                            );
300                            map.insert(
301                                ::jacquard_common::smol_str::SmolStr::new_static("slice"),
302                                ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
303                                    description: Some(
304                                        ::jacquard_common::CowStr::new_static(
305                                            "The AT URI of the slice being requested access to",
306                                        ),
307                                    ),
308                                    format: Some(
309                                        ::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
310                                    ),
311                                    default: None,
312                                    min_length: None,
313                                    max_length: None,
314                                    min_graphemes: None,
315                                    max_graphemes: None,
316                                    r#enum: None,
317                                    r#const: None,
318                                    known_values: None,
319                                }),
320                            );
321                            map
322                        },
323                    }),
324                }),
325            );
326            map
327        },
328    }
329}