// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: com.atproto.server.createAccount // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct CreateAccount<'a> { /// Pre-existing atproto DID, being imported to a new account. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub did: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub email: std::option::Option>, /// Requested handle for the account. #[serde(borrow)] pub handle: jacquard_common::types::string::Handle<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub invite_code: std::option::Option>, /// Initial account password. May need to meet instance-specific password strength requirements. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub password: std::option::Option>, /// A signed DID PLC operation to be submitted as part of importing an existing account to this instance. NOTE: this optional field may be updated when full account migration is implemented. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub plc_op: std::option::Option>, /// DID PLC rotation key (aka, recovery key) to be included in PLC creation operation. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub recovery_key: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub verification_code: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub verification_phone: std::option::Option>, } pub mod create_account_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Handle; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Handle = Unset; } ///State transition - sets the `handle` field to Set pub struct SetHandle(PhantomData S>); impl sealed::Sealed for SetHandle {} impl State for SetHandle { type Handle = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `handle` field pub struct handle(()); } } /// Builder for constructing an instance of this type pub struct CreateAccountBuilder<'a, S: create_account_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> CreateAccount<'a> { /// Create a new builder for this type pub fn new() -> CreateAccountBuilder<'a, create_account_state::Empty> { CreateAccountBuilder::new() } } impl<'a> CreateAccountBuilder<'a, create_account_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { CreateAccountBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: ( None, None, None, None, None, None, None, None, None, ), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `did` field (optional) pub fn did( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `did` field to an Option value (optional) pub fn maybe_did( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `email` field (optional) pub fn email( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `email` field to an Option value (optional) pub fn maybe_email(mut self, value: Option>) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S> CreateAccountBuilder<'a, S> where S: create_account_state::State, S::Handle: create_account_state::IsUnset, { /// Set the `handle` field (required) pub fn handle( mut self, value: impl Into>, ) -> CreateAccountBuilder<'a, create_account_state::SetHandle> { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); CreateAccountBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `inviteCode` field (optional) pub fn invite_code( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `inviteCode` field to an Option value (optional) pub fn maybe_invite_code( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `password` field (optional) pub fn password( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `password` field to an Option value (optional) pub fn maybe_password(mut self, value: Option>) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `plcOp` field (optional) pub fn plc_op( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `plcOp` field to an Option value (optional) pub fn maybe_plc_op( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `recoveryKey` field (optional) pub fn recovery_key( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.6 = value.into(); self } /// Set the `recoveryKey` field to an Option value (optional) pub fn maybe_recovery_key( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.6 = value; self } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `verificationCode` field (optional) pub fn verification_code( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.7 = value.into(); self } /// Set the `verificationCode` field to an Option value (optional) pub fn maybe_verification_code( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.7 = value; self } } impl<'a, S: create_account_state::State> CreateAccountBuilder<'a, S> { /// Set the `verificationPhone` field (optional) pub fn verification_phone( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.8 = value.into(); self } /// Set the `verificationPhone` field to an Option value (optional) pub fn maybe_verification_phone( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.8 = value; self } } impl<'a, S> CreateAccountBuilder<'a, S> where S: create_account_state::State, S::Handle: create_account_state::IsSet, { /// Build the final struct pub fn build(self) -> CreateAccount<'a> { CreateAccount { did: self.__unsafe_private_named.0, email: self.__unsafe_private_named.1, handle: self.__unsafe_private_named.2.unwrap(), invite_code: self.__unsafe_private_named.3, password: self.__unsafe_private_named.4, plc_op: self.__unsafe_private_named.5, recovery_key: self.__unsafe_private_named.6, verification_code: self.__unsafe_private_named.7, verification_phone: self.__unsafe_private_named.8, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> CreateAccount<'a> { CreateAccount { did: self.__unsafe_private_named.0, email: self.__unsafe_private_named.1, handle: self.__unsafe_private_named.2.unwrap(), invite_code: self.__unsafe_private_named.3, password: self.__unsafe_private_named.4, plc_op: self.__unsafe_private_named.5, recovery_key: self.__unsafe_private_named.6, verification_code: self.__unsafe_private_named.7, verification_phone: self.__unsafe_private_named.8, extra_data: Some(extra_data), } } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct CreateAccountOutput<'a> { #[serde(borrow)] pub access_jwt: jacquard_common::CowStr<'a>, /// The DID of the new account. #[serde(borrow)] pub did: jacquard_common::types::string::Did<'a>, /// Complete DID document. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub did_doc: std::option::Option>, #[serde(borrow)] pub handle: jacquard_common::types::string::Handle<'a>, #[serde(borrow)] pub refresh_jwt: jacquard_common::CowStr<'a>, } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic, jacquard_derive::IntoStatic )] #[serde(tag = "error", content = "message")] #[serde(bound(deserialize = "'de: 'a"))] pub enum CreateAccountError<'a> { #[serde(rename = "InvalidHandle")] InvalidHandle(std::option::Option>), #[serde(rename = "InvalidPassword")] InvalidPassword(std::option::Option>), #[serde(rename = "InvalidInviteCode")] InvalidInviteCode(std::option::Option>), #[serde(rename = "HandleNotAvailable")] HandleNotAvailable(std::option::Option>), #[serde(rename = "UnsupportedDomain")] UnsupportedDomain(std::option::Option>), #[serde(rename = "UnresolvableDid")] UnresolvableDid(std::option::Option>), #[serde(rename = "IncompatibleDidDoc")] IncompatibleDidDoc(std::option::Option>), } impl core::fmt::Display for CreateAccountError<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::InvalidHandle(msg) => { write!(f, "InvalidHandle")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::InvalidPassword(msg) => { write!(f, "InvalidPassword")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::InvalidInviteCode(msg) => { write!(f, "InvalidInviteCode")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::HandleNotAvailable(msg) => { write!(f, "HandleNotAvailable")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::UnsupportedDomain(msg) => { write!(f, "UnsupportedDomain")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::UnresolvableDid(msg) => { write!(f, "UnresolvableDid")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::IncompatibleDidDoc(msg) => { write!(f, "IncompatibleDidDoc")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } /// Response type for ///com.atproto.server.createAccount pub struct CreateAccountResponse; impl jacquard_common::xrpc::XrpcResp for CreateAccountResponse { const NSID: &'static str = "com.atproto.server.createAccount"; const ENCODING: &'static str = "application/json"; type Output<'de> = CreateAccountOutput<'de>; type Err<'de> = CreateAccountError<'de>; } impl<'a> jacquard_common::xrpc::XrpcRequest for CreateAccount<'a> { const NSID: &'static str = "com.atproto.server.createAccount"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( "application/json", ); type Response = CreateAccountResponse; } /// Endpoint type for ///com.atproto.server.createAccount pub struct CreateAccountRequest; impl jacquard_common::xrpc::XrpcEndpoint for CreateAccountRequest { const PATH: &'static str = "/xrpc/com.atproto.server.createAccount"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( "application/json", ); type Request<'de> = CreateAccount<'de>; type Response = CreateAccountResponse; }