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