jacquard_api/sh_tangled/git/temp/
get_commit.rs1#[allow(unused_imports)]
9use core::marker::PhantomData;
10use jacquard_common::CowStr;
11use jacquard_common::types::string::AtUri;
12use jacquard_derive::{IntoStatic, open_union};
13use serde::{Serialize, Deserialize};
14use crate::sh_tangled::git::temp::Commit;
15
16#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
17#[serde(rename_all = "camelCase")]
18pub struct GetCommit<'a> {
19 #[serde(borrow)]
20 pub r#ref: CowStr<'a>,
21 #[serde(borrow)]
22 pub repo: AtUri<'a>,
23}
24
25
26#[jacquard_derive::lexicon]
27#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
28#[serde(rename_all = "camelCase")]
29pub struct GetCommitOutput<'a> {
30 #[serde(flatten)]
31 #[serde(borrow)]
32 pub value: Commit<'a>,
33}
34
35
36#[open_union]
37#[derive(
38 Serialize,
39 Deserialize,
40 Debug,
41 Clone,
42 PartialEq,
43 Eq,
44 thiserror::Error,
45 miette::Diagnostic,
46 IntoStatic
47)]
48
49#[serde(tag = "error", content = "message")]
50#[serde(bound(deserialize = "'de: 'a"))]
51pub enum GetCommitError<'a> {
52 #[serde(rename = "RepoNotFound")]
54 RepoNotFound(Option<CowStr<'a>>),
55 #[serde(rename = "CommitNotFound")]
57 CommitNotFound(Option<CowStr<'a>>),
58 #[serde(rename = "InvalidRequest")]
60 InvalidRequest(Option<CowStr<'a>>),
61}
62
63impl core::fmt::Display for GetCommitError<'_> {
64 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 match self {
66 Self::RepoNotFound(msg) => {
67 write!(f, "RepoNotFound")?;
68 if let Some(msg) = msg {
69 write!(f, ": {}", msg)?;
70 }
71 Ok(())
72 }
73 Self::CommitNotFound(msg) => {
74 write!(f, "CommitNotFound")?;
75 if let Some(msg) = msg {
76 write!(f, ": {}", msg)?;
77 }
78 Ok(())
79 }
80 Self::InvalidRequest(msg) => {
81 write!(f, "InvalidRequest")?;
82 if let Some(msg) = msg {
83 write!(f, ": {}", msg)?;
84 }
85 Ok(())
86 }
87 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
88 }
89 }
90}
91
92pub struct GetCommitResponse;
94impl jacquard_common::xrpc::XrpcResp for GetCommitResponse {
95 const NSID: &'static str = "sh.tangled.git.temp.getCommit";
96 const ENCODING: &'static str = "application/json";
97 type Output<'de> = GetCommitOutput<'de>;
98 type Err<'de> = GetCommitError<'de>;
99}
100
101impl<'a> jacquard_common::xrpc::XrpcRequest for GetCommit<'a> {
102 const NSID: &'static str = "sh.tangled.git.temp.getCommit";
103 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
104 type Response = GetCommitResponse;
105}
106
107pub struct GetCommitRequest;
109impl jacquard_common::xrpc::XrpcEndpoint for GetCommitRequest {
110 const PATH: &'static str = "/xrpc/sh.tangled.git.temp.getCommit";
111 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
112 type Request<'de> = GetCommit<'de>;
113 type Response = GetCommitResponse;
114}
115
116pub mod get_commit_state {
117
118 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
119 #[allow(unused)]
120 use ::core::marker::PhantomData;
121 mod sealed {
122 pub trait Sealed {}
123 }
124 pub trait State: sealed::Sealed {
126 type Ref;
127 type Repo;
128 }
129 pub struct Empty(());
131 impl sealed::Sealed for Empty {}
132 impl State for Empty {
133 type Ref = Unset;
134 type Repo = Unset;
135 }
136 pub struct SetRef<S: State = Empty>(PhantomData<fn() -> S>);
138 impl<S: State> sealed::Sealed for SetRef<S> {}
139 impl<S: State> State for SetRef<S> {
140 type Ref = Set<members::r#ref>;
141 type Repo = S::Repo;
142 }
143 pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
145 impl<S: State> sealed::Sealed for SetRepo<S> {}
146 impl<S: State> State for SetRepo<S> {
147 type Ref = S::Ref;
148 type Repo = Set<members::repo>;
149 }
150 #[allow(non_camel_case_types)]
152 pub mod members {
153 pub struct r#ref(());
155 pub struct repo(());
157 }
158}
159
160pub struct GetCommitBuilder<'a, S: get_commit_state::State> {
162 _state: PhantomData<fn() -> S>,
163 _fields: (Option<CowStr<'a>>, Option<AtUri<'a>>),
164 _lifetime: PhantomData<&'a ()>,
165}
166
167impl<'a> GetCommit<'a> {
168 pub fn new() -> GetCommitBuilder<'a, get_commit_state::Empty> {
170 GetCommitBuilder::new()
171 }
172}
173
174impl<'a> GetCommitBuilder<'a, get_commit_state::Empty> {
175 pub fn new() -> Self {
177 GetCommitBuilder {
178 _state: PhantomData,
179 _fields: (None, None),
180 _lifetime: PhantomData,
181 }
182 }
183}
184
185impl<'a, S> GetCommitBuilder<'a, S>
186where
187 S: get_commit_state::State,
188 S::Ref: get_commit_state::IsUnset,
189{
190 pub fn r#ref(
192 mut self,
193 value: impl Into<CowStr<'a>>,
194 ) -> GetCommitBuilder<'a, get_commit_state::SetRef<S>> {
195 self._fields.0 = Option::Some(value.into());
196 GetCommitBuilder {
197 _state: PhantomData,
198 _fields: self._fields,
199 _lifetime: PhantomData,
200 }
201 }
202}
203
204impl<'a, S> GetCommitBuilder<'a, S>
205where
206 S: get_commit_state::State,
207 S::Repo: get_commit_state::IsUnset,
208{
209 pub fn repo(
211 mut self,
212 value: impl Into<AtUri<'a>>,
213 ) -> GetCommitBuilder<'a, get_commit_state::SetRepo<S>> {
214 self._fields.1 = Option::Some(value.into());
215 GetCommitBuilder {
216 _state: PhantomData,
217 _fields: self._fields,
218 _lifetime: PhantomData,
219 }
220 }
221}
222
223impl<'a, S> GetCommitBuilder<'a, S>
224where
225 S: get_commit_state::State,
226 S::Ref: get_commit_state::IsSet,
227 S::Repo: get_commit_state::IsSet,
228{
229 pub fn build(self) -> GetCommit<'a> {
231 GetCommit {
232 r#ref: self._fields.0.unwrap(),
233 repo: self._fields.1.unwrap(),
234 }
235 }
236}