jacquard_api/app_bsky/draft/
get_drafts.rs1#[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 #[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
42pub 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
59pub 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 pub trait State: sealed::Sealed {}
84 pub struct Empty(());
86 impl sealed::Sealed for Empty {}
87 impl State for Empty {}
88 #[allow(non_camel_case_types)]
90 pub mod members {}
91}
92
93pub 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 pub fn new() -> GetDraftsBuilder<get_drafts_state::Empty, DefaultStr> {
103 GetDraftsBuilder::new()
104 }
105}
106
107impl<S: BosStr> GetDrafts<S> {
108 pub fn builder() -> GetDraftsBuilder<get_drafts_state::Empty, S> {
110 GetDraftsBuilder::builder()
111 }
112}
113
114impl GetDraftsBuilder<get_drafts_state::Empty, DefaultStr> {
115 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 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 pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
139 self._fields.0 = value.into();
140 self
141 }
142 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 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
152 self._fields.1 = value.into();
153 self
154 }
155 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 pub fn build(self) -> GetDrafts<S> {
168 GetDrafts {
169 cursor: self._fields.0,
170 limit: self._fields.1,
171 }
172 }
173}