#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ResolveDid<S: BosStr = DefaultStr> {
pub did: Did<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ResolveDidOutput<S: BosStr = DefaultStr> {
pub did_doc: Data<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 ResolveDidError {
#[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 ResolveDidError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
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 ResolveDidResponse;
impl jacquard_common::xrpc::XrpcResp for ResolveDidResponse {
const NSID: &'static str = "com.atproto.identity.resolveDid";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ResolveDidOutput<S>;
type Err = ResolveDidError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ResolveDid<S> {
const NSID: &'static str = "com.atproto.identity.resolveDid";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ResolveDidResponse;
}
pub struct ResolveDidRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ResolveDidRequest {
const PATH: &'static str = "/xrpc/com.atproto.identity.resolveDid";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = ResolveDid<S>;
type Response = ResolveDidResponse;
}
pub mod resolve_did_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct ResolveDidBuilder<S: BosStr, St: resolve_did_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ResolveDid<S> {
pub fn new() -> ResolveDidBuilder<S, resolve_did_state::Empty> {
ResolveDidBuilder::new()
}
}
impl<S: BosStr> ResolveDidBuilder<S, resolve_did_state::Empty> {
pub fn new() -> Self {
ResolveDidBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ResolveDidBuilder<S, St>
where
St: resolve_did_state::State,
St::Did: resolve_did_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> ResolveDidBuilder<S, resolve_did_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
ResolveDidBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ResolveDidBuilder<S, St>
where
St: resolve_did_state::State,
St::Did: resolve_did_state::IsSet,
{
pub fn build(self) -> ResolveDid<S> {
ResolveDid {
did: self._fields.0.unwrap(),
}
}
}