1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.atwork.getListing
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 GetListing<'a> {
21 #[serde(borrow)]
22 pub repo: jacquard_common::types::ident::AtIdentifier<'a>,
23 #[serde(borrow)]
24 #[builder(into)]
25 pub rkey: jacquard_common::CowStr<'a>,
26}
27
28#[jacquard_derive::lexicon]
29#[derive(
30 serde::Serialize,
31 serde::Deserialize,
32 Debug,
33 Clone,
34 PartialEq,
35 Eq,
36 jacquard_derive::IntoStatic
37)]
38#[serde(rename_all = "camelCase")]
39pub struct GetListingOutput<'a> {
40 /// CID of the listing record
41 #[serde(skip_serializing_if = "std::option::Option::is_none")]
42 #[serde(borrow)]
43 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
44 /// AT-URI of the listing
45 #[serde(borrow)]
46 pub uri: jacquard_common::types::string::AtUri<'a>,
47 /// The job listing record
48 #[serde(borrow)]
49 pub value: crate::place_atwork::listing::Listing<'a>,
50}
51
52#[jacquard_derive::open_union]
53#[derive(
54 serde::Serialize,
55 serde::Deserialize,
56 Debug,
57 Clone,
58 PartialEq,
59 Eq,
60 thiserror::Error,
61 miette::Diagnostic,
62 jacquard_derive::IntoStatic
63)]
64#[serde(tag = "error", content = "message")]
65#[serde(bound(deserialize = "'de: 'a"))]
66pub enum GetListingError<'a> {
67 /// The requested listing does not exist
68 #[serde(rename = "ListingNotFound")]
69 ListingNotFound(std::option::Option<String>),
70 /// Failed to parse the listing data
71 #[serde(rename = "ListingParseFailed")]
72 ListingParseFailed(std::option::Option<String>),
73 /// Failed to fetch the listing from storage
74 #[serde(rename = "ListingFetchFailed")]
75 ListingFetchFailed(std::option::Option<String>),
76}
77
78impl std::fmt::Display for GetListingError<'_> {
79 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80 match self {
81 Self::ListingNotFound(msg) => {
82 write!(f, "ListingNotFound")?;
83 if let Some(msg) = msg {
84 write!(f, ": {}", msg)?;
85 }
86 Ok(())
87 }
88 Self::ListingParseFailed(msg) => {
89 write!(f, "ListingParseFailed")?;
90 if let Some(msg) = msg {
91 write!(f, ": {}", msg)?;
92 }
93 Ok(())
94 }
95 Self::ListingFetchFailed(msg) => {
96 write!(f, "ListingFetchFailed")?;
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
108///place.atwork.getListing
109pub struct GetListingResponse;
110impl jacquard_common::xrpc::XrpcResp for GetListingResponse {
111 const NSID: &'static str = "place.atwork.getListing";
112 const ENCODING: &'static str = "application/json";
113 type Output<'de> = GetListingOutput<'de>;
114 type Err<'de> = GetListingError<'de>;
115}
116
117impl<'a> jacquard_common::xrpc::XrpcRequest for GetListing<'a> {
118 const NSID: &'static str = "place.atwork.getListing";
119 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
120 type Response = GetListingResponse;
121}
122
123///Endpoint type for
124///place.atwork.getListing
125pub struct GetListingRequest;
126impl jacquard_common::xrpc::XrpcEndpoint for GetListingRequest {
127 const PATH: &'static str = "/xrpc/place.atwork.getListing";
128 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
129 type Request<'de> = GetListing<'de>;
130 type Response = GetListingResponse;
131}