#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use crate::com_atproto::identity::IdentityInfo;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::ident::AtIdentifier;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::{IntoStatic, open_union};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ResolveIdentity<S: BosStr = DefaultStr> {
pub identifier: AtIdentifier<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ResolveIdentityOutput<S: BosStr = DefaultStr> {
#[serde(flatten)]
pub value: IdentityInfo<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, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum ResolveIdentityError {
#[serde(rename = "HandleNotFound")]
HandleNotFound(Option<SmolStr>),
#[serde(rename = "DidNotFound")]
DidNotFound(Option<SmolStr>),
#[serde(rename = "DidDeactivated")]
DidDeactivated(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
impl core::fmt::Display for ResolveIdentityError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::HandleNotFound(msg) => {
write!(f, "HandleNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::DidNotFound(msg) => {
write!(f, "DidNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::DidDeactivated(msg) => {
write!(f, "DidDeactivated")?;
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(())
}
}
}
}
pub struct ResolveIdentityResponse;
impl jacquard_common::xrpc::XrpcResp for ResolveIdentityResponse {
const NSID: &'static str = "com.atproto.identity.resolveIdentity";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ResolveIdentityOutput<S>;
type Err = ResolveIdentityError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ResolveIdentity<S> {
const NSID: &'static str = "com.atproto.identity.resolveIdentity";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ResolveIdentityResponse;
}
pub struct ResolveIdentityRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ResolveIdentityRequest {
const PATH: &'static str = "/xrpc/com.atproto.identity.resolveIdentity";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = ResolveIdentity<S>;
type Response = ResolveIdentityResponse;
}
pub mod resolve_identity_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 Identifier;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Identifier = Unset;
}
pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIdentifier<St> {}
impl<St: State> State for SetIdentifier<St> {
type Identifier = Set<members::identifier>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct identifier(());
}
}
pub struct ResolveIdentityBuilder<S: BosStr, St: resolve_identity_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtIdentifier<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ResolveIdentity<S> {
pub fn new() -> ResolveIdentityBuilder<S, resolve_identity_state::Empty> {
ResolveIdentityBuilder::new()
}
}
impl<S: BosStr> ResolveIdentityBuilder<S, resolve_identity_state::Empty> {
pub fn new() -> Self {
ResolveIdentityBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ResolveIdentityBuilder<S, St>
where
St: resolve_identity_state::State,
St::Identifier: resolve_identity_state::IsUnset,
{
pub fn identifier(
mut self,
value: impl Into<AtIdentifier<S>>,
) -> ResolveIdentityBuilder<S, resolve_identity_state::SetIdentifier<St>> {
self._fields.0 = Option::Some(value.into());
ResolveIdentityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ResolveIdentityBuilder<S, St>
where
St: resolve_identity_state::State,
St::Identifier: resolve_identity_state::IsSet,
{
pub fn build(self) -> ResolveIdentity<S> {
ResolveIdentity {
identifier: self._fields.0.unwrap(),
}
}
}