A better Rust ATProto crate
at oauth 4.5 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.getBlob 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 GetBlob<'a> { 20 #[serde(borrow)] 21 pub cid: jacquard_common::types::string::Cid<'a>, 22 #[serde(borrow)] 23 pub did: jacquard_common::types::string::Did<'a>, 24} 25 26impl jacquard_common::IntoStatic for GetBlob<'_> { 27 type Output = GetBlob<'static>; 28 fn into_static(self) -> Self::Output { 29 GetBlob { 30 cid: self.cid.into_static(), 31 did: self.did.into_static(), 32 } 33 } 34} 35 36#[jacquard_derive::lexicon] 37#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 38#[serde(rename_all = "camelCase")] 39pub struct GetBlobOutput<'a> {} 40impl jacquard_common::IntoStatic for GetBlobOutput<'_> { 41 type Output = GetBlobOutput<'static>; 42 fn into_static(self) -> Self::Output { 43 GetBlobOutput { 44 extra_data: self.extra_data.into_static(), 45 } 46 } 47} 48 49#[jacquard_derive::open_union] 50#[derive( 51 serde::Serialize, 52 serde::Deserialize, 53 Debug, 54 Clone, 55 PartialEq, 56 Eq, 57 thiserror::Error, 58 miette::Diagnostic 59)] 60#[serde(tag = "error", content = "message")] 61#[serde(bound(deserialize = "'de: 'a"))] 62pub enum GetBlobError<'a> { 63 #[serde(rename = "BlobNotFound")] 64 BlobNotFound(std::option::Option<String>), 65 #[serde(rename = "RepoNotFound")] 66 RepoNotFound(std::option::Option<String>), 67 #[serde(rename = "RepoTakendown")] 68 RepoTakendown(std::option::Option<String>), 69 #[serde(rename = "RepoSuspended")] 70 RepoSuspended(std::option::Option<String>), 71 #[serde(rename = "RepoDeactivated")] 72 RepoDeactivated(std::option::Option<String>), 73} 74 75impl std::fmt::Display for GetBlobError<'_> { 76 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 77 match self { 78 Self::BlobNotFound(msg) => { 79 write!(f, "BlobNotFound")?; 80 if let Some(msg) = msg { 81 write!(f, ": {}", msg)?; 82 } 83 Ok(()) 84 } 85 Self::RepoNotFound(msg) => { 86 write!(f, "RepoNotFound")?; 87 if let Some(msg) = msg { 88 write!(f, ": {}", msg)?; 89 } 90 Ok(()) 91 } 92 Self::RepoTakendown(msg) => { 93 write!(f, "RepoTakendown")?; 94 if let Some(msg) = msg { 95 write!(f, ": {}", msg)?; 96 } 97 Ok(()) 98 } 99 Self::RepoSuspended(msg) => { 100 write!(f, "RepoSuspended")?; 101 if let Some(msg) = msg { 102 write!(f, ": {}", msg)?; 103 } 104 Ok(()) 105 } 106 Self::RepoDeactivated(msg) => { 107 write!(f, "RepoDeactivated")?; 108 if let Some(msg) = msg { 109 write!(f, ": {}", msg)?; 110 } 111 Ok(()) 112 } 113 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 114 } 115 } 116} 117 118impl jacquard_common::IntoStatic for GetBlobError<'_> { 119 type Output = GetBlobError<'static>; 120 fn into_static(self) -> Self::Output { 121 match self { 122 GetBlobError::BlobNotFound(v) => GetBlobError::BlobNotFound(v.into_static()), 123 GetBlobError::RepoNotFound(v) => GetBlobError::RepoNotFound(v.into_static()), 124 GetBlobError::RepoTakendown(v) => { 125 GetBlobError::RepoTakendown(v.into_static()) 126 } 127 GetBlobError::RepoSuspended(v) => { 128 GetBlobError::RepoSuspended(v.into_static()) 129 } 130 GetBlobError::RepoDeactivated(v) => { 131 GetBlobError::RepoDeactivated(v.into_static()) 132 } 133 GetBlobError::Unknown(v) => GetBlobError::Unknown(v.into_static()), 134 } 135 } 136} 137 138impl jacquard_common::types::xrpc::XrpcRequest for GetBlob<'_> { 139 const NSID: &'static str = "com.atproto.sync.getBlob"; 140 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query; 141 const OUTPUT_ENCODING: &'static str = "*/*"; 142 type Output<'de> = GetBlobOutput<'de>; 143 type Err<'de> = GetBlobError<'de>; 144}