atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.bookmark.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod create_bookmark;
9pub mod delete_bookmark;
10pub mod get_bookmarks;
11
12/// Object used to store bookmark data in stash.
13#[jacquard_derive::lexicon]
14#[derive(
15 serde::Serialize,
16 serde::Deserialize,
17 Debug,
18 Clone,
19 PartialEq,
20 Eq,
21 jacquard_derive::IntoStatic
22)]
23#[serde(rename_all = "camelCase")]
24pub struct Bookmark<'a> {
25 /// A strong ref to the record to be bookmarked. Currently, only `app.bsky.feed.post` records are supported.
26 #[serde(borrow)]
27 pub subject: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
28}
29
30pub mod bookmark_state {
31
32 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
33 #[allow(unused)]
34 use ::core::marker::PhantomData;
35 mod sealed {
36 pub trait Sealed {}
37 }
38 /// State trait tracking which required fields have been set
39 pub trait State: sealed::Sealed {
40 type Subject;
41 }
42 /// Empty state - all required fields are unset
43 pub struct Empty(());
44 impl sealed::Sealed for Empty {}
45 impl State for Empty {
46 type Subject = Unset;
47 }
48 ///State transition - sets the `subject` field to Set
49 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
50 impl<S: State> sealed::Sealed for SetSubject<S> {}
51 impl<S: State> State for SetSubject<S> {
52 type Subject = Set<members::subject>;
53 }
54 /// Marker types for field names
55 #[allow(non_camel_case_types)]
56 pub mod members {
57 ///Marker type for the `subject` field
58 pub struct subject(());
59 }
60}
61
62/// Builder for constructing an instance of this type
63pub struct BookmarkBuilder<'a, S: bookmark_state::State> {
64 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
65 __unsafe_private_named: (
66 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
67 ),
68 _phantom: ::core::marker::PhantomData<&'a ()>,
69}
70
71impl<'a> Bookmark<'a> {
72 /// Create a new builder for this type
73 pub fn new() -> BookmarkBuilder<'a, bookmark_state::Empty> {
74 BookmarkBuilder::new()
75 }
76}
77
78impl<'a> BookmarkBuilder<'a, bookmark_state::Empty> {
79 /// Create a new builder with all fields unset
80 pub fn new() -> Self {
81 BookmarkBuilder {
82 _phantom_state: ::core::marker::PhantomData,
83 __unsafe_private_named: (None,),
84 _phantom: ::core::marker::PhantomData,
85 }
86 }
87}
88
89impl<'a, S> BookmarkBuilder<'a, S>
90where
91 S: bookmark_state::State,
92 S::Subject: bookmark_state::IsUnset,
93{
94 /// Set the `subject` field (required)
95 pub fn subject(
96 mut self,
97 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
98 ) -> BookmarkBuilder<'a, bookmark_state::SetSubject<S>> {
99 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
100 BookmarkBuilder {
101 _phantom_state: ::core::marker::PhantomData,
102 __unsafe_private_named: self.__unsafe_private_named,
103 _phantom: ::core::marker::PhantomData,
104 }
105 }
106}
107
108impl<'a, S> BookmarkBuilder<'a, S>
109where
110 S: bookmark_state::State,
111 S::Subject: bookmark_state::IsSet,
112{
113 /// Build the final struct
114 pub fn build(self) -> Bookmark<'a> {
115 Bookmark {
116 subject: self.__unsafe_private_named.0.unwrap(),
117 extra_data: Default::default(),
118 }
119 }
120 /// Build the final struct with custom extra_data
121 pub fn build_with_data(
122 self,
123 extra_data: std::collections::BTreeMap<
124 jacquard_common::smol_str::SmolStr,
125 jacquard_common::types::value::Data<'a>,
126 >,
127 ) -> Bookmark<'a> {
128 Bookmark {
129 subject: self.__unsafe_private_named.0.unwrap(),
130 extra_data: Some(extra_data),
131 }
132 }
133}
134
135fn lexicon_doc_app_bsky_bookmark_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
136 'static,
137> {
138 ::jacquard_lexicon::lexicon::LexiconDoc {
139 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
140 id: ::jacquard_common::CowStr::new_static("app.bsky.bookmark.defs"),
141 revision: None,
142 description: None,
143 defs: {
144 let mut map = ::alloc::collections::BTreeMap::new();
145 map.insert(
146 ::jacquard_common::smol_str::SmolStr::new_static("bookmark"),
147 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
148 description: Some(
149 ::jacquard_common::CowStr::new_static(
150 "Object used to store bookmark data in stash.",
151 ),
152 ),
153 required: Some(
154 vec![::jacquard_common::smol_str::SmolStr::new_static("subject")],
155 ),
156 nullable: None,
157 properties: {
158 #[allow(unused_mut)]
159 let mut map = ::alloc::collections::BTreeMap::new();
160 map.insert(
161 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
162 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
163 description: None,
164 r#ref: ::jacquard_common::CowStr::new_static(
165 "com.atproto.repo.strongRef",
166 ),
167 }),
168 );
169 map
170 },
171 }),
172 );
173 map.insert(
174 ::jacquard_common::smol_str::SmolStr::new_static("bookmarkView"),
175 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
176 description: None,
177 required: Some(
178 vec![
179 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
180 ::jacquard_common::smol_str::SmolStr::new_static("item")
181 ],
182 ),
183 nullable: None,
184 properties: {
185 #[allow(unused_mut)]
186 let mut map = ::alloc::collections::BTreeMap::new();
187 map.insert(
188 ::jacquard_common::smol_str::SmolStr::new_static(
189 "createdAt",
190 ),
191 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
192 description: None,
193 format: Some(
194 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
195 ),
196 default: None,
197 min_length: None,
198 max_length: None,
199 min_graphemes: None,
200 max_graphemes: None,
201 r#enum: None,
202 r#const: None,
203 known_values: None,
204 }),
205 );
206 map.insert(
207 ::jacquard_common::smol_str::SmolStr::new_static("item"),
208 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
209 description: None,
210 refs: vec![
211 ::jacquard_common::CowStr::new_static("app.bsky.feed.defs#blockedPost"),
212 ::jacquard_common::CowStr::new_static("app.bsky.feed.defs#notFoundPost"),
213 ::jacquard_common::CowStr::new_static("app.bsky.feed.defs#postView")
214 ],
215 closed: None,
216 }),
217 );
218 map.insert(
219 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
220 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
221 description: None,
222 r#ref: ::jacquard_common::CowStr::new_static(
223 "com.atproto.repo.strongRef",
224 ),
225 }),
226 );
227 map
228 },
229 }),
230 );
231 map
232 },
233 }
234}
235
236impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Bookmark<'a> {
237 fn nsid() -> &'static str {
238 "app.bsky.bookmark.defs"
239 }
240 fn def_name() -> &'static str {
241 "bookmark"
242 }
243 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
244 lexicon_doc_app_bsky_bookmark_defs()
245 }
246 fn validate(
247 &self,
248 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
249 Ok(())
250 }
251}
252
253#[jacquard_derive::lexicon]
254#[derive(
255 serde::Serialize,
256 serde::Deserialize,
257 Debug,
258 Clone,
259 PartialEq,
260 Eq,
261 jacquard_derive::IntoStatic
262)]
263#[serde(rename_all = "camelCase")]
264pub struct BookmarkView<'a> {
265 #[serde(skip_serializing_if = "std::option::Option::is_none")]
266 pub created_at: std::option::Option<jacquard_common::types::string::Datetime>,
267 #[serde(borrow)]
268 pub item: BookmarkViewItem<'a>,
269 /// A strong ref to the bookmarked record.
270 #[serde(borrow)]
271 pub subject: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
272}
273
274pub mod bookmark_view_state {
275
276 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
277 #[allow(unused)]
278 use ::core::marker::PhantomData;
279 mod sealed {
280 pub trait Sealed {}
281 }
282 /// State trait tracking which required fields have been set
283 pub trait State: sealed::Sealed {
284 type Item;
285 type Subject;
286 }
287 /// Empty state - all required fields are unset
288 pub struct Empty(());
289 impl sealed::Sealed for Empty {}
290 impl State for Empty {
291 type Item = Unset;
292 type Subject = Unset;
293 }
294 ///State transition - sets the `item` field to Set
295 pub struct SetItem<S: State = Empty>(PhantomData<fn() -> S>);
296 impl<S: State> sealed::Sealed for SetItem<S> {}
297 impl<S: State> State for SetItem<S> {
298 type Item = Set<members::item>;
299 type Subject = S::Subject;
300 }
301 ///State transition - sets the `subject` field to Set
302 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
303 impl<S: State> sealed::Sealed for SetSubject<S> {}
304 impl<S: State> State for SetSubject<S> {
305 type Item = S::Item;
306 type Subject = Set<members::subject>;
307 }
308 /// Marker types for field names
309 #[allow(non_camel_case_types)]
310 pub mod members {
311 ///Marker type for the `item` field
312 pub struct item(());
313 ///Marker type for the `subject` field
314 pub struct subject(());
315 }
316}
317
318/// Builder for constructing an instance of this type
319pub struct BookmarkViewBuilder<'a, S: bookmark_view_state::State> {
320 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
321 __unsafe_private_named: (
322 ::core::option::Option<jacquard_common::types::string::Datetime>,
323 ::core::option::Option<BookmarkViewItem<'a>>,
324 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
325 ),
326 _phantom: ::core::marker::PhantomData<&'a ()>,
327}
328
329impl<'a> BookmarkView<'a> {
330 /// Create a new builder for this type
331 pub fn new() -> BookmarkViewBuilder<'a, bookmark_view_state::Empty> {
332 BookmarkViewBuilder::new()
333 }
334}
335
336impl<'a> BookmarkViewBuilder<'a, bookmark_view_state::Empty> {
337 /// Create a new builder with all fields unset
338 pub fn new() -> Self {
339 BookmarkViewBuilder {
340 _phantom_state: ::core::marker::PhantomData,
341 __unsafe_private_named: (None, None, None),
342 _phantom: ::core::marker::PhantomData,
343 }
344 }
345}
346
347impl<'a, S: bookmark_view_state::State> BookmarkViewBuilder<'a, S> {
348 /// Set the `createdAt` field (optional)
349 pub fn created_at(
350 mut self,
351 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
352 ) -> Self {
353 self.__unsafe_private_named.0 = value.into();
354 self
355 }
356 /// Set the `createdAt` field to an Option value (optional)
357 pub fn maybe_created_at(
358 mut self,
359 value: Option<jacquard_common::types::string::Datetime>,
360 ) -> Self {
361 self.__unsafe_private_named.0 = value;
362 self
363 }
364}
365
366impl<'a, S> BookmarkViewBuilder<'a, S>
367where
368 S: bookmark_view_state::State,
369 S::Item: bookmark_view_state::IsUnset,
370{
371 /// Set the `item` field (required)
372 pub fn item(
373 mut self,
374 value: impl Into<BookmarkViewItem<'a>>,
375 ) -> BookmarkViewBuilder<'a, bookmark_view_state::SetItem<S>> {
376 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
377 BookmarkViewBuilder {
378 _phantom_state: ::core::marker::PhantomData,
379 __unsafe_private_named: self.__unsafe_private_named,
380 _phantom: ::core::marker::PhantomData,
381 }
382 }
383}
384
385impl<'a, S> BookmarkViewBuilder<'a, S>
386where
387 S: bookmark_view_state::State,
388 S::Subject: bookmark_view_state::IsUnset,
389{
390 /// Set the `subject` field (required)
391 pub fn subject(
392 mut self,
393 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
394 ) -> BookmarkViewBuilder<'a, bookmark_view_state::SetSubject<S>> {
395 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
396 BookmarkViewBuilder {
397 _phantom_state: ::core::marker::PhantomData,
398 __unsafe_private_named: self.__unsafe_private_named,
399 _phantom: ::core::marker::PhantomData,
400 }
401 }
402}
403
404impl<'a, S> BookmarkViewBuilder<'a, S>
405where
406 S: bookmark_view_state::State,
407 S::Item: bookmark_view_state::IsSet,
408 S::Subject: bookmark_view_state::IsSet,
409{
410 /// Build the final struct
411 pub fn build(self) -> BookmarkView<'a> {
412 BookmarkView {
413 created_at: self.__unsafe_private_named.0,
414 item: self.__unsafe_private_named.1.unwrap(),
415 subject: self.__unsafe_private_named.2.unwrap(),
416 extra_data: Default::default(),
417 }
418 }
419 /// Build the final struct with custom extra_data
420 pub fn build_with_data(
421 self,
422 extra_data: std::collections::BTreeMap<
423 jacquard_common::smol_str::SmolStr,
424 jacquard_common::types::value::Data<'a>,
425 >,
426 ) -> BookmarkView<'a> {
427 BookmarkView {
428 created_at: self.__unsafe_private_named.0,
429 item: self.__unsafe_private_named.1.unwrap(),
430 subject: self.__unsafe_private_named.2.unwrap(),
431 extra_data: Some(extra_data),
432 }
433 }
434}
435
436#[jacquard_derive::open_union]
437#[derive(
438 serde::Serialize,
439 serde::Deserialize,
440 Debug,
441 Clone,
442 PartialEq,
443 Eq,
444 jacquard_derive::IntoStatic
445)]
446#[serde(tag = "$type")]
447#[serde(bound(deserialize = "'de: 'a"))]
448pub enum BookmarkViewItem<'a> {
449 #[serde(rename = "app.bsky.feed.defs#blockedPost")]
450 BlockedPost(Box<crate::app_bsky::feed::BlockedPost<'a>>),
451 #[serde(rename = "app.bsky.feed.defs#notFoundPost")]
452 NotFoundPost(Box<crate::app_bsky::feed::NotFoundPost<'a>>),
453 #[serde(rename = "app.bsky.feed.defs#postView")]
454 PostView(Box<crate::app_bsky::feed::PostView<'a>>),
455}
456
457impl<'a> ::jacquard_lexicon::schema::LexiconSchema for BookmarkView<'a> {
458 fn nsid() -> &'static str {
459 "app.bsky.bookmark.defs"
460 }
461 fn def_name() -> &'static str {
462 "bookmarkView"
463 }
464 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
465 lexicon_doc_app_bsky_bookmark_defs()
466 }
467 fn validate(
468 &self,
469 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
470 Ok(())
471 }
472}