A better Rust ATProto crate
at oauth 2.8 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.getHead 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 GetHead<'a> { 20 #[serde(borrow)] 21 pub did: jacquard_common::types::string::Did<'a>, 22} 23 24impl jacquard_common::IntoStatic for GetHead<'_> { 25 type Output = GetHead<'static>; 26 fn into_static(self) -> Self::Output { 27 GetHead { 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 GetHeadOutput<'a> { 37 #[serde(borrow)] 38 pub root: jacquard_common::types::string::Cid<'a>, 39} 40 41impl jacquard_common::IntoStatic for GetHeadOutput<'_> { 42 type Output = GetHeadOutput<'static>; 43 fn into_static(self) -> Self::Output { 44 GetHeadOutput { 45 root: self.root.into_static(), 46 extra_data: self.extra_data.into_static(), 47 } 48 } 49} 50 51#[jacquard_derive::open_union] 52#[derive( 53 serde::Serialize, 54 serde::Deserialize, 55 Debug, 56 Clone, 57 PartialEq, 58 Eq, 59 thiserror::Error, 60 miette::Diagnostic 61)] 62#[serde(tag = "error", content = "message")] 63#[serde(bound(deserialize = "'de: 'a"))] 64pub enum GetHeadError<'a> { 65 #[serde(rename = "HeadNotFound")] 66 HeadNotFound(std::option::Option<String>), 67} 68 69impl std::fmt::Display for GetHeadError<'_> { 70 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 71 match self { 72 Self::HeadNotFound(msg) => { 73 write!(f, "HeadNotFound")?; 74 if let Some(msg) = msg { 75 write!(f, ": {}", msg)?; 76 } 77 Ok(()) 78 } 79 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 80 } 81 } 82} 83 84impl jacquard_common::IntoStatic for GetHeadError<'_> { 85 type Output = GetHeadError<'static>; 86 fn into_static(self) -> Self::Output { 87 match self { 88 GetHeadError::HeadNotFound(v) => GetHeadError::HeadNotFound(v.into_static()), 89 GetHeadError::Unknown(v) => GetHeadError::Unknown(v.into_static()), 90 } 91 } 92} 93 94impl jacquard_common::types::xrpc::XrpcRequest for GetHead<'_> { 95 const NSID: &'static str = "com.atproto.sync.getHead"; 96 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query; 97 const OUTPUT_ENCODING: &'static str = "application/json"; 98 type Output<'de> = GetHeadOutput<'de>; 99 type Err<'de> = GetHeadError<'de>; 100}