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