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