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