#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Datetime, Handle};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::com_atproto::temp::check_handle_availability;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CheckHandleAvailability<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub birth_date: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<S>,
pub handle: Handle<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CheckHandleAvailabilityOutput<S: BosStr = DefaultStr> {
pub handle: Handle<S>,
pub result: CheckHandleAvailabilityOutputResult<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CheckHandleAvailabilityOutputResult<S: BosStr = DefaultStr> {
#[serde(rename = "com.atproto.temp.checkHandleAvailability#resultAvailable")]
ResultAvailable(Box<check_handle_availability::ResultAvailable<S>>),
#[serde(rename = "com.atproto.temp.checkHandleAvailability#resultUnavailable")]
ResultUnavailable(Box<check_handle_availability::ResultUnavailable<S>>),
}
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum CheckHandleAvailabilityError {
#[serde(rename = "InvalidEmail")]
InvalidEmail(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
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::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ResultAvailable<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ResultUnavailable<S: BosStr = DefaultStr> {
pub suggestions: Vec<check_handle_availability::Suggestion<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Suggestion<S: BosStr = DefaultStr> {
pub handle: Handle<S>,
pub method: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
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<S: BosStr> = CheckHandleAvailabilityOutput<S>;
type Err = CheckHandleAvailabilityError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CheckHandleAvailability<S> {
const NSID: &'static str = "com.atproto.temp.checkHandleAvailability";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = CheckHandleAvailabilityResponse;
}
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<S: BosStr> = CheckHandleAvailability<S>;
type Response = CheckHandleAvailabilityResponse;
}
impl<S: BosStr> LexiconSchema for ResultAvailable<S> {
fn nsid() -> &'static str {
"com.atproto.temp.checkHandleAvailability"
}
fn def_name() -> &'static str {
"resultAvailable"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_temp_checkHandleAvailability()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ResultUnavailable<S> {
fn nsid() -> &'static str {
"com.atproto.temp.checkHandleAvailability"
}
fn def_name() -> &'static str {
"resultUnavailable"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_temp_checkHandleAvailability()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Suggestion<S> {
fn nsid() -> &'static str {
"com.atproto.temp.checkHandleAvailability"
}
fn def_name() -> &'static str {
"suggestion"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_temp_checkHandleAvailability()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod check_handle_availability_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Handle;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Handle = Unset;
}
pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHandle<St> {}
impl<St: State> State for SetHandle<St> {
type Handle = Set<members::handle>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct handle(());
}
}
pub struct CheckHandleAvailabilityBuilder<S: BosStr, St: check_handle_availability_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>, Option<S>, Option<Handle<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CheckHandleAvailability<S> {
pub fn new() -> CheckHandleAvailabilityBuilder<S, check_handle_availability_state::Empty> {
CheckHandleAvailabilityBuilder::new()
}
}
impl<S: BosStr> CheckHandleAvailabilityBuilder<S, check_handle_availability_state::Empty> {
pub fn new() -> Self {
CheckHandleAvailabilityBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: check_handle_availability_state::State> CheckHandleAvailabilityBuilder<S, St> {
pub fn birth_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_birth_date(mut self, value: Option<Datetime>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: check_handle_availability_state::State> CheckHandleAvailabilityBuilder<S, St> {
pub fn email(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_email(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> CheckHandleAvailabilityBuilder<S, St>
where
St: check_handle_availability_state::State,
St::Handle: check_handle_availability_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<Handle<S>>,
) -> CheckHandleAvailabilityBuilder<S, check_handle_availability_state::SetHandle<St>> {
self._fields.2 = Option::Some(value.into());
CheckHandleAvailabilityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CheckHandleAvailabilityBuilder<S, St>
where
St: check_handle_availability_state::State,
St::Handle: check_handle_availability_state::IsSet,
{
pub fn build(self) -> CheckHandleAvailability<S> {
CheckHandleAvailability {
birth_date: self._fields.0,
email: self._fields.1,
handle: self._fields.2.unwrap(),
}
}
}
fn lexicon_doc_com_atproto_temp_checkHandleAvailability() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("com.atproto.temp.checkHandleAvailability"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("handle")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("birthDate"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"User-provided birth date. Might be used to build handle suggestions.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("email"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"User-provided email. Might be used to build handle suggestions.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Tentative handle. Will be checked for availability or used to build handle suggestions.",
),
),
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultAvailable"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Indicates the provided handle is available.",
)),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultUnavailable"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Indicates the provided handle is unavailable and gives suggestions of available handles.",
),
),
required: Some(vec![SmolStr::new_static("suggestions")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("suggestions"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"List of suggested handles based on the provided inputs.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#suggestion"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("suggestion"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("handle"), SmolStr::new_static("method")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("method"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Method used to build this suggestion. Should be considered opaque to clients. Can be used for metrics.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod result_unavailable_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Suggestions;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Suggestions = Unset;
}
pub struct SetSuggestions<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSuggestions<St> {}
impl<St: State> State for SetSuggestions<St> {
type Suggestions = Set<members::suggestions>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct suggestions(());
}
}
pub struct ResultUnavailableBuilder<S: BosStr, St: result_unavailable_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<check_handle_availability::Suggestion<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ResultUnavailable<S> {
pub fn new() -> ResultUnavailableBuilder<S, result_unavailable_state::Empty> {
ResultUnavailableBuilder::new()
}
}
impl<S: BosStr> ResultUnavailableBuilder<S, result_unavailable_state::Empty> {
pub fn new() -> Self {
ResultUnavailableBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ResultUnavailableBuilder<S, St>
where
St: result_unavailable_state::State,
St::Suggestions: result_unavailable_state::IsUnset,
{
pub fn suggestions(
mut self,
value: impl Into<Vec<check_handle_availability::Suggestion<S>>>,
) -> ResultUnavailableBuilder<S, result_unavailable_state::SetSuggestions<St>> {
self._fields.0 = Option::Some(value.into());
ResultUnavailableBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ResultUnavailableBuilder<S, St>
where
St: result_unavailable_state::State,
St::Suggestions: result_unavailable_state::IsSet,
{
pub fn build(self) -> ResultUnavailable<S> {
ResultUnavailable {
suggestions: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ResultUnavailable<S> {
ResultUnavailable {
suggestions: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod suggestion_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Handle;
type Method;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Handle = Unset;
type Method = Unset;
}
pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHandle<St> {}
impl<St: State> State for SetHandle<St> {
type Handle = Set<members::handle>;
type Method = St::Method;
}
pub struct SetMethod<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMethod<St> {}
impl<St: State> State for SetMethod<St> {
type Handle = St::Handle;
type Method = Set<members::method>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct handle(());
pub struct method(());
}
}
pub struct SuggestionBuilder<S: BosStr, St: suggestion_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Handle<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Suggestion<S> {
pub fn new() -> SuggestionBuilder<S, suggestion_state::Empty> {
SuggestionBuilder::new()
}
}
impl<S: BosStr> SuggestionBuilder<S, suggestion_state::Empty> {
pub fn new() -> Self {
SuggestionBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SuggestionBuilder<S, St>
where
St: suggestion_state::State,
St::Handle: suggestion_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<Handle<S>>,
) -> SuggestionBuilder<S, suggestion_state::SetHandle<St>> {
self._fields.0 = Option::Some(value.into());
SuggestionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SuggestionBuilder<S, St>
where
St: suggestion_state::State,
St::Method: suggestion_state::IsUnset,
{
pub fn method(
mut self,
value: impl Into<S>,
) -> SuggestionBuilder<S, suggestion_state::SetMethod<St>> {
self._fields.1 = Option::Some(value.into());
SuggestionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SuggestionBuilder<S, St>
where
St: suggestion_state::State,
St::Handle: suggestion_state::IsSet,
St::Method: suggestion_state::IsSet,
{
pub fn build(self) -> Suggestion<S> {
Suggestion {
handle: self._fields.0.unwrap(),
method: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Suggestion<S> {
Suggestion {
handle: self._fields.0.unwrap(),
method: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}