Skip to main content

jacquard_api/sh_weaver/edit/
list_drafts.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.edit.listDrafts
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::ident::AtIdentifier;
18use jacquard_common::types::string::{AtUri, Cid, Datetime};
19use jacquard_derive::{IntoStatic, lexicon};
20use jacquard_lexicon::lexicon::LexiconDoc;
21use jacquard_lexicon::schema::LexiconSchema;
22
23#[allow(unused_imports)]
24use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
25use serde::{Serialize, Deserialize};
26use crate::com_atproto::repo::strong_ref::StrongRef;
27use crate::sh_weaver::edit::list_drafts;
28/// Hydrated view of a draft with edit state.
29
30#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
32#[serde(rename_all = "camelCase")]
33pub struct DraftView<'a> {
34    #[serde(borrow)]
35    pub cid: Cid<'a>,
36    pub created_at: Datetime,
37    ///Associated edit root if one exists
38    #[serde(skip_serializing_if = "Option::is_none")]
39    #[serde(borrow)]
40    pub edit_root: Option<StrongRef<'a>>,
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub last_edit_at: Option<Datetime>,
43    ///Extracted title if available from edit state
44    #[serde(skip_serializing_if = "Option::is_none")]
45    #[serde(borrow)]
46    pub title: Option<CowStr<'a>>,
47    #[serde(borrow)]
48    pub uri: AtUri<'a>,
49}
50
51
52#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
53#[serde(rename_all = "camelCase")]
54pub struct ListDrafts<'a> {
55    #[serde(borrow)]
56    pub actor: AtIdentifier<'a>,
57    #[serde(skip_serializing_if = "Option::is_none")]
58    #[serde(borrow)]
59    pub cursor: Option<CowStr<'a>>,
60    ///Defaults to `50`. Min: 1. Max: 100.
61    #[serde(default = "_default_limit")]
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub limit: Option<i64>,
64}
65
66
67#[lexicon]
68#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
69#[serde(rename_all = "camelCase")]
70pub struct ListDraftsOutput<'a> {
71    #[serde(skip_serializing_if = "Option::is_none")]
72    #[serde(borrow)]
73    pub cursor: Option<CowStr<'a>>,
74    #[serde(borrow)]
75    pub drafts: Vec<list_drafts::DraftView<'a>>,
76}
77
78impl<'a> LexiconSchema for DraftView<'a> {
79    fn nsid() -> &'static str {
80        "sh.weaver.edit.listDrafts"
81    }
82    fn def_name() -> &'static str {
83        "draftView"
84    }
85    fn lexicon_doc() -> LexiconDoc<'static> {
86        lexicon_doc_sh_weaver_edit_listDrafts()
87    }
88    fn validate(&self) -> Result<(), ConstraintError> {
89        Ok(())
90    }
91}
92
93/// Response type for sh.weaver.edit.listDrafts
94pub struct ListDraftsResponse;
95impl jacquard_common::xrpc::XrpcResp for ListDraftsResponse {
96    const NSID: &'static str = "sh.weaver.edit.listDrafts";
97    const ENCODING: &'static str = "application/json";
98    type Output<'de> = ListDraftsOutput<'de>;
99    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
100}
101
102impl<'a> jacquard_common::xrpc::XrpcRequest for ListDrafts<'a> {
103    const NSID: &'static str = "sh.weaver.edit.listDrafts";
104    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
105    type Response = ListDraftsResponse;
106}
107
108/// Endpoint type for sh.weaver.edit.listDrafts
109pub struct ListDraftsRequest;
110impl jacquard_common::xrpc::XrpcEndpoint for ListDraftsRequest {
111    const PATH: &'static str = "/xrpc/sh.weaver.edit.listDrafts";
112    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
113    type Request<'de> = ListDrafts<'de>;
114    type Response = ListDraftsResponse;
115}
116
117pub mod draft_view_state {
118
119    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
120    #[allow(unused)]
121    use ::core::marker::PhantomData;
122    mod sealed {
123        pub trait Sealed {}
124    }
125    /// State trait tracking which required fields have been set
126    pub trait State: sealed::Sealed {
127        type Uri;
128        type Cid;
129        type CreatedAt;
130    }
131    /// Empty state - all required fields are unset
132    pub struct Empty(());
133    impl sealed::Sealed for Empty {}
134    impl State for Empty {
135        type Uri = Unset;
136        type Cid = Unset;
137        type CreatedAt = Unset;
138    }
139    ///State transition - sets the `uri` field to Set
140    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
141    impl<S: State> sealed::Sealed for SetUri<S> {}
142    impl<S: State> State for SetUri<S> {
143        type Uri = Set<members::uri>;
144        type Cid = S::Cid;
145        type CreatedAt = S::CreatedAt;
146    }
147    ///State transition - sets the `cid` field to Set
148    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
149    impl<S: State> sealed::Sealed for SetCid<S> {}
150    impl<S: State> State for SetCid<S> {
151        type Uri = S::Uri;
152        type Cid = Set<members::cid>;
153        type CreatedAt = S::CreatedAt;
154    }
155    ///State transition - sets the `created_at` field to Set
156    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
157    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
158    impl<S: State> State for SetCreatedAt<S> {
159        type Uri = S::Uri;
160        type Cid = S::Cid;
161        type CreatedAt = Set<members::created_at>;
162    }
163    /// Marker types for field names
164    #[allow(non_camel_case_types)]
165    pub mod members {
166        ///Marker type for the `uri` field
167        pub struct uri(());
168        ///Marker type for the `cid` field
169        pub struct cid(());
170        ///Marker type for the `created_at` field
171        pub struct created_at(());
172    }
173}
174
175/// Builder for constructing an instance of this type
176pub struct DraftViewBuilder<'a, S: draft_view_state::State> {
177    _state: PhantomData<fn() -> S>,
178    _fields: (
179        Option<Cid<'a>>,
180        Option<Datetime>,
181        Option<StrongRef<'a>>,
182        Option<Datetime>,
183        Option<CowStr<'a>>,
184        Option<AtUri<'a>>,
185    ),
186    _lifetime: PhantomData<&'a ()>,
187}
188
189impl<'a> DraftView<'a> {
190    /// Create a new builder for this type
191    pub fn new() -> DraftViewBuilder<'a, draft_view_state::Empty> {
192        DraftViewBuilder::new()
193    }
194}
195
196impl<'a> DraftViewBuilder<'a, draft_view_state::Empty> {
197    /// Create a new builder with all fields unset
198    pub fn new() -> Self {
199        DraftViewBuilder {
200            _state: PhantomData,
201            _fields: (None, None, None, None, None, None),
202            _lifetime: PhantomData,
203        }
204    }
205}
206
207impl<'a, S> DraftViewBuilder<'a, S>
208where
209    S: draft_view_state::State,
210    S::Cid: draft_view_state::IsUnset,
211{
212    /// Set the `cid` field (required)
213    pub fn cid(
214        mut self,
215        value: impl Into<Cid<'a>>,
216    ) -> DraftViewBuilder<'a, draft_view_state::SetCid<S>> {
217        self._fields.0 = Option::Some(value.into());
218        DraftViewBuilder {
219            _state: PhantomData,
220            _fields: self._fields,
221            _lifetime: PhantomData,
222        }
223    }
224}
225
226impl<'a, S> DraftViewBuilder<'a, S>
227where
228    S: draft_view_state::State,
229    S::CreatedAt: draft_view_state::IsUnset,
230{
231    /// Set the `createdAt` field (required)
232    pub fn created_at(
233        mut self,
234        value: impl Into<Datetime>,
235    ) -> DraftViewBuilder<'a, draft_view_state::SetCreatedAt<S>> {
236        self._fields.1 = Option::Some(value.into());
237        DraftViewBuilder {
238            _state: PhantomData,
239            _fields: self._fields,
240            _lifetime: PhantomData,
241        }
242    }
243}
244
245impl<'a, S: draft_view_state::State> DraftViewBuilder<'a, S> {
246    /// Set the `editRoot` field (optional)
247    pub fn edit_root(mut self, value: impl Into<Option<StrongRef<'a>>>) -> Self {
248        self._fields.2 = value.into();
249        self
250    }
251    /// Set the `editRoot` field to an Option value (optional)
252    pub fn maybe_edit_root(mut self, value: Option<StrongRef<'a>>) -> Self {
253        self._fields.2 = value;
254        self
255    }
256}
257
258impl<'a, S: draft_view_state::State> DraftViewBuilder<'a, S> {
259    /// Set the `lastEditAt` field (optional)
260    pub fn last_edit_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
261        self._fields.3 = value.into();
262        self
263    }
264    /// Set the `lastEditAt` field to an Option value (optional)
265    pub fn maybe_last_edit_at(mut self, value: Option<Datetime>) -> Self {
266        self._fields.3 = value;
267        self
268    }
269}
270
271impl<'a, S: draft_view_state::State> DraftViewBuilder<'a, S> {
272    /// Set the `title` field (optional)
273    pub fn title(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
274        self._fields.4 = value.into();
275        self
276    }
277    /// Set the `title` field to an Option value (optional)
278    pub fn maybe_title(mut self, value: Option<CowStr<'a>>) -> Self {
279        self._fields.4 = value;
280        self
281    }
282}
283
284impl<'a, S> DraftViewBuilder<'a, S>
285where
286    S: draft_view_state::State,
287    S::Uri: draft_view_state::IsUnset,
288{
289    /// Set the `uri` field (required)
290    pub fn uri(
291        mut self,
292        value: impl Into<AtUri<'a>>,
293    ) -> DraftViewBuilder<'a, draft_view_state::SetUri<S>> {
294        self._fields.5 = Option::Some(value.into());
295        DraftViewBuilder {
296            _state: PhantomData,
297            _fields: self._fields,
298            _lifetime: PhantomData,
299        }
300    }
301}
302
303impl<'a, S> DraftViewBuilder<'a, S>
304where
305    S: draft_view_state::State,
306    S::Uri: draft_view_state::IsSet,
307    S::Cid: draft_view_state::IsSet,
308    S::CreatedAt: draft_view_state::IsSet,
309{
310    /// Build the final struct
311    pub fn build(self) -> DraftView<'a> {
312        DraftView {
313            cid: self._fields.0.unwrap(),
314            created_at: self._fields.1.unwrap(),
315            edit_root: self._fields.2,
316            last_edit_at: self._fields.3,
317            title: self._fields.4,
318            uri: self._fields.5.unwrap(),
319            extra_data: Default::default(),
320        }
321    }
322    /// Build the final struct with custom extra_data
323    pub fn build_with_data(
324        self,
325        extra_data: BTreeMap<
326            jacquard_common::deps::smol_str::SmolStr,
327            jacquard_common::types::value::Data<'a>,
328        >,
329    ) -> DraftView<'a> {
330        DraftView {
331            cid: self._fields.0.unwrap(),
332            created_at: self._fields.1.unwrap(),
333            edit_root: self._fields.2,
334            last_edit_at: self._fields.3,
335            title: self._fields.4,
336            uri: self._fields.5.unwrap(),
337            extra_data: Some(extra_data),
338        }
339    }
340}
341
342fn lexicon_doc_sh_weaver_edit_listDrafts() -> LexiconDoc<'static> {
343    #[allow(unused_imports)]
344    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
345    use jacquard_lexicon::lexicon::*;
346    use alloc::collections::BTreeMap;
347    LexiconDoc {
348        lexicon: Lexicon::Lexicon1,
349        id: CowStr::new_static("sh.weaver.edit.listDrafts"),
350        defs: {
351            let mut map = BTreeMap::new();
352            map.insert(
353                SmolStr::new_static("draftView"),
354                LexUserType::Object(LexObject {
355                    description: Some(
356                        CowStr::new_static("Hydrated view of a draft with edit state."),
357                    ),
358                    required: Some(
359                        vec![
360                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
361                            SmolStr::new_static("createdAt")
362                        ],
363                    ),
364                    properties: {
365                        #[allow(unused_mut)]
366                        let mut map = BTreeMap::new();
367                        map.insert(
368                            SmolStr::new_static("cid"),
369                            LexObjectProperty::String(LexString {
370                                format: Some(LexStringFormat::Cid),
371                                ..Default::default()
372                            }),
373                        );
374                        map.insert(
375                            SmolStr::new_static("createdAt"),
376                            LexObjectProperty::String(LexString {
377                                format: Some(LexStringFormat::Datetime),
378                                ..Default::default()
379                            }),
380                        );
381                        map.insert(
382                            SmolStr::new_static("editRoot"),
383                            LexObjectProperty::Ref(LexRef {
384                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
385                                ..Default::default()
386                            }),
387                        );
388                        map.insert(
389                            SmolStr::new_static("lastEditAt"),
390                            LexObjectProperty::String(LexString {
391                                format: Some(LexStringFormat::Datetime),
392                                ..Default::default()
393                            }),
394                        );
395                        map.insert(
396                            SmolStr::new_static("title"),
397                            LexObjectProperty::String(LexString {
398                                description: Some(
399                                    CowStr::new_static(
400                                        "Extracted title if available from edit state",
401                                    ),
402                                ),
403                                ..Default::default()
404                            }),
405                        );
406                        map.insert(
407                            SmolStr::new_static("uri"),
408                            LexObjectProperty::String(LexString {
409                                format: Some(LexStringFormat::AtUri),
410                                ..Default::default()
411                            }),
412                        );
413                        map
414                    },
415                    ..Default::default()
416                }),
417            );
418            map.insert(
419                SmolStr::new_static("main"),
420                LexUserType::XrpcQuery(LexXrpcQuery {
421                    parameters: Some(
422                        LexXrpcQueryParameter::Params(LexXrpcParameters {
423                            required: Some(vec![SmolStr::new_static("actor")]),
424                            properties: {
425                                #[allow(unused_mut)]
426                                let mut map = BTreeMap::new();
427                                map.insert(
428                                    SmolStr::new_static("actor"),
429                                    LexXrpcParametersProperty::String(LexString {
430                                        description: Some(
431                                            CowStr::new_static("DID or handle of the actor"),
432                                        ),
433                                        format: Some(LexStringFormat::AtIdentifier),
434                                        ..Default::default()
435                                    }),
436                                );
437                                map.insert(
438                                    SmolStr::new_static("cursor"),
439                                    LexXrpcParametersProperty::String(LexString {
440                                        ..Default::default()
441                                    }),
442                                );
443                                map.insert(
444                                    SmolStr::new_static("limit"),
445                                    LexXrpcParametersProperty::Integer(LexInteger {
446                                        ..Default::default()
447                                    }),
448                                );
449                                map
450                            },
451                            ..Default::default()
452                        }),
453                    ),
454                    ..Default::default()
455                }),
456            );
457            map
458        },
459        ..Default::default()
460    }
461}
462
463fn _default_limit() -> Option<i64> {
464    Some(50i64)
465}
466
467pub mod list_drafts_state {
468
469    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
470    #[allow(unused)]
471    use ::core::marker::PhantomData;
472    mod sealed {
473        pub trait Sealed {}
474    }
475    /// State trait tracking which required fields have been set
476    pub trait State: sealed::Sealed {
477        type Actor;
478    }
479    /// Empty state - all required fields are unset
480    pub struct Empty(());
481    impl sealed::Sealed for Empty {}
482    impl State for Empty {
483        type Actor = Unset;
484    }
485    ///State transition - sets the `actor` field to Set
486    pub struct SetActor<S: State = Empty>(PhantomData<fn() -> S>);
487    impl<S: State> sealed::Sealed for SetActor<S> {}
488    impl<S: State> State for SetActor<S> {
489        type Actor = Set<members::actor>;
490    }
491    /// Marker types for field names
492    #[allow(non_camel_case_types)]
493    pub mod members {
494        ///Marker type for the `actor` field
495        pub struct actor(());
496    }
497}
498
499/// Builder for constructing an instance of this type
500pub struct ListDraftsBuilder<'a, S: list_drafts_state::State> {
501    _state: PhantomData<fn() -> S>,
502    _fields: (Option<AtIdentifier<'a>>, Option<CowStr<'a>>, Option<i64>),
503    _lifetime: PhantomData<&'a ()>,
504}
505
506impl<'a> ListDrafts<'a> {
507    /// Create a new builder for this type
508    pub fn new() -> ListDraftsBuilder<'a, list_drafts_state::Empty> {
509        ListDraftsBuilder::new()
510    }
511}
512
513impl<'a> ListDraftsBuilder<'a, list_drafts_state::Empty> {
514    /// Create a new builder with all fields unset
515    pub fn new() -> Self {
516        ListDraftsBuilder {
517            _state: PhantomData,
518            _fields: (None, None, None),
519            _lifetime: PhantomData,
520        }
521    }
522}
523
524impl<'a, S> ListDraftsBuilder<'a, S>
525where
526    S: list_drafts_state::State,
527    S::Actor: list_drafts_state::IsUnset,
528{
529    /// Set the `actor` field (required)
530    pub fn actor(
531        mut self,
532        value: impl Into<AtIdentifier<'a>>,
533    ) -> ListDraftsBuilder<'a, list_drafts_state::SetActor<S>> {
534        self._fields.0 = Option::Some(value.into());
535        ListDraftsBuilder {
536            _state: PhantomData,
537            _fields: self._fields,
538            _lifetime: PhantomData,
539        }
540    }
541}
542
543impl<'a, S: list_drafts_state::State> ListDraftsBuilder<'a, S> {
544    /// Set the `cursor` field (optional)
545    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
546        self._fields.1 = value.into();
547        self
548    }
549    /// Set the `cursor` field to an Option value (optional)
550    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
551        self._fields.1 = value;
552        self
553    }
554}
555
556impl<'a, S: list_drafts_state::State> ListDraftsBuilder<'a, S> {
557    /// Set the `limit` field (optional)
558    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
559        self._fields.2 = value.into();
560        self
561    }
562    /// Set the `limit` field to an Option value (optional)
563    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
564        self._fields.2 = value;
565        self
566    }
567}
568
569impl<'a, S> ListDraftsBuilder<'a, S>
570where
571    S: list_drafts_state::State,
572    S::Actor: list_drafts_state::IsSet,
573{
574    /// Build the final struct
575    pub fn build(self) -> ListDrafts<'a> {
576        ListDrafts {
577            actor: self._fields.0.unwrap(),
578            cursor: self._fields.1,
579            limit: self._fields.2,
580        }
581    }
582}