A better Rust ATProto crate
at oauth 3.6 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)] 17#[builder(start_fn = new)] 18#[serde(rename_all = "camelCase")] 19pub struct ResolveDid<'a> { 20 #[serde(borrow)] 21 pub did: jacquard_common::types::string::Did<'a>, 22} 23 24impl jacquard_common::IntoStatic for ResolveDid<'_> { 25 type Output = ResolveDid<'static>; 26 fn into_static(self) -> Self::Output { 27 ResolveDid { 28 did: self.did.into_static(), 29 } 30 } 31} 32 33#[jacquard_derive::lexicon] 34#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 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 42impl jacquard_common::IntoStatic for ResolveDidOutput<'_> { 43 type Output = ResolveDidOutput<'static>; 44 fn into_static(self) -> Self::Output { 45 ResolveDidOutput { 46 did_doc: self.did_doc.into_static(), 47 extra_data: self.extra_data.into_static(), 48 } 49 } 50} 51 52#[jacquard_derive::open_union] 53#[derive( 54 serde::Serialize, 55 serde::Deserialize, 56 Debug, 57 Clone, 58 PartialEq, 59 Eq, 60 thiserror::Error, 61 miette::Diagnostic 62)] 63#[serde(tag = "error", content = "message")] 64#[serde(bound(deserialize = "'de: 'a"))] 65pub enum ResolveDidError<'a> { 66 ///The DID resolution process confirmed that there is no current DID. 67 #[serde(rename = "DidNotFound")] 68 DidNotFound(std::option::Option<String>), 69 ///The DID previously existed, but has been deactivated. 70 #[serde(rename = "DidDeactivated")] 71 DidDeactivated(std::option::Option<String>), 72} 73 74impl std::fmt::Display for ResolveDidError<'_> { 75 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 76 match self { 77 Self::DidNotFound(msg) => { 78 write!(f, "DidNotFound")?; 79 if let Some(msg) = msg { 80 write!(f, ": {}", msg)?; 81 } 82 Ok(()) 83 } 84 Self::DidDeactivated(msg) => { 85 write!(f, "DidDeactivated")?; 86 if let Some(msg) = msg { 87 write!(f, ": {}", msg)?; 88 } 89 Ok(()) 90 } 91 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 92 } 93 } 94} 95 96impl jacquard_common::IntoStatic for ResolveDidError<'_> { 97 type Output = ResolveDidError<'static>; 98 fn into_static(self) -> Self::Output { 99 match self { 100 ResolveDidError::DidNotFound(v) => { 101 ResolveDidError::DidNotFound(v.into_static()) 102 } 103 ResolveDidError::DidDeactivated(v) => { 104 ResolveDidError::DidDeactivated(v.into_static()) 105 } 106 ResolveDidError::Unknown(v) => ResolveDidError::Unknown(v.into_static()), 107 } 108 } 109} 110 111impl jacquard_common::types::xrpc::XrpcRequest for ResolveDid<'_> { 112 const NSID: &'static str = "com.atproto.identity.resolveDid"; 113 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query; 114 const OUTPUT_ENCODING: &'static str = "application/json"; 115 type Output<'de> = ResolveDidOutput<'de>; 116 type Err<'de> = ResolveDidError<'de>; 117}