jacquard_api/sh_tangled/repo/
diff.rs

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