Skip to main content

jacquard_api/sh_tangled/git/temp/
list_commits.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.tangled.git.temp.listCommits
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use core::marker::PhantomData;
10use jacquard_common::CowStr;
11use jacquard_common::deps::bytes::Bytes;
12use jacquard_common::types::string::AtUri;
13use jacquard_derive::{IntoStatic, open_union};
14use serde::{Serialize, Deserialize};
15
16#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
17#[serde(rename_all = "camelCase")]
18pub struct ListCommits<'a> {
19    #[serde(skip_serializing_if = "Option::is_none")]
20    #[serde(borrow)]
21    pub cursor: Option<CowStr<'a>>,
22    ///Defaults to `50`. Min: 1. Max: 100.
23    #[serde(default = "_default_limit")]
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub limit: Option<i64>,
26    #[serde(skip_serializing_if = "Option::is_none")]
27    #[serde(borrow)]
28    pub r#ref: Option<CowStr<'a>>,
29    #[serde(borrow)]
30    pub repo: AtUri<'a>,
31}
32
33
34#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
35#[serde(rename_all = "camelCase")]
36pub struct ListCommitsOutput {
37    pub body: Bytes,
38}
39
40
41#[open_union]
42#[derive(
43    Serialize,
44    Deserialize,
45    Debug,
46    Clone,
47    PartialEq,
48    Eq,
49    thiserror::Error,
50    miette::Diagnostic,
51    IntoStatic
52)]
53
54#[serde(tag = "error", content = "message")]
55#[serde(bound(deserialize = "'de: 'a"))]
56pub enum ListCommitsError<'a> {
57    /// Repository not found or access denied
58    #[serde(rename = "RepoNotFound")]
59    RepoNotFound(Option<CowStr<'a>>),
60    /// Git reference not found
61    #[serde(rename = "RefNotFound")]
62    RefNotFound(Option<CowStr<'a>>),
63    /// Path not found in repository
64    #[serde(rename = "PathNotFound")]
65    PathNotFound(Option<CowStr<'a>>),
66    /// Invalid request parameters
67    #[serde(rename = "InvalidRequest")]
68    InvalidRequest(Option<CowStr<'a>>),
69}
70
71impl core::fmt::Display for ListCommitsError<'_> {
72    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73        match self {
74            Self::RepoNotFound(msg) => {
75                write!(f, "RepoNotFound")?;
76                if let Some(msg) = msg {
77                    write!(f, ": {}", msg)?;
78                }
79                Ok(())
80            }
81            Self::RefNotFound(msg) => {
82                write!(f, "RefNotFound")?;
83                if let Some(msg) = msg {
84                    write!(f, ": {}", msg)?;
85                }
86                Ok(())
87            }
88            Self::PathNotFound(msg) => {
89                write!(f, "PathNotFound")?;
90                if let Some(msg) = msg {
91                    write!(f, ": {}", msg)?;
92                }
93                Ok(())
94            }
95            Self::InvalidRequest(msg) => {
96                write!(f, "InvalidRequest")?;
97                if let Some(msg) = msg {
98                    write!(f, ": {}", msg)?;
99                }
100                Ok(())
101            }
102            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
103        }
104    }
105}
106
107/// Response type for sh.tangled.git.temp.listCommits
108pub struct ListCommitsResponse;
109impl jacquard_common::xrpc::XrpcResp for ListCommitsResponse {
110    const NSID: &'static str = "sh.tangled.git.temp.listCommits";
111    const ENCODING: &'static str = "*/*";
112    type Output<'de> = ListCommitsOutput;
113    type Err<'de> = ListCommitsError<'de>;
114    fn encode_output(
115        output: &Self::Output<'_>,
116    ) -> Result<Vec<u8>, jacquard_common::xrpc::EncodeError> {
117        Ok(output.body.to_vec())
118    }
119    fn decode_output<'de>(
120        body: &'de [u8],
121    ) -> Result<Self::Output<'de>, jacquard_common::error::DecodeError>
122    where
123        Self::Output<'de>: serde::Deserialize<'de>,
124    {
125        Ok(ListCommitsOutput {
126            body: jacquard_common::deps::bytes::Bytes::copy_from_slice(body),
127        })
128    }
129}
130
131impl<'a> jacquard_common::xrpc::XrpcRequest for ListCommits<'a> {
132    const NSID: &'static str = "sh.tangled.git.temp.listCommits";
133    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
134    type Response = ListCommitsResponse;
135}
136
137/// Endpoint type for sh.tangled.git.temp.listCommits
138pub struct ListCommitsRequest;
139impl jacquard_common::xrpc::XrpcEndpoint for ListCommitsRequest {
140    const PATH: &'static str = "/xrpc/sh.tangled.git.temp.listCommits";
141    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
142    type Request<'de> = ListCommits<'de>;
143    type Response = ListCommitsResponse;
144}
145
146fn _default_limit() -> Option<i64> {
147    Some(50i64)
148}
149
150pub mod list_commits_state {
151
152    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
153    #[allow(unused)]
154    use ::core::marker::PhantomData;
155    mod sealed {
156        pub trait Sealed {}
157    }
158    /// State trait tracking which required fields have been set
159    pub trait State: sealed::Sealed {
160        type Repo;
161    }
162    /// Empty state - all required fields are unset
163    pub struct Empty(());
164    impl sealed::Sealed for Empty {}
165    impl State for Empty {
166        type Repo = Unset;
167    }
168    ///State transition - sets the `repo` field to Set
169    pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
170    impl<S: State> sealed::Sealed for SetRepo<S> {}
171    impl<S: State> State for SetRepo<S> {
172        type Repo = Set<members::repo>;
173    }
174    /// Marker types for field names
175    #[allow(non_camel_case_types)]
176    pub mod members {
177        ///Marker type for the `repo` field
178        pub struct repo(());
179    }
180}
181
182/// Builder for constructing an instance of this type
183pub struct ListCommitsBuilder<'a, S: list_commits_state::State> {
184    _state: PhantomData<fn() -> S>,
185    _fields: (Option<CowStr<'a>>, Option<i64>, Option<CowStr<'a>>, Option<AtUri<'a>>),
186    _lifetime: PhantomData<&'a ()>,
187}
188
189impl<'a> ListCommits<'a> {
190    /// Create a new builder for this type
191    pub fn new() -> ListCommitsBuilder<'a, list_commits_state::Empty> {
192        ListCommitsBuilder::new()
193    }
194}
195
196impl<'a> ListCommitsBuilder<'a, list_commits_state::Empty> {
197    /// Create a new builder with all fields unset
198    pub fn new() -> Self {
199        ListCommitsBuilder {
200            _state: PhantomData,
201            _fields: (None, None, None, None),
202            _lifetime: PhantomData,
203        }
204    }
205}
206
207impl<'a, S: list_commits_state::State> ListCommitsBuilder<'a, S> {
208    /// Set the `cursor` field (optional)
209    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
210        self._fields.0 = value.into();
211        self
212    }
213    /// Set the `cursor` field to an Option value (optional)
214    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
215        self._fields.0 = value;
216        self
217    }
218}
219
220impl<'a, S: list_commits_state::State> ListCommitsBuilder<'a, S> {
221    /// Set the `limit` field (optional)
222    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
223        self._fields.1 = value.into();
224        self
225    }
226    /// Set the `limit` field to an Option value (optional)
227    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
228        self._fields.1 = value;
229        self
230    }
231}
232
233impl<'a, S: list_commits_state::State> ListCommitsBuilder<'a, S> {
234    /// Set the `ref` field (optional)
235    pub fn r#ref(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
236        self._fields.2 = value.into();
237        self
238    }
239    /// Set the `ref` field to an Option value (optional)
240    pub fn maybe_ref(mut self, value: Option<CowStr<'a>>) -> Self {
241        self._fields.2 = value;
242        self
243    }
244}
245
246impl<'a, S> ListCommitsBuilder<'a, S>
247where
248    S: list_commits_state::State,
249    S::Repo: list_commits_state::IsUnset,
250{
251    /// Set the `repo` field (required)
252    pub fn repo(
253        mut self,
254        value: impl Into<AtUri<'a>>,
255    ) -> ListCommitsBuilder<'a, list_commits_state::SetRepo<S>> {
256        self._fields.3 = Option::Some(value.into());
257        ListCommitsBuilder {
258            _state: PhantomData,
259            _fields: self._fields,
260            _lifetime: PhantomData,
261        }
262    }
263}
264
265impl<'a, S> ListCommitsBuilder<'a, S>
266where
267    S: list_commits_state::State,
268    S::Repo: list_commits_state::IsSet,
269{
270    /// Build the final struct
271    pub fn build(self) -> ListCommits<'a> {
272        ListCommits {
273            cursor: self._fields.0,
274            limit: self._fields.1,
275            r#ref: self._fields.2,
276            repo: self._fields.3.unwrap(),
277        }
278    }
279}