Skip to main content

jacquard_api/app_bsky/draft/
get_drafts.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.draft.getDrafts
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, BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::value::Data;
16use jacquard_derive::IntoStatic;
17use serde::{Serialize, Deserialize};
18use crate::app_bsky::draft::DraftView;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
22pub struct GetDrafts<S: BosStr = DefaultStr> {
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub cursor: Option<S>,
25    /// Defaults to `50`. Min: 1. Max: 100.
26    #[serde(default = "_default_limit")]
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub limit: Option<i64>,
29}
30
31
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
34pub struct GetDraftsOutput<S: BosStr = DefaultStr> {
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub cursor: Option<S>,
37    pub drafts: Vec<DraftView<S>>,
38    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
39    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
40}
41
42/** Response marker for the `app.bsky.draft.getDrafts` query.
43
44Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetDraftsOutput<S>` for this endpoint.*/
45pub struct GetDraftsResponse;
46impl jacquard_common::xrpc::XrpcResp for GetDraftsResponse {
47    const NSID: &'static str = "app.bsky.draft.getDrafts";
48    const ENCODING: &'static str = "application/json";
49    type Output<S: BosStr> = GetDraftsOutput<S>;
50    type Err = jacquard_common::xrpc::GenericError;
51}
52
53impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetDrafts<S> {
54    const NSID: &'static str = "app.bsky.draft.getDrafts";
55    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
56    type Response = GetDraftsResponse;
57}
58
59/** Endpoint marker for the `app.bsky.draft.getDrafts` query.
60
61Path: `/xrpc/app.bsky.draft.getDrafts`. The request payload type is `GetDrafts<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
62pub struct GetDraftsRequest;
63impl jacquard_common::xrpc::XrpcEndpoint for GetDraftsRequest {
64    const PATH: &'static str = "/xrpc/app.bsky.draft.getDrafts";
65    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
66    type Request<S: BosStr> = GetDrafts<S>;
67    type Response = GetDraftsResponse;
68}
69
70fn _default_limit() -> Option<i64> {
71    Some(50i64)
72}
73
74pub mod get_drafts_state {
75
76    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
77    #[allow(unused)]
78    use ::core::marker::PhantomData;
79    mod sealed {
80        pub trait Sealed {}
81    }
82    /// State trait tracking which required fields have been set
83    pub trait State: sealed::Sealed {}
84    /// Empty state - all required fields are unset
85    pub struct Empty(());
86    impl sealed::Sealed for Empty {}
87    impl State for Empty {}
88    /// Marker types for field names
89    #[allow(non_camel_case_types)]
90    pub mod members {}
91}
92
93/// Builder for constructing an instance of this type.
94pub struct GetDraftsBuilder<St: get_drafts_state::State, S: BosStr = DefaultStr> {
95    _state: PhantomData<fn() -> St>,
96    _fields: (Option<S>, Option<i64>),
97    _type: PhantomData<fn() -> S>,
98}
99
100impl GetDrafts<DefaultStr> {
101    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
102    pub fn new() -> GetDraftsBuilder<get_drafts_state::Empty, DefaultStr> {
103        GetDraftsBuilder::new()
104    }
105}
106
107impl<S: BosStr> GetDrafts<S> {
108    /// Create a new builder for this type
109    pub fn builder() -> GetDraftsBuilder<get_drafts_state::Empty, S> {
110        GetDraftsBuilder::builder()
111    }
112}
113
114impl GetDraftsBuilder<get_drafts_state::Empty, DefaultStr> {
115    /// Create a new builder with all fields unset, using the default string type, if needed
116    pub fn new() -> Self {
117        GetDraftsBuilder {
118            _state: PhantomData,
119            _fields: (None, None),
120            _type: PhantomData,
121        }
122    }
123}
124
125impl<S: BosStr> GetDraftsBuilder<get_drafts_state::Empty, S> {
126    /// Create a new builder with all fields unset
127    pub fn builder() -> Self {
128        GetDraftsBuilder {
129            _state: PhantomData,
130            _fields: (None, None),
131            _type: PhantomData,
132        }
133    }
134}
135
136impl<St: get_drafts_state::State, S: BosStr> GetDraftsBuilder<St, S> {
137    /// Set the `cursor` field (optional)
138    pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
139        self._fields.0 = value.into();
140        self
141    }
142    /// Set the `cursor` field to an Option value (optional)
143    pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
144        self._fields.0 = value;
145        self
146    }
147}
148
149impl<St: get_drafts_state::State, S: BosStr> GetDraftsBuilder<St, S> {
150    /// Set the `limit` field (optional)
151    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
152        self._fields.1 = value.into();
153        self
154    }
155    /// Set the `limit` field to an Option value (optional)
156    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
157        self._fields.1 = value;
158        self
159    }
160}
161
162impl<St, S: BosStr> GetDraftsBuilder<St, S>
163where
164    St: get_drafts_state::State,
165{
166    /// Build the final struct.
167    pub fn build(self) -> GetDrafts<S> {
168        GetDrafts {
169            cursor: self._fields.0,
170            limit: self._fields.1,
171        }
172    }
173}