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