Skip to main content

jacquard_api/com_atproto/server/
delete_account.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.deleteAccount
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[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
75/// Response type for com.atproto.server.deleteAccount
76pub 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
92/// Endpoint type for com.atproto.server.deleteAccount
93pub 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    /// State trait tracking which required fields have been set
112    pub trait State: sealed::Sealed {
113        type Did;
114        type Password;
115        type Token;
116    }
117    /// Empty state - all required fields are unset
118    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    ///State transition - sets the `did` field to Set
126    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    ///State transition - sets the `password` field to Set
134    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    ///State transition - sets the `token` field to Set
142    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    /// Marker types for field names
150    #[allow(non_camel_case_types)]
151    pub mod members {
152        ///Marker type for the `did` field
153        pub struct did(());
154        ///Marker type for the `password` field
155        pub struct password(());
156        ///Marker type for the `token` field
157        pub struct token(());
158    }
159}
160
161/// Builder for constructing an instance of this type
162pub 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    /// Create a new builder for this type
170    pub fn new() -> DeleteAccountBuilder<'a, delete_account_state::Empty> {
171        DeleteAccountBuilder::new()
172    }
173}
174
175impl<'a> DeleteAccountBuilder<'a, delete_account_state::Empty> {
176    /// Create a new builder with all fields unset
177    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    /// Set the `did` field (required)
192    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    /// Set the `password` field (required)
211    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    /// Set the `token` field (required)
230    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    /// Build the final struct
251    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    /// Build the final struct with custom extra_data
260    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}