atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: blog.pckt.document
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10 serde::Serialize,
11 serde::Deserialize,
12 Debug,
13 Clone,
14 PartialEq,
15 Eq,
16 jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct Document<'a> {
20 #[serde(borrow)]
21 pub document: crate::site_standard::document::Document<'a>,
22}
23
24pub mod document_state {
25
26 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
27 #[allow(unused)]
28 use ::core::marker::PhantomData;
29 mod sealed {
30 pub trait Sealed {}
31 }
32 /// State trait tracking which required fields have been set
33 pub trait State: sealed::Sealed {
34 type Document;
35 }
36 /// Empty state - all required fields are unset
37 pub struct Empty(());
38 impl sealed::Sealed for Empty {}
39 impl State for Empty {
40 type Document = Unset;
41 }
42 ///State transition - sets the `document` field to Set
43 pub struct SetDocument<S: State = Empty>(PhantomData<fn() -> S>);
44 impl<S: State> sealed::Sealed for SetDocument<S> {}
45 impl<S: State> State for SetDocument<S> {
46 type Document = Set<members::document>;
47 }
48 /// Marker types for field names
49 #[allow(non_camel_case_types)]
50 pub mod members {
51 ///Marker type for the `document` field
52 pub struct document(());
53 }
54}
55
56/// Builder for constructing an instance of this type
57pub struct DocumentBuilder<'a, S: document_state::State> {
58 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
59 __unsafe_private_named: (
60 ::core::option::Option<crate::site_standard::document::Document<'a>>,
61 ),
62 _phantom: ::core::marker::PhantomData<&'a ()>,
63}
64
65impl<'a> Document<'a> {
66 /// Create a new builder for this type
67 pub fn new() -> DocumentBuilder<'a, document_state::Empty> {
68 DocumentBuilder::new()
69 }
70}
71
72impl<'a> DocumentBuilder<'a, document_state::Empty> {
73 /// Create a new builder with all fields unset
74 pub fn new() -> Self {
75 DocumentBuilder {
76 _phantom_state: ::core::marker::PhantomData,
77 __unsafe_private_named: (None,),
78 _phantom: ::core::marker::PhantomData,
79 }
80 }
81}
82
83impl<'a, S> DocumentBuilder<'a, S>
84where
85 S: document_state::State,
86 S::Document: document_state::IsUnset,
87{
88 /// Set the `document` field (required)
89 pub fn document(
90 mut self,
91 value: impl Into<crate::site_standard::document::Document<'a>>,
92 ) -> DocumentBuilder<'a, document_state::SetDocument<S>> {
93 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
94 DocumentBuilder {
95 _phantom_state: ::core::marker::PhantomData,
96 __unsafe_private_named: self.__unsafe_private_named,
97 _phantom: ::core::marker::PhantomData,
98 }
99 }
100}
101
102impl<'a, S> DocumentBuilder<'a, S>
103where
104 S: document_state::State,
105 S::Document: document_state::IsSet,
106{
107 /// Build the final struct
108 pub fn build(self) -> Document<'a> {
109 Document {
110 document: self.__unsafe_private_named.0.unwrap(),
111 extra_data: Default::default(),
112 }
113 }
114 /// Build the final struct with custom extra_data
115 pub fn build_with_data(
116 self,
117 extra_data: std::collections::BTreeMap<
118 jacquard_common::smol_str::SmolStr,
119 jacquard_common::types::value::Data<'a>,
120 >,
121 ) -> Document<'a> {
122 Document {
123 document: self.__unsafe_private_named.0.unwrap(),
124 extra_data: Some(extra_data),
125 }
126 }
127}
128
129impl<'a> Document<'a> {
130 pub fn uri(
131 uri: impl Into<jacquard_common::CowStr<'a>>,
132 ) -> Result<
133 jacquard_common::types::uri::RecordUri<'a, DocumentRecord>,
134 jacquard_common::types::uri::UriError,
135 > {
136 jacquard_common::types::uri::RecordUri::try_from_uri(
137 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
138 )
139 }
140}
141
142/// Typed wrapper for GetRecord response with this collection's record type.
143#[derive(
144 serde::Serialize,
145 serde::Deserialize,
146 Debug,
147 Clone,
148 PartialEq,
149 Eq,
150 jacquard_derive::IntoStatic
151)]
152#[serde(rename_all = "camelCase")]
153pub struct DocumentGetRecordOutput<'a> {
154 #[serde(skip_serializing_if = "std::option::Option::is_none")]
155 #[serde(borrow)]
156 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
157 #[serde(borrow)]
158 pub uri: jacquard_common::types::string::AtUri<'a>,
159 #[serde(borrow)]
160 pub value: Document<'a>,
161}
162
163impl From<DocumentGetRecordOutput<'_>> for Document<'_> {
164 fn from(output: DocumentGetRecordOutput<'_>) -> Self {
165 use jacquard_common::IntoStatic;
166 output.value.into_static()
167 }
168}
169
170impl jacquard_common::types::collection::Collection for Document<'_> {
171 const NSID: &'static str = "blog.pckt.document";
172 type Record = DocumentRecord;
173}
174
175/// Marker type for deserializing records from this collection.
176#[derive(Debug, serde::Serialize, serde::Deserialize)]
177pub struct DocumentRecord;
178impl jacquard_common::xrpc::XrpcResp for DocumentRecord {
179 const NSID: &'static str = "blog.pckt.document";
180 const ENCODING: &'static str = "application/json";
181 type Output<'de> = DocumentGetRecordOutput<'de>;
182 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
183}
184
185impl jacquard_common::types::collection::Collection for DocumentRecord {
186 const NSID: &'static str = "blog.pckt.document";
187 type Record = DocumentRecord;
188}
189
190impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Document<'a> {
191 fn nsid() -> &'static str {
192 "blog.pckt.document"
193 }
194 fn def_name() -> &'static str {
195 "main"
196 }
197 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
198 lexicon_doc_blog_pckt_document()
199 }
200 fn validate(
201 &self,
202 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
203 Ok(())
204 }
205}
206
207fn lexicon_doc_blog_pckt_document() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
208 ::jacquard_lexicon::lexicon::LexiconDoc {
209 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
210 id: ::jacquard_common::CowStr::new_static("blog.pckt.document"),
211 revision: None,
212 description: None,
213 defs: {
214 let mut map = ::alloc::collections::BTreeMap::new();
215 map.insert(
216 ::jacquard_common::smol_str::SmolStr::new_static("main"),
217 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
218 description: None,
219 key: Some(::jacquard_common::CowStr::new_static("tid")),
220 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
221 description: None,
222 required: Some(
223 vec![
224 ::jacquard_common::smol_str::SmolStr::new_static("document")
225 ],
226 ),
227 nullable: None,
228 properties: {
229 #[allow(unused_mut)]
230 let mut map = ::alloc::collections::BTreeMap::new();
231 map.insert(
232 ::jacquard_common::smol_str::SmolStr::new_static(
233 "document",
234 ),
235 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
236 description: None,
237 r#ref: ::jacquard_common::CowStr::new_static(
238 "site.standard.document",
239 ),
240 }),
241 );
242 map
243 },
244 }),
245 }),
246 );
247 map
248 },
249 }
250}