1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.tangled.repo.getDefaultBranch
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9 serde::Serialize,
10 serde::Deserialize,
11 Debug,
12 Clone,
13 PartialEq,
14 Eq,
15 bon::Builder,
16 jacquard_derive::IntoStatic
17)]
18#[builder(start_fn = new)]
19#[serde(rename_all = "camelCase")]
20pub struct GetDefaultBranch<'a> {
21 #[serde(borrow)]
22 #[builder(into)]
23 pub repo: jacquard_common::CowStr<'a>,
24}
25
26#[jacquard_derive::lexicon]
27#[derive(
28 serde::Serialize,
29 serde::Deserialize,
30 Debug,
31 Clone,
32 PartialEq,
33 Eq,
34 jacquard_derive::IntoStatic
35)]
36#[serde(rename_all = "camelCase")]
37pub struct GetDefaultBranchOutput<'a> {
38 #[serde(skip_serializing_if = "std::option::Option::is_none")]
39 #[serde(borrow)]
40 pub author: std::option::Option<jacquard_common::types::value::Data<'a>>,
41 /// Latest commit hash on default branch
42 #[serde(borrow)]
43 pub hash: jacquard_common::CowStr<'a>,
44 /// Latest commit message
45 #[serde(skip_serializing_if = "std::option::Option::is_none")]
46 #[serde(borrow)]
47 pub message: std::option::Option<jacquard_common::CowStr<'a>>,
48 /// Default branch name
49 #[serde(borrow)]
50 pub name: jacquard_common::CowStr<'a>,
51 /// Short commit hash
52 #[serde(skip_serializing_if = "std::option::Option::is_none")]
53 #[serde(borrow)]
54 pub short_hash: std::option::Option<jacquard_common::CowStr<'a>>,
55 /// Timestamp of latest commit
56 pub when: jacquard_common::types::string::Datetime,
57}
58
59#[jacquard_derive::open_union]
60#[derive(
61 serde::Serialize,
62 serde::Deserialize,
63 Debug,
64 Clone,
65 PartialEq,
66 Eq,
67 thiserror::Error,
68 miette::Diagnostic,
69 jacquard_derive::IntoStatic
70)]
71#[serde(tag = "error", content = "message")]
72#[serde(bound(deserialize = "'de: 'a"))]
73pub enum GetDefaultBranchError<'a> {
74 /// Repository not found or access denied
75 #[serde(rename = "RepoNotFound")]
76 RepoNotFound(std::option::Option<String>),
77 /// Invalid request parameters
78 #[serde(rename = "InvalidRequest")]
79 InvalidRequest(std::option::Option<String>),
80}
81
82impl std::fmt::Display for GetDefaultBranchError<'_> {
83 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
84 match self {
85 Self::RepoNotFound(msg) => {
86 write!(f, "RepoNotFound")?;
87 if let Some(msg) = msg {
88 write!(f, ": {}", msg)?;
89 }
90 Ok(())
91 }
92 Self::InvalidRequest(msg) => {
93 write!(f, "InvalidRequest")?;
94 if let Some(msg) = msg {
95 write!(f, ": {}", msg)?;
96 }
97 Ok(())
98 }
99 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
100 }
101 }
102}
103
104///Response type for
105///sh.tangled.repo.getDefaultBranch
106pub struct GetDefaultBranchResponse;
107impl jacquard_common::xrpc::XrpcResp for GetDefaultBranchResponse {
108 const NSID: &'static str = "sh.tangled.repo.getDefaultBranch";
109 const ENCODING: &'static str = "application/json";
110 type Output<'de> = GetDefaultBranchOutput<'de>;
111 type Err<'de> = GetDefaultBranchError<'de>;
112}
113
114impl<'a> jacquard_common::xrpc::XrpcRequest for GetDefaultBranch<'a> {
115 const NSID: &'static str = "sh.tangled.repo.getDefaultBranch";
116 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
117 type Response = GetDefaultBranchResponse;
118}
119
120///Endpoint type for
121///sh.tangled.repo.getDefaultBranch
122pub struct GetDefaultBranchRequest;
123impl jacquard_common::xrpc::XrpcEndpoint for GetDefaultBranchRequest {
124 const PATH: &'static str = "/xrpc/sh.tangled.repo.getDefaultBranch";
125 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
126 type Request<'de> = GetDefaultBranch<'de>;
127 type Response = GetDefaultBranchResponse;
128}
129
130#[jacquard_derive::lexicon]
131#[derive(
132 serde::Serialize,
133 serde::Deserialize,
134 Debug,
135 Clone,
136 PartialEq,
137 Eq,
138 jacquard_derive::IntoStatic,
139 bon::Builder
140)]
141#[serde(rename_all = "camelCase")]
142pub struct Signature<'a> {
143 /// Author email
144 #[serde(borrow)]
145 #[builder(into)]
146 pub email: jacquard_common::CowStr<'a>,
147 /// Author name
148 #[serde(borrow)]
149 #[builder(into)]
150 pub name: jacquard_common::CowStr<'a>,
151 /// Author timestamp
152 pub when: jacquard_common::types::string::Datetime,
153}