atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: blog.pckt.post
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 Post<'a> {
20 #[serde(borrow)]
21 pub blocks: jacquard_common::types::value::Data<'a>,
22 #[serde(borrow)]
23 pub blog: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 #[serde(borrow)]
26 pub body_plain: std::option::Option<jacquard_common::CowStr<'a>>,
27 #[serde(skip_serializing_if = "std::option::Option::is_none")]
28 #[serde(borrow)]
29 pub cover: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
30 #[serde(skip_serializing_if = "std::option::Option::is_none")]
31 #[serde(borrow)]
32 pub images: std::option::Option<Vec<jacquard_common::types::blob::BlobRef<'a>>>,
33 #[serde(skip_serializing_if = "std::option::Option::is_none")]
34 pub published_at: std::option::Option<jacquard_common::types::string::Datetime>,
35 #[serde(skip_serializing_if = "std::option::Option::is_none")]
36 #[serde(borrow)]
37 pub tags: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
38 #[serde(borrow)]
39 pub title: jacquard_common::CowStr<'a>,
40 #[serde(skip_serializing_if = "std::option::Option::is_none")]
41 pub updated_at: std::option::Option<jacquard_common::types::string::Datetime>,
42 #[serde(borrow)]
43 pub url: jacquard_common::types::string::Uri<'a>,
44}
45
46pub mod post_state {
47
48 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
49 #[allow(unused)]
50 use ::core::marker::PhantomData;
51 mod sealed {
52 pub trait Sealed {}
53 }
54 /// State trait tracking which required fields have been set
55 pub trait State: sealed::Sealed {
56 type Title;
57 type Blocks;
58 type Blog;
59 type Url;
60 }
61 /// Empty state - all required fields are unset
62 pub struct Empty(());
63 impl sealed::Sealed for Empty {}
64 impl State for Empty {
65 type Title = Unset;
66 type Blocks = Unset;
67 type Blog = Unset;
68 type Url = Unset;
69 }
70 ///State transition - sets the `title` field to Set
71 pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
72 impl<S: State> sealed::Sealed for SetTitle<S> {}
73 impl<S: State> State for SetTitle<S> {
74 type Title = Set<members::title>;
75 type Blocks = S::Blocks;
76 type Blog = S::Blog;
77 type Url = S::Url;
78 }
79 ///State transition - sets the `blocks` field to Set
80 pub struct SetBlocks<S: State = Empty>(PhantomData<fn() -> S>);
81 impl<S: State> sealed::Sealed for SetBlocks<S> {}
82 impl<S: State> State for SetBlocks<S> {
83 type Title = S::Title;
84 type Blocks = Set<members::blocks>;
85 type Blog = S::Blog;
86 type Url = S::Url;
87 }
88 ///State transition - sets the `blog` field to Set
89 pub struct SetBlog<S: State = Empty>(PhantomData<fn() -> S>);
90 impl<S: State> sealed::Sealed for SetBlog<S> {}
91 impl<S: State> State for SetBlog<S> {
92 type Title = S::Title;
93 type Blocks = S::Blocks;
94 type Blog = Set<members::blog>;
95 type Url = S::Url;
96 }
97 ///State transition - sets the `url` field to Set
98 pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
99 impl<S: State> sealed::Sealed for SetUrl<S> {}
100 impl<S: State> State for SetUrl<S> {
101 type Title = S::Title;
102 type Blocks = S::Blocks;
103 type Blog = S::Blog;
104 type Url = Set<members::url>;
105 }
106 /// Marker types for field names
107 #[allow(non_camel_case_types)]
108 pub mod members {
109 ///Marker type for the `title` field
110 pub struct title(());
111 ///Marker type for the `blocks` field
112 pub struct blocks(());
113 ///Marker type for the `blog` field
114 pub struct blog(());
115 ///Marker type for the `url` field
116 pub struct url(());
117 }
118}
119
120/// Builder for constructing an instance of this type
121pub struct PostBuilder<'a, S: post_state::State> {
122 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
123 __unsafe_private_named: (
124 ::core::option::Option<jacquard_common::types::value::Data<'a>>,
125 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
126 ::core::option::Option<jacquard_common::CowStr<'a>>,
127 ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
128 ::core::option::Option<Vec<jacquard_common::types::blob::BlobRef<'a>>>,
129 ::core::option::Option<jacquard_common::types::string::Datetime>,
130 ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
131 ::core::option::Option<jacquard_common::CowStr<'a>>,
132 ::core::option::Option<jacquard_common::types::string::Datetime>,
133 ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
134 ),
135 _phantom: ::core::marker::PhantomData<&'a ()>,
136}
137
138impl<'a> Post<'a> {
139 /// Create a new builder for this type
140 pub fn new() -> PostBuilder<'a, post_state::Empty> {
141 PostBuilder::new()
142 }
143}
144
145impl<'a> PostBuilder<'a, post_state::Empty> {
146 /// Create a new builder with all fields unset
147 pub fn new() -> Self {
148 PostBuilder {
149 _phantom_state: ::core::marker::PhantomData,
150 __unsafe_private_named: (
151 None,
152 None,
153 None,
154 None,
155 None,
156 None,
157 None,
158 None,
159 None,
160 None,
161 ),
162 _phantom: ::core::marker::PhantomData,
163 }
164 }
165}
166
167impl<'a, S> PostBuilder<'a, S>
168where
169 S: post_state::State,
170 S::Blocks: post_state::IsUnset,
171{
172 /// Set the `blocks` field (required)
173 pub fn blocks(
174 mut self,
175 value: impl Into<jacquard_common::types::value::Data<'a>>,
176 ) -> PostBuilder<'a, post_state::SetBlocks<S>> {
177 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
178 PostBuilder {
179 _phantom_state: ::core::marker::PhantomData,
180 __unsafe_private_named: self.__unsafe_private_named,
181 _phantom: ::core::marker::PhantomData,
182 }
183 }
184}
185
186impl<'a, S> PostBuilder<'a, S>
187where
188 S: post_state::State,
189 S::Blog: post_state::IsUnset,
190{
191 /// Set the `blog` field (required)
192 pub fn blog(
193 mut self,
194 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
195 ) -> PostBuilder<'a, post_state::SetBlog<S>> {
196 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
197 PostBuilder {
198 _phantom_state: ::core::marker::PhantomData,
199 __unsafe_private_named: self.__unsafe_private_named,
200 _phantom: ::core::marker::PhantomData,
201 }
202 }
203}
204
205impl<'a, S: post_state::State> PostBuilder<'a, S> {
206 /// Set the `bodyPlain` field (optional)
207 pub fn body_plain(
208 mut self,
209 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
210 ) -> Self {
211 self.__unsafe_private_named.2 = value.into();
212 self
213 }
214 /// Set the `bodyPlain` field to an Option value (optional)
215 pub fn maybe_body_plain(
216 mut self,
217 value: Option<jacquard_common::CowStr<'a>>,
218 ) -> Self {
219 self.__unsafe_private_named.2 = value;
220 self
221 }
222}
223
224impl<'a, S: post_state::State> PostBuilder<'a, S> {
225 /// Set the `cover` field (optional)
226 pub fn cover(
227 mut self,
228 value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
229 ) -> Self {
230 self.__unsafe_private_named.3 = value.into();
231 self
232 }
233 /// Set the `cover` field to an Option value (optional)
234 pub fn maybe_cover(
235 mut self,
236 value: Option<jacquard_common::types::blob::BlobRef<'a>>,
237 ) -> Self {
238 self.__unsafe_private_named.3 = value;
239 self
240 }
241}
242
243impl<'a, S: post_state::State> PostBuilder<'a, S> {
244 /// Set the `images` field (optional)
245 pub fn images(
246 mut self,
247 value: impl Into<Option<Vec<jacquard_common::types::blob::BlobRef<'a>>>>,
248 ) -> Self {
249 self.__unsafe_private_named.4 = value.into();
250 self
251 }
252 /// Set the `images` field to an Option value (optional)
253 pub fn maybe_images(
254 mut self,
255 value: Option<Vec<jacquard_common::types::blob::BlobRef<'a>>>,
256 ) -> Self {
257 self.__unsafe_private_named.4 = value;
258 self
259 }
260}
261
262impl<'a, S: post_state::State> PostBuilder<'a, S> {
263 /// Set the `publishedAt` field (optional)
264 pub fn published_at(
265 mut self,
266 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
267 ) -> Self {
268 self.__unsafe_private_named.5 = value.into();
269 self
270 }
271 /// Set the `publishedAt` field to an Option value (optional)
272 pub fn maybe_published_at(
273 mut self,
274 value: Option<jacquard_common::types::string::Datetime>,
275 ) -> Self {
276 self.__unsafe_private_named.5 = value;
277 self
278 }
279}
280
281impl<'a, S: post_state::State> PostBuilder<'a, S> {
282 /// Set the `tags` field (optional)
283 pub fn tags(
284 mut self,
285 value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
286 ) -> Self {
287 self.__unsafe_private_named.6 = value.into();
288 self
289 }
290 /// Set the `tags` field to an Option value (optional)
291 pub fn maybe_tags(
292 mut self,
293 value: Option<Vec<jacquard_common::CowStr<'a>>>,
294 ) -> Self {
295 self.__unsafe_private_named.6 = value;
296 self
297 }
298}
299
300impl<'a, S> PostBuilder<'a, S>
301where
302 S: post_state::State,
303 S::Title: post_state::IsUnset,
304{
305 /// Set the `title` field (required)
306 pub fn title(
307 mut self,
308 value: impl Into<jacquard_common::CowStr<'a>>,
309 ) -> PostBuilder<'a, post_state::SetTitle<S>> {
310 self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
311 PostBuilder {
312 _phantom_state: ::core::marker::PhantomData,
313 __unsafe_private_named: self.__unsafe_private_named,
314 _phantom: ::core::marker::PhantomData,
315 }
316 }
317}
318
319impl<'a, S: post_state::State> PostBuilder<'a, S> {
320 /// Set the `updatedAt` field (optional)
321 pub fn updated_at(
322 mut self,
323 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
324 ) -> Self {
325 self.__unsafe_private_named.8 = value.into();
326 self
327 }
328 /// Set the `updatedAt` field to an Option value (optional)
329 pub fn maybe_updated_at(
330 mut self,
331 value: Option<jacquard_common::types::string::Datetime>,
332 ) -> Self {
333 self.__unsafe_private_named.8 = value;
334 self
335 }
336}
337
338impl<'a, S> PostBuilder<'a, S>
339where
340 S: post_state::State,
341 S::Url: post_state::IsUnset,
342{
343 /// Set the `url` field (required)
344 pub fn url(
345 mut self,
346 value: impl Into<jacquard_common::types::string::Uri<'a>>,
347 ) -> PostBuilder<'a, post_state::SetUrl<S>> {
348 self.__unsafe_private_named.9 = ::core::option::Option::Some(value.into());
349 PostBuilder {
350 _phantom_state: ::core::marker::PhantomData,
351 __unsafe_private_named: self.__unsafe_private_named,
352 _phantom: ::core::marker::PhantomData,
353 }
354 }
355}
356
357impl<'a, S> PostBuilder<'a, S>
358where
359 S: post_state::State,
360 S::Title: post_state::IsSet,
361 S::Blocks: post_state::IsSet,
362 S::Blog: post_state::IsSet,
363 S::Url: post_state::IsSet,
364{
365 /// Build the final struct
366 pub fn build(self) -> Post<'a> {
367 Post {
368 blocks: self.__unsafe_private_named.0.unwrap(),
369 blog: self.__unsafe_private_named.1.unwrap(),
370 body_plain: self.__unsafe_private_named.2,
371 cover: self.__unsafe_private_named.3,
372 images: self.__unsafe_private_named.4,
373 published_at: self.__unsafe_private_named.5,
374 tags: self.__unsafe_private_named.6,
375 title: self.__unsafe_private_named.7.unwrap(),
376 updated_at: self.__unsafe_private_named.8,
377 url: self.__unsafe_private_named.9.unwrap(),
378 extra_data: Default::default(),
379 }
380 }
381 /// Build the final struct with custom extra_data
382 pub fn build_with_data(
383 self,
384 extra_data: std::collections::BTreeMap<
385 jacquard_common::smol_str::SmolStr,
386 jacquard_common::types::value::Data<'a>,
387 >,
388 ) -> Post<'a> {
389 Post {
390 blocks: self.__unsafe_private_named.0.unwrap(),
391 blog: self.__unsafe_private_named.1.unwrap(),
392 body_plain: self.__unsafe_private_named.2,
393 cover: self.__unsafe_private_named.3,
394 images: self.__unsafe_private_named.4,
395 published_at: self.__unsafe_private_named.5,
396 tags: self.__unsafe_private_named.6,
397 title: self.__unsafe_private_named.7.unwrap(),
398 updated_at: self.__unsafe_private_named.8,
399 url: self.__unsafe_private_named.9.unwrap(),
400 extra_data: Some(extra_data),
401 }
402 }
403}
404
405impl<'a> Post<'a> {
406 pub fn uri(
407 uri: impl Into<jacquard_common::CowStr<'a>>,
408 ) -> Result<
409 jacquard_common::types::uri::RecordUri<'a, PostRecord>,
410 jacquard_common::types::uri::UriError,
411 > {
412 jacquard_common::types::uri::RecordUri::try_from_uri(
413 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
414 )
415 }
416}
417
418/// Typed wrapper for GetRecord response with this collection's record type.
419#[derive(
420 serde::Serialize,
421 serde::Deserialize,
422 Debug,
423 Clone,
424 PartialEq,
425 Eq,
426 jacquard_derive::IntoStatic
427)]
428#[serde(rename_all = "camelCase")]
429pub struct PostGetRecordOutput<'a> {
430 #[serde(skip_serializing_if = "std::option::Option::is_none")]
431 #[serde(borrow)]
432 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
433 #[serde(borrow)]
434 pub uri: jacquard_common::types::string::AtUri<'a>,
435 #[serde(borrow)]
436 pub value: Post<'a>,
437}
438
439impl From<PostGetRecordOutput<'_>> for Post<'_> {
440 fn from(output: PostGetRecordOutput<'_>) -> Self {
441 use jacquard_common::IntoStatic;
442 output.value.into_static()
443 }
444}
445
446impl jacquard_common::types::collection::Collection for Post<'_> {
447 const NSID: &'static str = "blog.pckt.post";
448 type Record = PostRecord;
449}
450
451/// Marker type for deserializing records from this collection.
452#[derive(Debug, serde::Serialize, serde::Deserialize)]
453pub struct PostRecord;
454impl jacquard_common::xrpc::XrpcResp for PostRecord {
455 const NSID: &'static str = "blog.pckt.post";
456 const ENCODING: &'static str = "application/json";
457 type Output<'de> = PostGetRecordOutput<'de>;
458 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
459}
460
461impl jacquard_common::types::collection::Collection for PostRecord {
462 const NSID: &'static str = "blog.pckt.post";
463 type Record = PostRecord;
464}
465
466impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Post<'a> {
467 fn nsid() -> &'static str {
468 "blog.pckt.post"
469 }
470 fn def_name() -> &'static str {
471 "main"
472 }
473 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
474 lexicon_doc_blog_pckt_post()
475 }
476 fn validate(
477 &self,
478 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
479 Ok(())
480 }
481}
482
483fn lexicon_doc_blog_pckt_post() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
484 ::jacquard_lexicon::lexicon::LexiconDoc {
485 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
486 id: ::jacquard_common::CowStr::new_static("blog.pckt.post"),
487 revision: None,
488 description: None,
489 defs: {
490 let mut map = ::alloc::collections::BTreeMap::new();
491 map.insert(
492 ::jacquard_common::smol_str::SmolStr::new_static("main"),
493 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
494 description: None,
495 key: Some(::jacquard_common::CowStr::new_static("tid")),
496 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
497 description: None,
498 required: Some(
499 vec![
500 ::jacquard_common::smol_str::SmolStr::new_static("title"),
501 ::jacquard_common::smol_str::SmolStr::new_static("blocks"),
502 ::jacquard_common::smol_str::SmolStr::new_static("url"),
503 ::jacquard_common::smol_str::SmolStr::new_static("blog")
504 ],
505 ),
506 nullable: None,
507 properties: {
508 #[allow(unused_mut)]
509 let mut map = ::alloc::collections::BTreeMap::new();
510 map.insert(
511 ::jacquard_common::smol_str::SmolStr::new_static("blocks"),
512 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
513 description: None,
514 refs: vec![],
515 closed: Some(false),
516 }),
517 );
518 map.insert(
519 ::jacquard_common::smol_str::SmolStr::new_static("blog"),
520 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
521 description: None,
522 r#ref: ::jacquard_common::CowStr::new_static(
523 "com.atproto.repo.strongRef",
524 ),
525 }),
526 );
527 map.insert(
528 ::jacquard_common::smol_str::SmolStr::new_static(
529 "bodyPlain",
530 ),
531 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
532 description: None,
533 format: None,
534 default: None,
535 min_length: None,
536 max_length: None,
537 min_graphemes: None,
538 max_graphemes: None,
539 r#enum: None,
540 r#const: None,
541 known_values: None,
542 }),
543 );
544 map.insert(
545 ::jacquard_common::smol_str::SmolStr::new_static("cover"),
546 ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
547 description: None,
548 accept: None,
549 max_size: None,
550 }),
551 );
552 map.insert(
553 ::jacquard_common::smol_str::SmolStr::new_static("images"),
554 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
555 description: None,
556 items: ::jacquard_lexicon::lexicon::LexArrayItem::Blob(::jacquard_lexicon::lexicon::LexBlob {
557 description: None,
558 accept: None,
559 max_size: None,
560 }),
561 min_length: None,
562 max_length: None,
563 }),
564 );
565 map.insert(
566 ::jacquard_common::smol_str::SmolStr::new_static(
567 "publishedAt",
568 ),
569 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
570 description: None,
571 format: Some(
572 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
573 ),
574 default: None,
575 min_length: None,
576 max_length: None,
577 min_graphemes: None,
578 max_graphemes: None,
579 r#enum: None,
580 r#const: None,
581 known_values: None,
582 }),
583 );
584 map.insert(
585 ::jacquard_common::smol_str::SmolStr::new_static("tags"),
586 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
587 description: None,
588 items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
589 description: None,
590 format: None,
591 default: None,
592 min_length: None,
593 max_length: None,
594 min_graphemes: None,
595 max_graphemes: None,
596 r#enum: None,
597 r#const: None,
598 known_values: None,
599 }),
600 min_length: None,
601 max_length: None,
602 }),
603 );
604 map.insert(
605 ::jacquard_common::smol_str::SmolStr::new_static("title"),
606 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
607 description: None,
608 format: None,
609 default: None,
610 min_length: None,
611 max_length: None,
612 min_graphemes: None,
613 max_graphemes: None,
614 r#enum: None,
615 r#const: None,
616 known_values: None,
617 }),
618 );
619 map.insert(
620 ::jacquard_common::smol_str::SmolStr::new_static(
621 "updatedAt",
622 ),
623 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
624 description: None,
625 format: Some(
626 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
627 ),
628 default: None,
629 min_length: None,
630 max_length: None,
631 min_graphemes: None,
632 max_graphemes: None,
633 r#enum: None,
634 r#const: None,
635 known_values: None,
636 }),
637 );
638 map.insert(
639 ::jacquard_common::smol_str::SmolStr::new_static("url"),
640 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
641 description: None,
642 format: Some(
643 ::jacquard_lexicon::lexicon::LexStringFormat::Uri,
644 ),
645 default: None,
646 min_length: None,
647 max_length: None,
648 min_graphemes: None,
649 max_graphemes: None,
650 r#enum: None,
651 r#const: None,
652 known_values: None,
653 }),
654 );
655 map
656 },
657 }),
658 }),
659 );
660 map
661 },
662 }
663}