A better Rust ATProto crate
at lifetimes 3.8 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.identity.resolveDid 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[derive( 9 serde::Serialize, 10 serde::Deserialize, 11 Debug, 12 Clone, 13 PartialEq, 14 Eq, 15 bon::Builder, 16 jacquard_derive::IntoStatic 17)] 18#[builder(start_fn = new)] 19#[serde(rename_all = "camelCase")] 20pub struct ResolveDid<'a> { 21 #[serde(borrow)] 22 pub did: jacquard_common::types::string::Did<'a>, 23} 24 25#[jacquard_derive::lexicon] 26#[derive( 27 serde::Serialize, 28 serde::Deserialize, 29 Debug, 30 Clone, 31 PartialEq, 32 Eq, 33 jacquard_derive::IntoStatic 34)] 35#[serde(rename_all = "camelCase")] 36pub struct ResolveDidOutput<'a> { 37 ///The complete DID document for the identity. 38 #[serde(borrow)] 39 pub did_doc: jacquard_common::types::value::Data<'a>, 40} 41 42#[jacquard_derive::open_union] 43#[derive( 44 serde::Serialize, 45 serde::Deserialize, 46 Debug, 47 Clone, 48 PartialEq, 49 Eq, 50 thiserror::Error, 51 miette::Diagnostic 52)] 53#[serde(tag = "error", content = "message")] 54#[serde(bound(deserialize = "'de: 'a"))] 55pub enum ResolveDidError<'a> { 56 ///The DID resolution process confirmed that there is no current DID. 57 #[serde(rename = "DidNotFound")] 58 DidNotFound(std::option::Option<String>), 59 ///The DID previously existed, but has been deactivated. 60 #[serde(rename = "DidDeactivated")] 61 DidDeactivated(std::option::Option<String>), 62} 63 64impl std::fmt::Display for ResolveDidError<'_> { 65 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 66 match self { 67 Self::DidNotFound(msg) => { 68 write!(f, "DidNotFound")?; 69 if let Some(msg) = msg { 70 write!(f, ": {}", msg)?; 71 } 72 Ok(()) 73 } 74 Self::DidDeactivated(msg) => { 75 write!(f, "DidDeactivated")?; 76 if let Some(msg) = msg { 77 write!(f, ": {}", msg)?; 78 } 79 Ok(()) 80 } 81 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 82 } 83 } 84} 85 86impl jacquard_common::IntoStatic for ResolveDidError<'_> { 87 type Output = ResolveDidError<'static>; 88 fn into_static(self) -> Self::Output { 89 match self { 90 ResolveDidError::DidNotFound(v) => { 91 ResolveDidError::DidNotFound(v.into_static()) 92 } 93 ResolveDidError::DidDeactivated(v) => { 94 ResolveDidError::DidDeactivated(v.into_static()) 95 } 96 ResolveDidError::Unknown(v) => ResolveDidError::Unknown(v.into_static()), 97 } 98 } 99} 100 101///Response type for 102///com.atproto.identity.resolveDid 103pub struct ResolveDidResponse; 104impl jacquard_common::xrpc::XrpcResp for ResolveDidResponse { 105 const NSID: &'static str = "com.atproto.identity.resolveDid"; 106 const ENCODING: &'static str = "application/json"; 107 type Output<'de> = ResolveDidOutput<'de>; 108 type Err<'de> = ResolveDidError<'de>; 109} 110 111impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for ResolveDid<'de> { 112 const NSID: &'static str = "com.atproto.identity.resolveDid"; 113 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 114 type Response = ResolveDidResponse; 115} 116 117///Endpoint type for 118///com.atproto.identity.resolveDid 119pub struct ResolveDidRequest; 120impl jacquard_common::xrpc::XrpcEndpoint for ResolveDidRequest { 121 const PATH: &'static str = "/xrpc/com.atproto.identity.resolveDid"; 122 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 123 type Request<'de> = ResolveDid<'de>; 124 type Response = ResolveDidResponse; 125}