// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.tangled.repo.tree // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, bon::Builder )] #[serde(rename_all = "camelCase")] pub struct LastCommit<'a> { /// Commit hash #[serde(borrow)] #[builder(into)] pub hash: jacquard_common::CowStr<'a>, /// Commit message #[serde(borrow)] #[builder(into)] pub message: jacquard_common::CowStr<'a>, /// Commit timestamp pub when: jacquard_common::types::string::Datetime, } #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, bon::Builder, jacquard_derive::IntoStatic )] #[builder(start_fn = new)] #[serde(rename_all = "camelCase")] pub struct Tree<'a> { ///(default: "") #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] #[builder(into)] pub path: std::option::Option>, #[serde(borrow)] #[builder(into)] pub r#ref: jacquard_common::CowStr<'a>, #[serde(borrow)] #[builder(into)] pub repo: jacquard_common::CowStr<'a>, } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct TreeOutput<'a> { /// Parent directory path #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub dotdot: std::option::Option>, #[serde(borrow)] pub files: Vec>, /// The parent path in the tree #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub parent: std::option::Option>, /// Readme for this file tree #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub readme: std::option::Option>, /// The git reference used #[serde(borrow)] pub r#ref: jacquard_common::CowStr<'a>, } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic, jacquard_derive::IntoStatic )] #[serde(tag = "error", content = "message")] #[serde(bound(deserialize = "'de: 'a"))] pub enum TreeError<'a> { /// Repository not found or access denied #[serde(rename = "RepoNotFound")] RepoNotFound(std::option::Option), /// Git reference not found #[serde(rename = "RefNotFound")] RefNotFound(std::option::Option), /// Path not found in repository tree #[serde(rename = "PathNotFound")] PathNotFound(std::option::Option), /// Invalid request parameters #[serde(rename = "InvalidRequest")] InvalidRequest(std::option::Option), } impl std::fmt::Display for TreeError<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::RepoNotFound(msg) => { write!(f, "RepoNotFound")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::RefNotFound(msg) => { write!(f, "RefNotFound")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::PathNotFound(msg) => { write!(f, "PathNotFound")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::InvalidRequest(msg) => { write!(f, "InvalidRequest")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } ///Response type for ///sh.tangled.repo.tree pub struct TreeResponse; impl jacquard_common::xrpc::XrpcResp for TreeResponse { const NSID: &'static str = "sh.tangled.repo.tree"; const ENCODING: &'static str = "application/json"; type Output<'de> = TreeOutput<'de>; type Err<'de> = TreeError<'de>; } impl<'a> jacquard_common::xrpc::XrpcRequest for Tree<'a> { const NSID: &'static str = "sh.tangled.repo.tree"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Response = TreeResponse; } ///Endpoint type for ///sh.tangled.repo.tree pub struct TreeRequest; impl jacquard_common::xrpc::XrpcEndpoint for TreeRequest { const PATH: &'static str = "/xrpc/sh.tangled.repo.tree"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Request<'de> = Tree<'de>; type Response = TreeResponse; } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct Readme<'a> { /// Contents of the readme file #[serde(borrow)] pub contents: jacquard_common::CowStr<'a>, /// Name of the readme file #[serde(borrow)] pub filename: jacquard_common::CowStr<'a>, } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, bon::Builder )] #[serde(rename_all = "camelCase")] pub struct TreeEntry<'a> { /// Whether this entry is a file pub is_file: bool, /// Whether this entry is a directory/subtree pub is_subtree: bool, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[builder(into)] #[serde(borrow)] pub last_commit: Option>, /// File mode #[serde(borrow)] #[builder(into)] pub mode: jacquard_common::CowStr<'a>, /// Relative file or directory name #[serde(borrow)] #[builder(into)] pub name: jacquard_common::CowStr<'a>, /// File size in bytes pub size: i64, }