jacquard_api/app_bsky/draft/
get_drafts.rs1#[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 #[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
47pub 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
64pub 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 pub trait State: sealed::Sealed {}
89 pub struct Empty(());
91 impl sealed::Sealed for Empty {}
92 impl State for Empty {}
93 #[allow(non_camel_case_types)]
95 pub mod members {}
96}
97
98pub 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 pub fn new() -> GetDraftsBuilder<get_drafts_state::Empty, DefaultStr> {
108 GetDraftsBuilder::new()
109 }
110}
111
112impl<S: BosStr> GetDrafts<S> {
113 pub fn builder() -> GetDraftsBuilder<get_drafts_state::Empty, S> {
115 GetDraftsBuilder::builder()
116 }
117}
118
119impl GetDraftsBuilder<get_drafts_state::Empty, DefaultStr> {
120 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 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 pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
144 self._fields.0 = value.into();
145 self
146 }
147 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 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
157 self._fields.1 = value.into();
158 self
159 }
160 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 pub fn build(self) -> GetDrafts<S> {
173 GetDrafts {
174 cursor: self._fields.0,
175 limit: self._fields.1,
176 }
177 }
178}