1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::string::AtUri;
18use jacquard_derive::{IntoStatic, lexicon, open_union};
19use jacquard_lexicon::lexicon::LexiconDoc;
20use jacquard_lexicon::schema::LexiconSchema;
21
22#[allow(unused_imports)]
23use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
24use serde::{Serialize, Deserialize};
25use crate::sh_tangled::git::temp::list_languages;
26
27#[lexicon]
28#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
29#[serde(rename_all = "camelCase")]
30pub struct Language<'a> {
31 #[serde(skip_serializing_if = "Option::is_none")]
33 #[serde(borrow)]
34 pub color: Option<CowStr<'a>>,
35 #[serde(skip_serializing_if = "Option::is_none")]
37 #[serde(borrow)]
38 pub extensions: Option<Vec<CowStr<'a>>>,
39 #[serde(skip_serializing_if = "Option::is_none")]
41 pub file_count: Option<i64>,
42 #[serde(borrow)]
44 pub name: CowStr<'a>,
45 pub percentage: i64,
47 pub size: i64,
49}
50
51
52#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
53#[serde(rename_all = "camelCase")]
54pub struct ListLanguages<'a> {
55 #[serde(default = "_default_ref")]
57 #[serde(skip_serializing_if = "Option::is_none")]
58 #[serde(borrow)]
59 pub r#ref: Option<CowStr<'a>>,
60 #[serde(borrow)]
61 pub repo: AtUri<'a>,
62}
63
64
65#[lexicon]
66#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
67#[serde(rename_all = "camelCase")]
68pub struct ListLanguagesOutput<'a> {
69 #[serde(borrow)]
70 pub languages: Vec<list_languages::Language<'a>>,
71 #[serde(borrow)]
73 pub r#ref: CowStr<'a>,
74 #[serde(skip_serializing_if = "Option::is_none")]
76 pub total_files: Option<i64>,
77 #[serde(skip_serializing_if = "Option::is_none")]
79 pub total_size: Option<i64>,
80}
81
82
83#[open_union]
84#[derive(
85 Serialize,
86 Deserialize,
87 Debug,
88 Clone,
89 PartialEq,
90 Eq,
91 thiserror::Error,
92 miette::Diagnostic,
93 IntoStatic
94)]
95
96#[serde(tag = "error", content = "message")]
97#[serde(bound(deserialize = "'de: 'a"))]
98pub enum ListLanguagesError<'a> {
99 #[serde(rename = "RepoNotFound")]
101 RepoNotFound(Option<CowStr<'a>>),
102 #[serde(rename = "RefNotFound")]
104 RefNotFound(Option<CowStr<'a>>),
105 #[serde(rename = "InvalidRequest")]
107 InvalidRequest(Option<CowStr<'a>>),
108}
109
110impl core::fmt::Display for ListLanguagesError<'_> {
111 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
112 match self {
113 Self::RepoNotFound(msg) => {
114 write!(f, "RepoNotFound")?;
115 if let Some(msg) = msg {
116 write!(f, ": {}", msg)?;
117 }
118 Ok(())
119 }
120 Self::RefNotFound(msg) => {
121 write!(f, "RefNotFound")?;
122 if let Some(msg) = msg {
123 write!(f, ": {}", msg)?;
124 }
125 Ok(())
126 }
127 Self::InvalidRequest(msg) => {
128 write!(f, "InvalidRequest")?;
129 if let Some(msg) = msg {
130 write!(f, ": {}", msg)?;
131 }
132 Ok(())
133 }
134 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
135 }
136 }
137}
138
139impl<'a> LexiconSchema for Language<'a> {
140 fn nsid() -> &'static str {
141 "sh.tangled.git.temp.listLanguages"
142 }
143 fn def_name() -> &'static str {
144 "language"
145 }
146 fn lexicon_doc() -> LexiconDoc<'static> {
147 lexicon_doc_sh_tangled_git_temp_listLanguages()
148 }
149 fn validate(&self) -> Result<(), ConstraintError> {
150 Ok(())
151 }
152}
153
154pub struct ListLanguagesResponse;
156impl jacquard_common::xrpc::XrpcResp for ListLanguagesResponse {
157 const NSID: &'static str = "sh.tangled.git.temp.listLanguages";
158 const ENCODING: &'static str = "application/json";
159 type Output<'de> = ListLanguagesOutput<'de>;
160 type Err<'de> = ListLanguagesError<'de>;
161}
162
163impl<'a> jacquard_common::xrpc::XrpcRequest for ListLanguages<'a> {
164 const NSID: &'static str = "sh.tangled.git.temp.listLanguages";
165 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
166 type Response = ListLanguagesResponse;
167}
168
169pub struct ListLanguagesRequest;
171impl jacquard_common::xrpc::XrpcEndpoint for ListLanguagesRequest {
172 const PATH: &'static str = "/xrpc/sh.tangled.git.temp.listLanguages";
173 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
174 type Request<'de> = ListLanguages<'de>;
175 type Response = ListLanguagesResponse;
176}
177
178pub mod language_state {
179
180 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
181 #[allow(unused)]
182 use ::core::marker::PhantomData;
183 mod sealed {
184 pub trait Sealed {}
185 }
186 pub trait State: sealed::Sealed {
188 type Name;
189 type Size;
190 type Percentage;
191 }
192 pub struct Empty(());
194 impl sealed::Sealed for Empty {}
195 impl State for Empty {
196 type Name = Unset;
197 type Size = Unset;
198 type Percentage = Unset;
199 }
200 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
202 impl<S: State> sealed::Sealed for SetName<S> {}
203 impl<S: State> State for SetName<S> {
204 type Name = Set<members::name>;
205 type Size = S::Size;
206 type Percentage = S::Percentage;
207 }
208 pub struct SetSize<S: State = Empty>(PhantomData<fn() -> S>);
210 impl<S: State> sealed::Sealed for SetSize<S> {}
211 impl<S: State> State for SetSize<S> {
212 type Name = S::Name;
213 type Size = Set<members::size>;
214 type Percentage = S::Percentage;
215 }
216 pub struct SetPercentage<S: State = Empty>(PhantomData<fn() -> S>);
218 impl<S: State> sealed::Sealed for SetPercentage<S> {}
219 impl<S: State> State for SetPercentage<S> {
220 type Name = S::Name;
221 type Size = S::Size;
222 type Percentage = Set<members::percentage>;
223 }
224 #[allow(non_camel_case_types)]
226 pub mod members {
227 pub struct name(());
229 pub struct size(());
231 pub struct percentage(());
233 }
234}
235
236pub struct LanguageBuilder<'a, S: language_state::State> {
238 _state: PhantomData<fn() -> S>,
239 _fields: (
240 Option<CowStr<'a>>,
241 Option<Vec<CowStr<'a>>>,
242 Option<i64>,
243 Option<CowStr<'a>>,
244 Option<i64>,
245 Option<i64>,
246 ),
247 _lifetime: PhantomData<&'a ()>,
248}
249
250impl<'a> Language<'a> {
251 pub fn new() -> LanguageBuilder<'a, language_state::Empty> {
253 LanguageBuilder::new()
254 }
255}
256
257impl<'a> LanguageBuilder<'a, language_state::Empty> {
258 pub fn new() -> Self {
260 LanguageBuilder {
261 _state: PhantomData,
262 _fields: (None, None, None, None, None, None),
263 _lifetime: PhantomData,
264 }
265 }
266}
267
268impl<'a, S: language_state::State> LanguageBuilder<'a, S> {
269 pub fn color(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
271 self._fields.0 = value.into();
272 self
273 }
274 pub fn maybe_color(mut self, value: Option<CowStr<'a>>) -> Self {
276 self._fields.0 = value;
277 self
278 }
279}
280
281impl<'a, S: language_state::State> LanguageBuilder<'a, S> {
282 pub fn extensions(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
284 self._fields.1 = value.into();
285 self
286 }
287 pub fn maybe_extensions(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
289 self._fields.1 = value;
290 self
291 }
292}
293
294impl<'a, S: language_state::State> LanguageBuilder<'a, S> {
295 pub fn file_count(mut self, value: impl Into<Option<i64>>) -> Self {
297 self._fields.2 = value.into();
298 self
299 }
300 pub fn maybe_file_count(mut self, value: Option<i64>) -> Self {
302 self._fields.2 = value;
303 self
304 }
305}
306
307impl<'a, S> LanguageBuilder<'a, S>
308where
309 S: language_state::State,
310 S::Name: language_state::IsUnset,
311{
312 pub fn name(
314 mut self,
315 value: impl Into<CowStr<'a>>,
316 ) -> LanguageBuilder<'a, language_state::SetName<S>> {
317 self._fields.3 = Option::Some(value.into());
318 LanguageBuilder {
319 _state: PhantomData,
320 _fields: self._fields,
321 _lifetime: PhantomData,
322 }
323 }
324}
325
326impl<'a, S> LanguageBuilder<'a, S>
327where
328 S: language_state::State,
329 S::Percentage: language_state::IsUnset,
330{
331 pub fn percentage(
333 mut self,
334 value: impl Into<i64>,
335 ) -> LanguageBuilder<'a, language_state::SetPercentage<S>> {
336 self._fields.4 = Option::Some(value.into());
337 LanguageBuilder {
338 _state: PhantomData,
339 _fields: self._fields,
340 _lifetime: PhantomData,
341 }
342 }
343}
344
345impl<'a, S> LanguageBuilder<'a, S>
346where
347 S: language_state::State,
348 S::Size: language_state::IsUnset,
349{
350 pub fn size(
352 mut self,
353 value: impl Into<i64>,
354 ) -> LanguageBuilder<'a, language_state::SetSize<S>> {
355 self._fields.5 = Option::Some(value.into());
356 LanguageBuilder {
357 _state: PhantomData,
358 _fields: self._fields,
359 _lifetime: PhantomData,
360 }
361 }
362}
363
364impl<'a, S> LanguageBuilder<'a, S>
365where
366 S: language_state::State,
367 S::Name: language_state::IsSet,
368 S::Size: language_state::IsSet,
369 S::Percentage: language_state::IsSet,
370{
371 pub fn build(self) -> Language<'a> {
373 Language {
374 color: self._fields.0,
375 extensions: self._fields.1,
376 file_count: self._fields.2,
377 name: self._fields.3.unwrap(),
378 percentage: self._fields.4.unwrap(),
379 size: self._fields.5.unwrap(),
380 extra_data: Default::default(),
381 }
382 }
383 pub fn build_with_data(
385 self,
386 extra_data: BTreeMap<
387 jacquard_common::deps::smol_str::SmolStr,
388 jacquard_common::types::value::Data<'a>,
389 >,
390 ) -> Language<'a> {
391 Language {
392 color: self._fields.0,
393 extensions: self._fields.1,
394 file_count: self._fields.2,
395 name: self._fields.3.unwrap(),
396 percentage: self._fields.4.unwrap(),
397 size: self._fields.5.unwrap(),
398 extra_data: Some(extra_data),
399 }
400 }
401}
402
403fn lexicon_doc_sh_tangled_git_temp_listLanguages() -> LexiconDoc<'static> {
404 #[allow(unused_imports)]
405 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
406 use jacquard_lexicon::lexicon::*;
407 use alloc::collections::BTreeMap;
408 LexiconDoc {
409 lexicon: Lexicon::Lexicon1,
410 id: CowStr::new_static("sh.tangled.git.temp.listLanguages"),
411 defs: {
412 let mut map = BTreeMap::new();
413 map.insert(
414 SmolStr::new_static("language"),
415 LexUserType::Object(LexObject {
416 required: Some(
417 vec![
418 SmolStr::new_static("name"), SmolStr::new_static("size"),
419 SmolStr::new_static("percentage")
420 ],
421 ),
422 properties: {
423 #[allow(unused_mut)]
424 let mut map = BTreeMap::new();
425 map.insert(
426 SmolStr::new_static("color"),
427 LexObjectProperty::String(LexString {
428 description: Some(
429 CowStr::new_static("Hex color code for this language"),
430 ),
431 ..Default::default()
432 }),
433 );
434 map.insert(
435 SmolStr::new_static("extensions"),
436 LexObjectProperty::Array(LexArray {
437 description: Some(
438 CowStr::new_static(
439 "File extensions associated with this language",
440 ),
441 ),
442 items: LexArrayItem::String(LexString {
443 ..Default::default()
444 }),
445 ..Default::default()
446 }),
447 );
448 map.insert(
449 SmolStr::new_static("fileCount"),
450 LexObjectProperty::Integer(LexInteger {
451 ..Default::default()
452 }),
453 );
454 map.insert(
455 SmolStr::new_static("name"),
456 LexObjectProperty::String(LexString {
457 description: Some(
458 CowStr::new_static("Programming language name"),
459 ),
460 ..Default::default()
461 }),
462 );
463 map.insert(
464 SmolStr::new_static("percentage"),
465 LexObjectProperty::Integer(LexInteger {
466 ..Default::default()
467 }),
468 );
469 map.insert(
470 SmolStr::new_static("size"),
471 LexObjectProperty::Integer(LexInteger {
472 ..Default::default()
473 }),
474 );
475 map
476 },
477 ..Default::default()
478 }),
479 );
480 map.insert(
481 SmolStr::new_static("main"),
482 LexUserType::XrpcQuery(LexXrpcQuery {
483 parameters: Some(
484 LexXrpcQueryParameter::Params(LexXrpcParameters {
485 required: Some(vec![SmolStr::new_static("repo")]),
486 properties: {
487 #[allow(unused_mut)]
488 let mut map = BTreeMap::new();
489 map.insert(
490 SmolStr::new_static("ref"),
491 LexXrpcParametersProperty::String(LexString {
492 description: Some(
493 CowStr::new_static(
494 "Git reference (branch, tag, or commit SHA)",
495 ),
496 ),
497 ..Default::default()
498 }),
499 );
500 map.insert(
501 SmolStr::new_static("repo"),
502 LexXrpcParametersProperty::String(LexString {
503 description: Some(
504 CowStr::new_static("AT-URI of the repository"),
505 ),
506 format: Some(LexStringFormat::AtUri),
507 ..Default::default()
508 }),
509 );
510 map
511 },
512 ..Default::default()
513 }),
514 ),
515 ..Default::default()
516 }),
517 );
518 map
519 },
520 ..Default::default()
521 }
522}
523
524fn _default_ref() -> Option<CowStr<'static>> {
525 Some(CowStr::from("HEAD"))
526}
527
528pub mod list_languages_state {
529
530 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
531 #[allow(unused)]
532 use ::core::marker::PhantomData;
533 mod sealed {
534 pub trait Sealed {}
535 }
536 pub trait State: sealed::Sealed {
538 type Repo;
539 }
540 pub struct Empty(());
542 impl sealed::Sealed for Empty {}
543 impl State for Empty {
544 type Repo = Unset;
545 }
546 pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
548 impl<S: State> sealed::Sealed for SetRepo<S> {}
549 impl<S: State> State for SetRepo<S> {
550 type Repo = Set<members::repo>;
551 }
552 #[allow(non_camel_case_types)]
554 pub mod members {
555 pub struct repo(());
557 }
558}
559
560pub struct ListLanguagesBuilder<'a, S: list_languages_state::State> {
562 _state: PhantomData<fn() -> S>,
563 _fields: (Option<CowStr<'a>>, Option<AtUri<'a>>),
564 _lifetime: PhantomData<&'a ()>,
565}
566
567impl<'a> ListLanguages<'a> {
568 pub fn new() -> ListLanguagesBuilder<'a, list_languages_state::Empty> {
570 ListLanguagesBuilder::new()
571 }
572}
573
574impl<'a> ListLanguagesBuilder<'a, list_languages_state::Empty> {
575 pub fn new() -> Self {
577 ListLanguagesBuilder {
578 _state: PhantomData,
579 _fields: (None, None),
580 _lifetime: PhantomData,
581 }
582 }
583}
584
585impl<'a, S: list_languages_state::State> ListLanguagesBuilder<'a, S> {
586 pub fn r#ref(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
588 self._fields.0 = value.into();
589 self
590 }
591 pub fn maybe_ref(mut self, value: Option<CowStr<'a>>) -> Self {
593 self._fields.0 = value;
594 self
595 }
596}
597
598impl<'a, S> ListLanguagesBuilder<'a, S>
599where
600 S: list_languages_state::State,
601 S::Repo: list_languages_state::IsUnset,
602{
603 pub fn repo(
605 mut self,
606 value: impl Into<AtUri<'a>>,
607 ) -> ListLanguagesBuilder<'a, list_languages_state::SetRepo<S>> {
608 self._fields.1 = Option::Some(value.into());
609 ListLanguagesBuilder {
610 _state: PhantomData,
611 _fields: self._fields,
612 _lifetime: PhantomData,
613 }
614 }
615}
616
617impl<'a, S> ListLanguagesBuilder<'a, S>
618where
619 S: list_languages_state::State,
620 S::Repo: list_languages_state::IsSet,
621{
622 pub fn build(self) -> ListLanguages<'a> {
624 ListLanguages {
625 r#ref: self._fields.0,
626 repo: self._fields.1.unwrap(),
627 }
628 }
629}