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_derive::{IntoStatic, lexicon};
14use serde::{Serialize, Deserialize};
15use crate::app_bsky::draft::DraftWithId;
16
17#[lexicon]
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct UpdateDraft<'a> {
21 #[serde(borrow)]
22 pub draft: DraftWithId<'a>,
23}
24
25pub struct UpdateDraftResponse;
27impl jacquard_common::xrpc::XrpcResp for UpdateDraftResponse {
28 const NSID: &'static str = "app.bsky.draft.updateDraft";
29 const ENCODING: &'static str = "application/json";
30 type Output<'de> = ();
31 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
32}
33
34impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateDraft<'a> {
35 const NSID: &'static str = "app.bsky.draft.updateDraft";
36 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
37 "application/json",
38 );
39 type Response = UpdateDraftResponse;
40}
41
42pub struct UpdateDraftRequest;
44impl jacquard_common::xrpc::XrpcEndpoint for UpdateDraftRequest {
45 const PATH: &'static str = "/xrpc/app.bsky.draft.updateDraft";
46 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
47 "application/json",
48 );
49 type Request<'de> = UpdateDraft<'de>;
50 type Response = UpdateDraftResponse;
51}
52
53pub mod update_draft_state {
54
55 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
56 #[allow(unused)]
57 use ::core::marker::PhantomData;
58 mod sealed {
59 pub trait Sealed {}
60 }
61 pub trait State: sealed::Sealed {
63 type Draft;
64 }
65 pub struct Empty(());
67 impl sealed::Sealed for Empty {}
68 impl State for Empty {
69 type Draft = Unset;
70 }
71 pub struct SetDraft<S: State = Empty>(PhantomData<fn() -> S>);
73 impl<S: State> sealed::Sealed for SetDraft<S> {}
74 impl<S: State> State for SetDraft<S> {
75 type Draft = Set<members::draft>;
76 }
77 #[allow(non_camel_case_types)]
79 pub mod members {
80 pub struct draft(());
82 }
83}
84
85pub struct UpdateDraftBuilder<'a, S: update_draft_state::State> {
87 _state: PhantomData<fn() -> S>,
88 _fields: (Option<DraftWithId<'a>>,),
89 _lifetime: PhantomData<&'a ()>,
90}
91
92impl<'a> UpdateDraft<'a> {
93 pub fn new() -> UpdateDraftBuilder<'a, update_draft_state::Empty> {
95 UpdateDraftBuilder::new()
96 }
97}
98
99impl<'a> UpdateDraftBuilder<'a, update_draft_state::Empty> {
100 pub fn new() -> Self {
102 UpdateDraftBuilder {
103 _state: PhantomData,
104 _fields: (None,),
105 _lifetime: PhantomData,
106 }
107 }
108}
109
110impl<'a, S> UpdateDraftBuilder<'a, S>
111where
112 S: update_draft_state::State,
113 S::Draft: update_draft_state::IsUnset,
114{
115 pub fn draft(
117 mut self,
118 value: impl Into<DraftWithId<'a>>,
119 ) -> UpdateDraftBuilder<'a, update_draft_state::SetDraft<S>> {
120 self._fields.0 = Option::Some(value.into());
121 UpdateDraftBuilder {
122 _state: PhantomData,
123 _fields: self._fields,
124 _lifetime: PhantomData,
125 }
126 }
127}
128
129impl<'a, S> UpdateDraftBuilder<'a, S>
130where
131 S: update_draft_state::State,
132 S::Draft: update_draft_state::IsSet,
133{
134 pub fn build(self) -> UpdateDraft<'a> {
136 UpdateDraft {
137 draft: self._fields.0.unwrap(),
138 extra_data: Default::default(),
139 }
140 }
141 pub fn build_with_data(
143 self,
144 extra_data: BTreeMap<
145 jacquard_common::deps::smol_str::SmolStr,
146 jacquard_common::types::value::Data<'a>,
147 >,
148 ) -> UpdateDraft<'a> {
149 UpdateDraft {
150 draft: self._fields.0.unwrap(),
151 extra_data: Some(extra_data),
152 }
153 }
154}