1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.tangled.repo.languages
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 Language<'a> {
20 ///Hex color code for this language
21 #[serde(skip_serializing_if = "std::option::Option::is_none")]
22 #[serde(borrow)]
23 pub color: std::option::Option<jacquard_common::CowStr<'a>>,
24 ///File extensions associated with this language
25 #[serde(skip_serializing_if = "std::option::Option::is_none")]
26 #[serde(borrow)]
27 pub extensions: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
28 ///Number of files in this language
29 #[serde(skip_serializing_if = "std::option::Option::is_none")]
30 pub file_count: std::option::Option<i64>,
31 ///Programming language name
32 #[serde(borrow)]
33 pub name: jacquard_common::CowStr<'a>,
34 ///Percentage of total codebase (0-100)
35 pub percentage: i64,
36 ///Total size of files in this language (bytes)
37 pub size: i64,
38}
39
40#[derive(
41 serde::Serialize,
42 serde::Deserialize,
43 Debug,
44 Clone,
45 PartialEq,
46 Eq,
47 bon::Builder,
48 jacquard_derive::IntoStatic
49)]
50#[builder(start_fn = new)]
51#[serde(rename_all = "camelCase")]
52pub struct Languages<'a> {
53 ///(default: "HEAD")
54 #[serde(skip_serializing_if = "std::option::Option::is_none")]
55 #[serde(borrow)]
56 #[builder(into)]
57 pub r#ref: std::option::Option<jacquard_common::CowStr<'a>>,
58 #[serde(borrow)]
59 #[builder(into)]
60 pub repo: jacquard_common::CowStr<'a>,
61}
62
63#[jacquard_derive::lexicon]
64#[derive(
65 serde::Serialize,
66 serde::Deserialize,
67 Debug,
68 Clone,
69 PartialEq,
70 Eq,
71 jacquard_derive::IntoStatic
72)]
73#[serde(rename_all = "camelCase")]
74pub struct LanguagesOutput<'a> {
75 #[serde(borrow)]
76 pub languages: Vec<jacquard_common::types::value::Data<'a>>,
77 ///The git reference used
78 #[serde(borrow)]
79 pub r#ref: jacquard_common::CowStr<'a>,
80 ///Total number of files analyzed
81 #[serde(skip_serializing_if = "std::option::Option::is_none")]
82 pub total_files: std::option::Option<i64>,
83 ///Total size of all analyzed files in bytes
84 #[serde(skip_serializing_if = "std::option::Option::is_none")]
85 pub total_size: std::option::Option<i64>,
86}
87
88#[jacquard_derive::open_union]
89#[derive(
90 serde::Serialize,
91 serde::Deserialize,
92 Debug,
93 Clone,
94 PartialEq,
95 Eq,
96 thiserror::Error,
97 miette::Diagnostic,
98 jacquard_derive::IntoStatic
99)]
100#[serde(tag = "error", content = "message")]
101#[serde(bound(deserialize = "'de: 'a"))]
102pub enum LanguagesError<'a> {
103 ///Repository not found or access denied
104 #[serde(rename = "RepoNotFound")]
105 RepoNotFound(std::option::Option<String>),
106 ///Git reference not found
107 #[serde(rename = "RefNotFound")]
108 RefNotFound(std::option::Option<String>),
109 ///Invalid request parameters
110 #[serde(rename = "InvalidRequest")]
111 InvalidRequest(std::option::Option<String>),
112}
113
114impl std::fmt::Display for LanguagesError<'_> {
115 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
116 match self {
117 Self::RepoNotFound(msg) => {
118 write!(f, "RepoNotFound")?;
119 if let Some(msg) = msg {
120 write!(f, ": {}", msg)?;
121 }
122 Ok(())
123 }
124 Self::RefNotFound(msg) => {
125 write!(f, "RefNotFound")?;
126 if let Some(msg) = msg {
127 write!(f, ": {}", msg)?;
128 }
129 Ok(())
130 }
131 Self::InvalidRequest(msg) => {
132 write!(f, "InvalidRequest")?;
133 if let Some(msg) = msg {
134 write!(f, ": {}", msg)?;
135 }
136 Ok(())
137 }
138 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
139 }
140 }
141}
142
143///Response type for
144///sh.tangled.repo.languages
145pub struct LanguagesResponse;
146impl jacquard_common::xrpc::XrpcResp for LanguagesResponse {
147 const NSID: &'static str = "sh.tangled.repo.languages";
148 const ENCODING: &'static str = "application/json";
149 type Output<'de> = LanguagesOutput<'de>;
150 type Err<'de> = LanguagesError<'de>;
151}
152
153impl<'a> jacquard_common::xrpc::XrpcRequest for Languages<'a> {
154 const NSID: &'static str = "sh.tangled.repo.languages";
155 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
156 type Response = LanguagesResponse;
157}
158
159///Endpoint type for
160///sh.tangled.repo.languages
161pub struct LanguagesRequest;
162impl jacquard_common::xrpc::XrpcEndpoint for LanguagesRequest {
163 const PATH: &'static str = "/xrpc/sh.tangled.repo.languages";
164 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
165 type Request<'de> = Languages<'de>;
166 type Response = LanguagesResponse;
167}