A better Rust ATProto crate
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.tangled.repo.blob 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 jacquard_derive::IntoStatic 17)] 18#[serde(rename_all = "camelCase")] 19pub struct LastCommit<'a> { 20 #[serde(skip_serializing_if = "std::option::Option::is_none")] 21 #[serde(borrow)] 22 pub author: std::option::Option<crate::sh_tangled::repo::blob::Signature<'a>>, 23 ///Commit hash 24 #[serde(borrow)] 25 pub hash: jacquard_common::CowStr<'a>, 26 ///Commit message 27 #[serde(borrow)] 28 pub message: jacquard_common::CowStr<'a>, 29 ///Short commit hash 30 #[serde(skip_serializing_if = "std::option::Option::is_none")] 31 #[serde(borrow)] 32 pub short_hash: std::option::Option<jacquard_common::CowStr<'a>>, 33 ///Commit timestamp 34 pub when: jacquard_common::types::string::Datetime, 35} 36 37#[derive( 38 serde::Serialize, 39 serde::Deserialize, 40 Debug, 41 Clone, 42 PartialEq, 43 Eq, 44 bon::Builder, 45 jacquard_derive::IntoStatic 46)] 47#[builder(start_fn = new)] 48#[serde(rename_all = "camelCase")] 49pub struct Blob<'a> { 50 #[serde(borrow)] 51 #[builder(into)] 52 pub path: jacquard_common::CowStr<'a>, 53 ///(default: false) 54 #[serde(skip_serializing_if = "std::option::Option::is_none")] 55 pub raw: std::option::Option<bool>, 56 #[serde(borrow)] 57 #[builder(into)] 58 pub r#ref: jacquard_common::CowStr<'a>, 59 #[serde(borrow)] 60 #[builder(into)] 61 pub repo: jacquard_common::CowStr<'a>, 62} 63 64#[jacquard_derive::lexicon] 65#[derive( 66 serde::Serialize, 67 serde::Deserialize, 68 Debug, 69 Clone, 70 PartialEq, 71 Eq, 72 jacquard_derive::IntoStatic 73)] 74#[serde(rename_all = "camelCase")] 75pub struct BlobOutput<'a> { 76 ///File content (base64 encoded for binary files) 77 #[serde(borrow)] 78 pub content: jacquard_common::CowStr<'a>, 79 ///Content encoding 80 #[serde(skip_serializing_if = "std::option::Option::is_none")] 81 #[serde(borrow)] 82 pub encoding: std::option::Option<jacquard_common::CowStr<'a>>, 83 ///Whether the file is binary 84 #[serde(skip_serializing_if = "std::option::Option::is_none")] 85 pub is_binary: std::option::Option<bool>, 86 #[serde(skip_serializing_if = "std::option::Option::is_none")] 87 #[serde(borrow)] 88 pub last_commit: std::option::Option<jacquard_common::types::value::Data<'a>>, 89 ///MIME type of the file 90 #[serde(skip_serializing_if = "std::option::Option::is_none")] 91 #[serde(borrow)] 92 pub mime_type: std::option::Option<jacquard_common::CowStr<'a>>, 93 ///The file path 94 #[serde(borrow)] 95 pub path: jacquard_common::CowStr<'a>, 96 ///The git reference used 97 #[serde(borrow)] 98 pub r#ref: jacquard_common::CowStr<'a>, 99 ///File size in bytes 100 #[serde(skip_serializing_if = "std::option::Option::is_none")] 101 pub size: std::option::Option<i64>, 102} 103 104#[jacquard_derive::open_union] 105#[derive( 106 serde::Serialize, 107 serde::Deserialize, 108 Debug, 109 Clone, 110 PartialEq, 111 Eq, 112 thiserror::Error, 113 miette::Diagnostic, 114 jacquard_derive::IntoStatic 115)] 116#[serde(tag = "error", content = "message")] 117#[serde(bound(deserialize = "'de: 'a"))] 118pub enum BlobError<'a> { 119 ///Repository not found or access denied 120 #[serde(rename = "RepoNotFound")] 121 RepoNotFound(std::option::Option<String>), 122 ///Git reference not found 123 #[serde(rename = "RefNotFound")] 124 RefNotFound(std::option::Option<String>), 125 ///File not found at the specified path 126 #[serde(rename = "FileNotFound")] 127 FileNotFound(std::option::Option<String>), 128 ///Invalid request parameters 129 #[serde(rename = "InvalidRequest")] 130 InvalidRequest(std::option::Option<String>), 131} 132 133impl std::fmt::Display for BlobError<'_> { 134 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 135 match self { 136 Self::RepoNotFound(msg) => { 137 write!(f, "RepoNotFound")?; 138 if let Some(msg) = msg { 139 write!(f, ": {}", msg)?; 140 } 141 Ok(()) 142 } 143 Self::RefNotFound(msg) => { 144 write!(f, "RefNotFound")?; 145 if let Some(msg) = msg { 146 write!(f, ": {}", msg)?; 147 } 148 Ok(()) 149 } 150 Self::FileNotFound(msg) => { 151 write!(f, "FileNotFound")?; 152 if let Some(msg) = msg { 153 write!(f, ": {}", msg)?; 154 } 155 Ok(()) 156 } 157 Self::InvalidRequest(msg) => { 158 write!(f, "InvalidRequest")?; 159 if let Some(msg) = msg { 160 write!(f, ": {}", msg)?; 161 } 162 Ok(()) 163 } 164 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 165 } 166 } 167} 168 169///Response type for 170///sh.tangled.repo.blob 171pub struct BlobResponse; 172impl jacquard_common::xrpc::XrpcResp for BlobResponse { 173 const NSID: &'static str = "sh.tangled.repo.blob"; 174 const ENCODING: &'static str = "application/json"; 175 type Output<'de> = BlobOutput<'de>; 176 type Err<'de> = BlobError<'de>; 177} 178 179impl<'a> jacquard_common::xrpc::XrpcRequest for Blob<'a> { 180 const NSID: &'static str = "sh.tangled.repo.blob"; 181 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 182 type Response = BlobResponse; 183} 184 185///Endpoint type for 186///sh.tangled.repo.blob 187pub struct BlobRequest; 188impl jacquard_common::xrpc::XrpcEndpoint for BlobRequest { 189 const PATH: &'static str = "/xrpc/sh.tangled.repo.blob"; 190 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 191 type Request<'de> = Blob<'de>; 192 type Response = BlobResponse; 193} 194 195#[jacquard_derive::lexicon] 196#[derive( 197 serde::Serialize, 198 serde::Deserialize, 199 Debug, 200 Clone, 201 PartialEq, 202 Eq, 203 jacquard_derive::IntoStatic 204)] 205#[serde(rename_all = "camelCase")] 206pub struct Signature<'a> { 207 ///Author email 208 #[serde(borrow)] 209 pub email: jacquard_common::CowStr<'a>, 210 ///Author name 211 #[serde(borrow)] 212 pub name: jacquard_common::CowStr<'a>, 213 ///Author timestamp 214 pub when: jacquard_common::types::string::Datetime, 215}