jacquard_api/app_bsky/draft/
update_draft.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{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::DraftWithId;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
22pub struct UpdateDraft<S: BosStr = DefaultStr> {
23 pub draft: DraftWithId<S>,
24 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
25 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
26}
27
28pub struct UpdateDraftResponse;
32impl jacquard_common::xrpc::XrpcResp for UpdateDraftResponse {
33 const NSID: &'static str = "app.bsky.draft.updateDraft";
34 const ENCODING: &'static str = "application/json";
35 type Output<S: BosStr> = ();
36 type Err = jacquard_common::xrpc::GenericError;
37}
38
39impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for UpdateDraft<S> {
40 const NSID: &'static str = "app.bsky.draft.updateDraft";
41 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
42 "application/json",
43 );
44 type Response = UpdateDraftResponse;
45}
46
47pub struct UpdateDraftRequest;
51impl jacquard_common::xrpc::XrpcEndpoint for UpdateDraftRequest {
52 const PATH: &'static str = "/xrpc/app.bsky.draft.updateDraft";
53 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
54 "application/json",
55 );
56 type Request<S: BosStr> = UpdateDraft<S>;
57 type Response = UpdateDraftResponse;
58}
59
60pub mod update_draft_state {
61
62 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
63 #[allow(unused)]
64 use ::core::marker::PhantomData;
65 mod sealed {
66 pub trait Sealed {}
67 }
68 pub trait State: sealed::Sealed {
70 type Draft;
71 }
72 pub struct Empty(());
74 impl sealed::Sealed for Empty {}
75 impl State for Empty {
76 type Draft = Unset;
77 }
78 pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
80 impl<St: State> sealed::Sealed for SetDraft<St> {}
81 impl<St: State> State for SetDraft<St> {
82 type Draft = Set<members::draft>;
83 }
84 #[allow(non_camel_case_types)]
86 pub mod members {
87 pub struct draft(());
89 }
90}
91
92pub struct UpdateDraftBuilder<St: update_draft_state::State, S: BosStr = DefaultStr> {
94 _state: PhantomData<fn() -> St>,
95 _fields: (Option<DraftWithId<S>>,),
96 _type: PhantomData<fn() -> S>,
97}
98
99impl UpdateDraft<DefaultStr> {
100 pub fn new() -> UpdateDraftBuilder<update_draft_state::Empty, DefaultStr> {
102 UpdateDraftBuilder::new()
103 }
104}
105
106impl<S: BosStr> UpdateDraft<S> {
107 pub fn builder() -> UpdateDraftBuilder<update_draft_state::Empty, S> {
109 UpdateDraftBuilder::builder()
110 }
111}
112
113impl UpdateDraftBuilder<update_draft_state::Empty, DefaultStr> {
114 pub fn new() -> Self {
116 UpdateDraftBuilder {
117 _state: PhantomData,
118 _fields: (None,),
119 _type: PhantomData,
120 }
121 }
122}
123
124impl<S: BosStr> UpdateDraftBuilder<update_draft_state::Empty, S> {
125 pub fn builder() -> Self {
127 UpdateDraftBuilder {
128 _state: PhantomData,
129 _fields: (None,),
130 _type: PhantomData,
131 }
132 }
133}
134
135impl<St, S: BosStr> UpdateDraftBuilder<St, S>
136where
137 St: update_draft_state::State,
138 St::Draft: update_draft_state::IsUnset,
139{
140 pub fn draft(
142 mut self,
143 value: impl Into<DraftWithId<S>>,
144 ) -> UpdateDraftBuilder<update_draft_state::SetDraft<St>, S> {
145 self._fields.0 = Option::Some(value.into());
146 UpdateDraftBuilder {
147 _state: PhantomData,
148 _fields: self._fields,
149 _type: PhantomData,
150 }
151 }
152}
153
154impl<St, S: BosStr> UpdateDraftBuilder<St, S>
155where
156 St: update_draft_state::State,
157 St::Draft: update_draft_state::IsSet,
158{
159 pub fn build(self) -> UpdateDraft<S> {
161 UpdateDraft {
162 draft: self._fields.0.unwrap(),
163 extra_data: Default::default(),
164 }
165 }
166 pub fn build_with_data(
168 self,
169 extra_data: BTreeMap<SmolStr, Data<S>>,
170 ) -> UpdateDraft<S> {
171 UpdateDraft {
172 draft: self._fields.0.unwrap(),
173 extra_data: Some(extra_data),
174 }
175 }
176}