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    bon::Builder,
16    jacquard_derive::IntoStatic
17)]
18#[builder(start_fn = new)]
19#[serde(rename_all = "camelCase")]
20pub struct Diff<'a> {
21    #[serde(borrow)]
22    #[builder(into)]
23    pub r#ref: 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 DiffOutput<'a> {}
41#[jacquard_derive::open_union]
42#[derive(
43    serde::Serialize,
44    serde::Deserialize,
45    Debug,
46    Clone,
47    PartialEq,
48    Eq,
49    thiserror::Error,
50    miette::Diagnostic
51)]
52#[serde(tag = "error", content = "message")]
53#[serde(bound(deserialize = "'de: 'a"))]
54pub enum DiffError<'a> {
55    ///Repository not found or access denied
56    #[serde(rename = "RepoNotFound")]
57    RepoNotFound(std::option::Option<String>),
58    ///Git reference not found
59    #[serde(rename = "RefNotFound")]
60    RefNotFound(std::option::Option<String>),
61    ///Invalid request parameters
62    #[serde(rename = "InvalidRequest")]
63    InvalidRequest(std::option::Option<String>),
64}
65
66impl std::fmt::Display for DiffError<'_> {
67    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
68        match self {
69            Self::RepoNotFound(msg) => {
70                write!(f, "RepoNotFound")?;
71                if let Some(msg) = msg {
72                    write!(f, ": {}", msg)?;
73                }
74                Ok(())
75            }
76            Self::RefNotFound(msg) => {
77                write!(f, "RefNotFound")?;
78                if let Some(msg) = msg {
79                    write!(f, ": {}", msg)?;
80                }
81                Ok(())
82            }
83            Self::InvalidRequest(msg) => {
84                write!(f, "InvalidRequest")?;
85                if let Some(msg) = msg {
86                    write!(f, ": {}", msg)?;
87                }
88                Ok(())
89            }
90            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
91        }
92    }
93}
94
95impl jacquard_common::IntoStatic for DiffError<'_> {
96    type Output = DiffError<'static>;
97    fn into_static(self) -> Self::Output {
98        match self {
99            DiffError::RepoNotFound(v) => DiffError::RepoNotFound(v.into_static()),
100            DiffError::RefNotFound(v) => DiffError::RefNotFound(v.into_static()),
101            DiffError::InvalidRequest(v) => DiffError::InvalidRequest(v.into_static()),
102            DiffError::Unknown(v) => DiffError::Unknown(v.into_static()),
103        }
104    }
105}
106
107///Response type for
108///sh.tangled.repo.diff
109pub struct DiffResponse;
110impl jacquard_common::xrpc::XrpcResp for DiffResponse {
111    const NSID: &'static str = "sh.tangled.repo.diff";
112    const ENCODING: &'static str = "*/*";
113    type Output<'de> = DiffOutput<'de>;
114    type Err<'de> = DiffError<'de>;
115}
116
117impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for Diff<'de> {
118    const NSID: &'static str = "sh.tangled.repo.diff";
119    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
120    type Response = DiffResponse;
121}
122
123///Endpoint type for
124///sh.tangled.repo.diff
125pub struct DiffRequest;
126impl jacquard_common::xrpc::XrpcEndpoint for DiffRequest {
127    const PATH: &'static str = "/xrpc/sh.tangled.repo.diff";
128    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
129    type Request<'de> = Diff<'de>;
130    type Response = DiffResponse;
131}