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