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