jacquard_api/com_atproto/server/
delete_account.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::Did;
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17
18#[lexicon]
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct DeleteAccount<'a> {
22 #[serde(borrow)]
23 pub did: Did<'a>,
24 #[serde(borrow)]
25 pub password: CowStr<'a>,
26 #[serde(borrow)]
27 pub token: CowStr<'a>,
28}
29
30
31#[open_union]
32#[derive(
33 Serialize,
34 Deserialize,
35 Debug,
36 Clone,
37 PartialEq,
38 Eq,
39 thiserror::Error,
40 miette::Diagnostic,
41 IntoStatic
42)]
43
44#[serde(tag = "error", content = "message")]
45#[serde(bound(deserialize = "'de: 'a"))]
46pub enum DeleteAccountError<'a> {
47 #[serde(rename = "ExpiredToken")]
48 ExpiredToken(Option<CowStr<'a>>),
49 #[serde(rename = "InvalidToken")]
50 InvalidToken(Option<CowStr<'a>>),
51}
52
53impl core::fmt::Display for DeleteAccountError<'_> {
54 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
55 match self {
56 Self::ExpiredToken(msg) => {
57 write!(f, "ExpiredToken")?;
58 if let Some(msg) = msg {
59 write!(f, ": {}", msg)?;
60 }
61 Ok(())
62 }
63 Self::InvalidToken(msg) => {
64 write!(f, "InvalidToken")?;
65 if let Some(msg) = msg {
66 write!(f, ": {}", msg)?;
67 }
68 Ok(())
69 }
70 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
71 }
72 }
73}
74
75pub struct DeleteAccountResponse;
77impl jacquard_common::xrpc::XrpcResp for DeleteAccountResponse {
78 const NSID: &'static str = "com.atproto.server.deleteAccount";
79 const ENCODING: &'static str = "application/json";
80 type Output<'de> = ();
81 type Err<'de> = DeleteAccountError<'de>;
82}
83
84impl<'a> jacquard_common::xrpc::XrpcRequest for DeleteAccount<'a> {
85 const NSID: &'static str = "com.atproto.server.deleteAccount";
86 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
87 "application/json",
88 );
89 type Response = DeleteAccountResponse;
90}
91
92pub struct DeleteAccountRequest;
94impl jacquard_common::xrpc::XrpcEndpoint for DeleteAccountRequest {
95 const PATH: &'static str = "/xrpc/com.atproto.server.deleteAccount";
96 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
97 "application/json",
98 );
99 type Request<'de> = DeleteAccount<'de>;
100 type Response = DeleteAccountResponse;
101}
102
103pub mod delete_account_state {
104
105 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
106 #[allow(unused)]
107 use ::core::marker::PhantomData;
108 mod sealed {
109 pub trait Sealed {}
110 }
111 pub trait State: sealed::Sealed {
113 type Did;
114 type Password;
115 type Token;
116 }
117 pub struct Empty(());
119 impl sealed::Sealed for Empty {}
120 impl State for Empty {
121 type Did = Unset;
122 type Password = Unset;
123 type Token = Unset;
124 }
125 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
127 impl<S: State> sealed::Sealed for SetDid<S> {}
128 impl<S: State> State for SetDid<S> {
129 type Did = Set<members::did>;
130 type Password = S::Password;
131 type Token = S::Token;
132 }
133 pub struct SetPassword<S: State = Empty>(PhantomData<fn() -> S>);
135 impl<S: State> sealed::Sealed for SetPassword<S> {}
136 impl<S: State> State for SetPassword<S> {
137 type Did = S::Did;
138 type Password = Set<members::password>;
139 type Token = S::Token;
140 }
141 pub struct SetToken<S: State = Empty>(PhantomData<fn() -> S>);
143 impl<S: State> sealed::Sealed for SetToken<S> {}
144 impl<S: State> State for SetToken<S> {
145 type Did = S::Did;
146 type Password = S::Password;
147 type Token = Set<members::token>;
148 }
149 #[allow(non_camel_case_types)]
151 pub mod members {
152 pub struct did(());
154 pub struct password(());
156 pub struct token(());
158 }
159}
160
161pub struct DeleteAccountBuilder<'a, S: delete_account_state::State> {
163 _state: PhantomData<fn() -> S>,
164 _fields: (Option<Did<'a>>, Option<CowStr<'a>>, Option<CowStr<'a>>),
165 _lifetime: PhantomData<&'a ()>,
166}
167
168impl<'a> DeleteAccount<'a> {
169 pub fn new() -> DeleteAccountBuilder<'a, delete_account_state::Empty> {
171 DeleteAccountBuilder::new()
172 }
173}
174
175impl<'a> DeleteAccountBuilder<'a, delete_account_state::Empty> {
176 pub fn new() -> Self {
178 DeleteAccountBuilder {
179 _state: PhantomData,
180 _fields: (None, None, None),
181 _lifetime: PhantomData,
182 }
183 }
184}
185
186impl<'a, S> DeleteAccountBuilder<'a, S>
187where
188 S: delete_account_state::State,
189 S::Did: delete_account_state::IsUnset,
190{
191 pub fn did(
193 mut self,
194 value: impl Into<Did<'a>>,
195 ) -> DeleteAccountBuilder<'a, delete_account_state::SetDid<S>> {
196 self._fields.0 = Option::Some(value.into());
197 DeleteAccountBuilder {
198 _state: PhantomData,
199 _fields: self._fields,
200 _lifetime: PhantomData,
201 }
202 }
203}
204
205impl<'a, S> DeleteAccountBuilder<'a, S>
206where
207 S: delete_account_state::State,
208 S::Password: delete_account_state::IsUnset,
209{
210 pub fn password(
212 mut self,
213 value: impl Into<CowStr<'a>>,
214 ) -> DeleteAccountBuilder<'a, delete_account_state::SetPassword<S>> {
215 self._fields.1 = Option::Some(value.into());
216 DeleteAccountBuilder {
217 _state: PhantomData,
218 _fields: self._fields,
219 _lifetime: PhantomData,
220 }
221 }
222}
223
224impl<'a, S> DeleteAccountBuilder<'a, S>
225where
226 S: delete_account_state::State,
227 S::Token: delete_account_state::IsUnset,
228{
229 pub fn token(
231 mut self,
232 value: impl Into<CowStr<'a>>,
233 ) -> DeleteAccountBuilder<'a, delete_account_state::SetToken<S>> {
234 self._fields.2 = Option::Some(value.into());
235 DeleteAccountBuilder {
236 _state: PhantomData,
237 _fields: self._fields,
238 _lifetime: PhantomData,
239 }
240 }
241}
242
243impl<'a, S> DeleteAccountBuilder<'a, S>
244where
245 S: delete_account_state::State,
246 S::Did: delete_account_state::IsSet,
247 S::Password: delete_account_state::IsSet,
248 S::Token: delete_account_state::IsSet,
249{
250 pub fn build(self) -> DeleteAccount<'a> {
252 DeleteAccount {
253 did: self._fields.0.unwrap(),
254 password: self._fields.1.unwrap(),
255 token: self._fields.2.unwrap(),
256 extra_data: Default::default(),
257 }
258 }
259 pub fn build_with_data(
261 self,
262 extra_data: BTreeMap<
263 jacquard_common::deps::smol_str::SmolStr,
264 jacquard_common::types::value::Data<'a>,
265 >,
266 ) -> DeleteAccount<'a> {
267 DeleteAccount {
268 did: self._fields.0.unwrap(),
269 password: self._fields.1.unwrap(),
270 token: self._fields.2.unwrap(),
271 extra_data: Some(extra_data),
272 }
273 }
274}