// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: com.atproto.temp.checkHandleAvailability // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct CheckHandleAvailability<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] pub birth_date: std::option::Option, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub email: std::option::Option>, #[serde(borrow)] pub handle: jacquard_common::types::string::Handle<'a>, } pub mod check_handle_availability_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 CheckHandleAvailabilityBuilder< 'a, S: check_handle_availability_state::State, > { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> CheckHandleAvailability<'a> { /// Create a new builder for this type pub fn new() -> CheckHandleAvailabilityBuilder< 'a, check_handle_availability_state::Empty, > { CheckHandleAvailabilityBuilder::new() } } impl<'a> CheckHandleAvailabilityBuilder<'a, check_handle_availability_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { CheckHandleAvailabilityBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None), _phantom: ::core::marker::PhantomData, } } } impl< 'a, S: check_handle_availability_state::State, > CheckHandleAvailabilityBuilder<'a, S> { /// Set the `birthDate` field (optional) pub fn birth_date( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `birthDate` field to an Option value (optional) pub fn maybe_birth_date( mut self, value: Option, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl< 'a, S: check_handle_availability_state::State, > CheckHandleAvailabilityBuilder<'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> CheckHandleAvailabilityBuilder<'a, S> where S: check_handle_availability_state::State, S::Handle: check_handle_availability_state::IsUnset, { /// Set the `handle` field (required) pub fn handle( mut self, value: impl Into>, ) -> CheckHandleAvailabilityBuilder< 'a, check_handle_availability_state::SetHandle, > { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); CheckHandleAvailabilityBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> CheckHandleAvailabilityBuilder<'a, S> where S: check_handle_availability_state::State, S::Handle: check_handle_availability_state::IsSet, { /// Build the final struct pub fn build(self) -> CheckHandleAvailability<'a> { CheckHandleAvailability { birth_date: self.__unsafe_private_named.0, email: self.__unsafe_private_named.1, handle: self.__unsafe_private_named.2.unwrap(), } } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct CheckHandleAvailabilityOutput<'a> { /// Echo of the input handle. #[serde(borrow)] pub handle: jacquard_common::types::string::Handle<'a>, #[serde(borrow)] pub result: CheckHandleAvailabilityOutputResult<'a>, } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum CheckHandleAvailabilityOutputResult<'a> { #[serde(rename = "com.atproto.temp.checkHandleAvailability#resultAvailable")] ResultAvailable( Box>, ), #[serde(rename = "com.atproto.temp.checkHandleAvailability#resultUnavailable")] ResultUnavailable( Box>, ), } #[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 CheckHandleAvailabilityError<'a> { /// An invalid email was provided. #[serde(rename = "InvalidEmail")] InvalidEmail(std::option::Option>), } impl core::fmt::Display for CheckHandleAvailabilityError<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::InvalidEmail(msg) => { write!(f, "InvalidEmail")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } /// Response type for ///com.atproto.temp.checkHandleAvailability pub struct CheckHandleAvailabilityResponse; impl jacquard_common::xrpc::XrpcResp for CheckHandleAvailabilityResponse { const NSID: &'static str = "com.atproto.temp.checkHandleAvailability"; const ENCODING: &'static str = "application/json"; type Output<'de> = CheckHandleAvailabilityOutput<'de>; type Err<'de> = CheckHandleAvailabilityError<'de>; } impl<'a> jacquard_common::xrpc::XrpcRequest for CheckHandleAvailability<'a> { const NSID: &'static str = "com.atproto.temp.checkHandleAvailability"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Response = CheckHandleAvailabilityResponse; } /// Endpoint type for ///com.atproto.temp.checkHandleAvailability pub struct CheckHandleAvailabilityRequest; impl jacquard_common::xrpc::XrpcEndpoint for CheckHandleAvailabilityRequest { const PATH: &'static str = "/xrpc/com.atproto.temp.checkHandleAvailability"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Request<'de> = CheckHandleAvailability<'de>; type Response = CheckHandleAvailabilityResponse; } /// Indicates the provided handle is available. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct ResultAvailable<'a> {} fn lexicon_doc_com_atproto_temp_checkHandleAvailability() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static( "com.atproto.temp.checkHandleAvailability", ), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::XrpcQuery(::jacquard_lexicon::lexicon::LexXrpcQuery { description: None, parameters: Some( ::jacquard_lexicon::lexicon::LexXrpcQueryParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("handle") ], ), properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "birthDate", ), ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "User-provided birth date. Might be used to build handle suggestions.", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("email"), ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "User-provided email. Might be used to build handle suggestions.", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("handle"), ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Tentative handle. Will be checked for availability or used to build handle suggestions.", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Handle, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ), output: None, errors: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("resultAvailable"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "Indicates the provided handle is available.", ), ), required: None, nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("resultUnavailable"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "Indicates the provided handle is unavailable and gives suggestions of available handles.", ), ), required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("suggestions") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "suggestions", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "List of suggested handles based on the provided inputs.", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#suggestion"), }), min_length: None, max_length: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("suggestion"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("handle"), ::jacquard_common::smol_str::SmolStr::new_static("method") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("handle"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Handle, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("method"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Method used to build this suggestion. Should be considered opaque to clients. Can be used for metrics.", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ResultAvailable<'a> { fn nsid() -> &'static str { "com.atproto.temp.checkHandleAvailability" } fn def_name() -> &'static str { "resultAvailable" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_com_atproto_temp_checkHandleAvailability() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } /// Indicates the provided handle is unavailable and gives suggestions of available handles. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct ResultUnavailable<'a> { /// List of suggested handles based on the provided inputs. #[serde(borrow)] pub suggestions: Vec< crate::com_atproto::temp::check_handle_availability::Suggestion<'a>, >, } pub mod result_unavailable_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 Suggestions; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Suggestions = Unset; } ///State transition - sets the `suggestions` field to Set pub struct SetSuggestions(PhantomData S>); impl sealed::Sealed for SetSuggestions {} impl State for SetSuggestions { type Suggestions = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `suggestions` field pub struct suggestions(()); } } /// Builder for constructing an instance of this type pub struct ResultUnavailableBuilder<'a, S: result_unavailable_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option< Vec>, >, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> ResultUnavailable<'a> { /// Create a new builder for this type pub fn new() -> ResultUnavailableBuilder<'a, result_unavailable_state::Empty> { ResultUnavailableBuilder::new() } } impl<'a> ResultUnavailableBuilder<'a, result_unavailable_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ResultUnavailableBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None,), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ResultUnavailableBuilder<'a, S> where S: result_unavailable_state::State, S::Suggestions: result_unavailable_state::IsUnset, { /// Set the `suggestions` field (required) pub fn suggestions( mut self, value: impl Into< Vec>, >, ) -> ResultUnavailableBuilder<'a, result_unavailable_state::SetSuggestions> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); ResultUnavailableBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ResultUnavailableBuilder<'a, S> where S: result_unavailable_state::State, S::Suggestions: result_unavailable_state::IsSet, { /// Build the final struct pub fn build(self) -> ResultUnavailable<'a> { ResultUnavailable { suggestions: self.__unsafe_private_named.0.unwrap(), 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>, >, ) -> ResultUnavailable<'a> { ResultUnavailable { suggestions: self.__unsafe_private_named.0.unwrap(), extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ResultUnavailable<'a> { fn nsid() -> &'static str { "com.atproto.temp.checkHandleAvailability" } fn def_name() -> &'static str { "resultUnavailable" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_com_atproto_temp_checkHandleAvailability() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Suggestion<'a> { #[serde(borrow)] pub handle: jacquard_common::types::string::Handle<'a>, /// Method used to build this suggestion. Should be considered opaque to clients. Can be used for metrics. #[serde(borrow)] pub method: jacquard_common::CowStr<'a>, } pub mod suggestion_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; type Method; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Handle = Unset; type Method = 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; type Method = S::Method; } ///State transition - sets the `method` field to Set pub struct SetMethod(PhantomData S>); impl sealed::Sealed for SetMethod {} impl State for SetMethod { type Handle = S::Handle; type Method = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `handle` field pub struct handle(()); ///Marker type for the `method` field pub struct method(()); } } /// Builder for constructing an instance of this type pub struct SuggestionBuilder<'a, S: suggestion_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Suggestion<'a> { /// Create a new builder for this type pub fn new() -> SuggestionBuilder<'a, suggestion_state::Empty> { SuggestionBuilder::new() } } impl<'a> SuggestionBuilder<'a, suggestion_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { SuggestionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SuggestionBuilder<'a, S> where S: suggestion_state::State, S::Handle: suggestion_state::IsUnset, { /// Set the `handle` field (required) pub fn handle( mut self, value: impl Into>, ) -> SuggestionBuilder<'a, suggestion_state::SetHandle> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); SuggestionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SuggestionBuilder<'a, S> where S: suggestion_state::State, S::Method: suggestion_state::IsUnset, { /// Set the `method` field (required) pub fn method( mut self, value: impl Into>, ) -> SuggestionBuilder<'a, suggestion_state::SetMethod> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); SuggestionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SuggestionBuilder<'a, S> where S: suggestion_state::State, S::Handle: suggestion_state::IsSet, S::Method: suggestion_state::IsSet, { /// Build the final struct pub fn build(self) -> Suggestion<'a> { Suggestion { handle: self.__unsafe_private_named.0.unwrap(), method: self.__unsafe_private_named.1.unwrap(), 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>, >, ) -> Suggestion<'a> { Suggestion { handle: self.__unsafe_private_named.0.unwrap(), method: self.__unsafe_private_named.1.unwrap(), extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Suggestion<'a> { fn nsid() -> &'static str { "com.atproto.temp.checkHandleAvailability" } fn def_name() -> &'static str { "suggestion" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_com_atproto_temp_checkHandleAvailability() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } }