atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.domain.resolveDocument
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 ResolveDocument<'a> {
19 #[serde(borrow)]
20 pub path: jacquard_common::CowStr<'a>,
21 #[serde(borrow)]
22 pub publication: jacquard_common::types::string::AtUri<'a>,
23}
24
25pub mod resolve_document_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 Publication;
36 type Path;
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 Publication = Unset;
43 type Path = Unset;
44 }
45 ///State transition - sets the `publication` field to Set
46 pub struct SetPublication<S: State = Empty>(PhantomData<fn() -> S>);
47 impl<S: State> sealed::Sealed for SetPublication<S> {}
48 impl<S: State> State for SetPublication<S> {
49 type Publication = Set<members::publication>;
50 type Path = S::Path;
51 }
52 ///State transition - sets the `path` field to Set
53 pub struct SetPath<S: State = Empty>(PhantomData<fn() -> S>);
54 impl<S: State> sealed::Sealed for SetPath<S> {}
55 impl<S: State> State for SetPath<S> {
56 type Publication = S::Publication;
57 type Path = Set<members::path>;
58 }
59 /// Marker types for field names
60 #[allow(non_camel_case_types)]
61 pub mod members {
62 ///Marker type for the `publication` field
63 pub struct publication(());
64 ///Marker type for the `path` field
65 pub struct path(());
66 }
67}
68
69/// Builder for constructing an instance of this type
70pub struct ResolveDocumentBuilder<'a, S: resolve_document_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::types::string::AtUri<'a>>,
75 ),
76 _phantom: ::core::marker::PhantomData<&'a ()>,
77}
78
79impl<'a> ResolveDocument<'a> {
80 /// Create a new builder for this type
81 pub fn new() -> ResolveDocumentBuilder<'a, resolve_document_state::Empty> {
82 ResolveDocumentBuilder::new()
83 }
84}
85
86impl<'a> ResolveDocumentBuilder<'a, resolve_document_state::Empty> {
87 /// Create a new builder with all fields unset
88 pub fn new() -> Self {
89 ResolveDocumentBuilder {
90 _phantom_state: ::core::marker::PhantomData,
91 __unsafe_private_named: (None, None),
92 _phantom: ::core::marker::PhantomData,
93 }
94 }
95}
96
97impl<'a, S> ResolveDocumentBuilder<'a, S>
98where
99 S: resolve_document_state::State,
100 S::Path: resolve_document_state::IsUnset,
101{
102 /// Set the `path` field (required)
103 pub fn path(
104 mut self,
105 value: impl Into<jacquard_common::CowStr<'a>>,
106 ) -> ResolveDocumentBuilder<'a, resolve_document_state::SetPath<S>> {
107 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
108 ResolveDocumentBuilder {
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> ResolveDocumentBuilder<'a, S>
117where
118 S: resolve_document_state::State,
119 S::Publication: resolve_document_state::IsUnset,
120{
121 /// Set the `publication` field (required)
122 pub fn publication(
123 mut self,
124 value: impl Into<jacquard_common::types::string::AtUri<'a>>,
125 ) -> ResolveDocumentBuilder<'a, resolve_document_state::SetPublication<S>> {
126 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
127 ResolveDocumentBuilder {
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> ResolveDocumentBuilder<'a, S>
136where
137 S: resolve_document_state::State,
138 S::Publication: resolve_document_state::IsSet,
139 S::Path: resolve_document_state::IsSet,
140{
141 /// Build the final struct
142 pub fn build(self) -> ResolveDocument<'a> {
143 ResolveDocument {
144 path: self.__unsafe_private_named.0.unwrap(),
145 publication: self.__unsafe_private_named.1.unwrap(),
146 }
147 }
148}
149
150#[jacquard_derive::lexicon]
151#[derive(
152 serde::Serialize,
153 serde::Deserialize,
154 Debug,
155 Clone,
156 PartialEq,
157 Eq,
158 jacquard_derive::IntoStatic
159)]
160#[serde(rename_all = "camelCase")]
161pub struct ResolveDocumentOutput<'a> {
162 #[serde(borrow)]
163 pub document: crate::sh_weaver::domain::DocumentView<'a>,
164}
165
166#[jacquard_derive::open_union]
167#[derive(
168 serde::Serialize,
169 serde::Deserialize,
170 Debug,
171 Clone,
172 PartialEq,
173 Eq,
174 thiserror::Error,
175 miette::Diagnostic,
176 jacquard_derive::IntoStatic
177)]
178#[serde(tag = "error", content = "message")]
179#[serde(bound(deserialize = "'de: 'a"))]
180pub enum ResolveDocumentError<'a> {
181 #[serde(rename = "PublicationNotFound")]
182 PublicationNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
183 #[serde(rename = "DocumentNotFound")]
184 DocumentNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
185}
186
187impl core::fmt::Display for ResolveDocumentError<'_> {
188 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
189 match self {
190 Self::PublicationNotFound(msg) => {
191 write!(f, "PublicationNotFound")?;
192 if let Some(msg) = msg {
193 write!(f, ": {}", msg)?;
194 }
195 Ok(())
196 }
197 Self::DocumentNotFound(msg) => {
198 write!(f, "DocumentNotFound")?;
199 if let Some(msg) = msg {
200 write!(f, ": {}", msg)?;
201 }
202 Ok(())
203 }
204 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
205 }
206 }
207}
208
209/// Response type for
210///sh.weaver.domain.resolveDocument
211pub struct ResolveDocumentResponse;
212impl jacquard_common::xrpc::XrpcResp for ResolveDocumentResponse {
213 const NSID: &'static str = "sh.weaver.domain.resolveDocument";
214 const ENCODING: &'static str = "application/json";
215 type Output<'de> = ResolveDocumentOutput<'de>;
216 type Err<'de> = ResolveDocumentError<'de>;
217}
218
219impl<'a> jacquard_common::xrpc::XrpcRequest for ResolveDocument<'a> {
220 const NSID: &'static str = "sh.weaver.domain.resolveDocument";
221 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
222 type Response = ResolveDocumentResponse;
223}
224
225/// Endpoint type for
226///sh.weaver.domain.resolveDocument
227pub struct ResolveDocumentRequest;
228impl jacquard_common::xrpc::XrpcEndpoint for ResolveDocumentRequest {
229 const PATH: &'static str = "/xrpc/sh.weaver.domain.resolveDocument";
230 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
231 type Request<'de> = ResolveDocument<'de>;
232 type Response = ResolveDocumentResponse;
233}