1pub mod create_bookmark;
9pub mod delete_bookmark;
10pub mod get_bookmarks;
11
12
13#[allow(unused_imports)]
14use alloc::collections::BTreeMap;
15
16#[allow(unused_imports)]
17use core::marker::PhantomData;
18
19#[allow(unused_imports)]
20use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
21use jacquard_common::types::string::Datetime;
22use jacquard_derive::{IntoStatic, lexicon, open_union};
23use jacquard_lexicon::lexicon::LexiconDoc;
24use jacquard_lexicon::schema::LexiconSchema;
25
26#[allow(unused_imports)]
27use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
28use serde::{Serialize, Deserialize};
29use crate::app_bsky::feed::BlockedPost;
30use crate::app_bsky::feed::NotFoundPost;
31use crate::app_bsky::feed::PostView;
32use crate::com_atproto::repo::strong_ref::StrongRef;
33#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase")]
38pub struct Bookmark<'a> {
39 #[serde(borrow)]
41 pub subject: StrongRef<'a>,
42}
43
44
45#[lexicon]
46#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
47#[serde(rename_all = "camelCase")]
48pub struct BookmarkView<'a> {
49 #[serde(skip_serializing_if = "Option::is_none")]
50 pub created_at: Option<Datetime>,
51 #[serde(borrow)]
52 pub item: BookmarkViewItem<'a>,
53 #[serde(borrow)]
55 pub subject: StrongRef<'a>,
56}
57
58
59#[open_union]
60#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
61#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
62pub enum BookmarkViewItem<'a> {
63 #[serde(rename = "app.bsky.feed.defs#blockedPost")]
64 BlockedPost(Box<BlockedPost<'a>>),
65 #[serde(rename = "app.bsky.feed.defs#notFoundPost")]
66 NotFoundPost(Box<NotFoundPost<'a>>),
67 #[serde(rename = "app.bsky.feed.defs#postView")]
68 PostView(Box<PostView<'a>>),
69}
70
71impl<'a> LexiconSchema for Bookmark<'a> {
72 fn nsid() -> &'static str {
73 "app.bsky.bookmark.defs"
74 }
75 fn def_name() -> &'static str {
76 "bookmark"
77 }
78 fn lexicon_doc() -> LexiconDoc<'static> {
79 lexicon_doc_app_bsky_bookmark_defs()
80 }
81 fn validate(&self) -> Result<(), ConstraintError> {
82 Ok(())
83 }
84}
85
86impl<'a> LexiconSchema for BookmarkView<'a> {
87 fn nsid() -> &'static str {
88 "app.bsky.bookmark.defs"
89 }
90 fn def_name() -> &'static str {
91 "bookmarkView"
92 }
93 fn lexicon_doc() -> LexiconDoc<'static> {
94 lexicon_doc_app_bsky_bookmark_defs()
95 }
96 fn validate(&self) -> Result<(), ConstraintError> {
97 Ok(())
98 }
99}
100
101pub mod bookmark_state {
102
103 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
104 #[allow(unused)]
105 use ::core::marker::PhantomData;
106 mod sealed {
107 pub trait Sealed {}
108 }
109 pub trait State: sealed::Sealed {
111 type Subject;
112 }
113 pub struct Empty(());
115 impl sealed::Sealed for Empty {}
116 impl State for Empty {
117 type Subject = Unset;
118 }
119 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
121 impl<S: State> sealed::Sealed for SetSubject<S> {}
122 impl<S: State> State for SetSubject<S> {
123 type Subject = Set<members::subject>;
124 }
125 #[allow(non_camel_case_types)]
127 pub mod members {
128 pub struct subject(());
130 }
131}
132
133pub struct BookmarkBuilder<'a, S: bookmark_state::State> {
135 _state: PhantomData<fn() -> S>,
136 _fields: (Option<StrongRef<'a>>,),
137 _lifetime: PhantomData<&'a ()>,
138}
139
140impl<'a> Bookmark<'a> {
141 pub fn new() -> BookmarkBuilder<'a, bookmark_state::Empty> {
143 BookmarkBuilder::new()
144 }
145}
146
147impl<'a> BookmarkBuilder<'a, bookmark_state::Empty> {
148 pub fn new() -> Self {
150 BookmarkBuilder {
151 _state: PhantomData,
152 _fields: (None,),
153 _lifetime: PhantomData,
154 }
155 }
156}
157
158impl<'a, S> BookmarkBuilder<'a, S>
159where
160 S: bookmark_state::State,
161 S::Subject: bookmark_state::IsUnset,
162{
163 pub fn subject(
165 mut self,
166 value: impl Into<StrongRef<'a>>,
167 ) -> BookmarkBuilder<'a, bookmark_state::SetSubject<S>> {
168 self._fields.0 = Option::Some(value.into());
169 BookmarkBuilder {
170 _state: PhantomData,
171 _fields: self._fields,
172 _lifetime: PhantomData,
173 }
174 }
175}
176
177impl<'a, S> BookmarkBuilder<'a, S>
178where
179 S: bookmark_state::State,
180 S::Subject: bookmark_state::IsSet,
181{
182 pub fn build(self) -> Bookmark<'a> {
184 Bookmark {
185 subject: self._fields.0.unwrap(),
186 extra_data: Default::default(),
187 }
188 }
189 pub fn build_with_data(
191 self,
192 extra_data: BTreeMap<
193 jacquard_common::deps::smol_str::SmolStr,
194 jacquard_common::types::value::Data<'a>,
195 >,
196 ) -> Bookmark<'a> {
197 Bookmark {
198 subject: self._fields.0.unwrap(),
199 extra_data: Some(extra_data),
200 }
201 }
202}
203
204fn lexicon_doc_app_bsky_bookmark_defs() -> LexiconDoc<'static> {
205 #[allow(unused_imports)]
206 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
207 use jacquard_lexicon::lexicon::*;
208 use alloc::collections::BTreeMap;
209 LexiconDoc {
210 lexicon: Lexicon::Lexicon1,
211 id: CowStr::new_static("app.bsky.bookmark.defs"),
212 defs: {
213 let mut map = BTreeMap::new();
214 map.insert(
215 SmolStr::new_static("bookmark"),
216 LexUserType::Object(LexObject {
217 description: Some(
218 CowStr::new_static(
219 "Object used to store bookmark data in stash.",
220 ),
221 ),
222 required: Some(vec![SmolStr::new_static("subject")]),
223 properties: {
224 #[allow(unused_mut)]
225 let mut map = BTreeMap::new();
226 map.insert(
227 SmolStr::new_static("subject"),
228 LexObjectProperty::Ref(LexRef {
229 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
230 ..Default::default()
231 }),
232 );
233 map
234 },
235 ..Default::default()
236 }),
237 );
238 map.insert(
239 SmolStr::new_static("bookmarkView"),
240 LexUserType::Object(LexObject {
241 required: Some(
242 vec![SmolStr::new_static("subject"), SmolStr::new_static("item")],
243 ),
244 properties: {
245 #[allow(unused_mut)]
246 let mut map = BTreeMap::new();
247 map.insert(
248 SmolStr::new_static("createdAt"),
249 LexObjectProperty::String(LexString {
250 format: Some(LexStringFormat::Datetime),
251 ..Default::default()
252 }),
253 );
254 map.insert(
255 SmolStr::new_static("item"),
256 LexObjectProperty::Union(LexRefUnion {
257 refs: vec![
258 CowStr::new_static("app.bsky.feed.defs#blockedPost"),
259 CowStr::new_static("app.bsky.feed.defs#notFoundPost"),
260 CowStr::new_static("app.bsky.feed.defs#postView")
261 ],
262 ..Default::default()
263 }),
264 );
265 map.insert(
266 SmolStr::new_static("subject"),
267 LexObjectProperty::Ref(LexRef {
268 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
269 ..Default::default()
270 }),
271 );
272 map
273 },
274 ..Default::default()
275 }),
276 );
277 map
278 },
279 ..Default::default()
280 }
281}
282
283pub mod bookmark_view_state {
284
285 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
286 #[allow(unused)]
287 use ::core::marker::PhantomData;
288 mod sealed {
289 pub trait Sealed {}
290 }
291 pub trait State: sealed::Sealed {
293 type Item;
294 type Subject;
295 }
296 pub struct Empty(());
298 impl sealed::Sealed for Empty {}
299 impl State for Empty {
300 type Item = Unset;
301 type Subject = Unset;
302 }
303 pub struct SetItem<S: State = Empty>(PhantomData<fn() -> S>);
305 impl<S: State> sealed::Sealed for SetItem<S> {}
306 impl<S: State> State for SetItem<S> {
307 type Item = Set<members::item>;
308 type Subject = S::Subject;
309 }
310 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
312 impl<S: State> sealed::Sealed for SetSubject<S> {}
313 impl<S: State> State for SetSubject<S> {
314 type Item = S::Item;
315 type Subject = Set<members::subject>;
316 }
317 #[allow(non_camel_case_types)]
319 pub mod members {
320 pub struct item(());
322 pub struct subject(());
324 }
325}
326
327pub struct BookmarkViewBuilder<'a, S: bookmark_view_state::State> {
329 _state: PhantomData<fn() -> S>,
330 _fields: (Option<Datetime>, Option<BookmarkViewItem<'a>>, Option<StrongRef<'a>>),
331 _lifetime: PhantomData<&'a ()>,
332}
333
334impl<'a> BookmarkView<'a> {
335 pub fn new() -> BookmarkViewBuilder<'a, bookmark_view_state::Empty> {
337 BookmarkViewBuilder::new()
338 }
339}
340
341impl<'a> BookmarkViewBuilder<'a, bookmark_view_state::Empty> {
342 pub fn new() -> Self {
344 BookmarkViewBuilder {
345 _state: PhantomData,
346 _fields: (None, None, None),
347 _lifetime: PhantomData,
348 }
349 }
350}
351
352impl<'a, S: bookmark_view_state::State> BookmarkViewBuilder<'a, S> {
353 pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
355 self._fields.0 = value.into();
356 self
357 }
358 pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
360 self._fields.0 = value;
361 self
362 }
363}
364
365impl<'a, S> BookmarkViewBuilder<'a, S>
366where
367 S: bookmark_view_state::State,
368 S::Item: bookmark_view_state::IsUnset,
369{
370 pub fn item(
372 mut self,
373 value: impl Into<BookmarkViewItem<'a>>,
374 ) -> BookmarkViewBuilder<'a, bookmark_view_state::SetItem<S>> {
375 self._fields.1 = Option::Some(value.into());
376 BookmarkViewBuilder {
377 _state: PhantomData,
378 _fields: self._fields,
379 _lifetime: PhantomData,
380 }
381 }
382}
383
384impl<'a, S> BookmarkViewBuilder<'a, S>
385where
386 S: bookmark_view_state::State,
387 S::Subject: bookmark_view_state::IsUnset,
388{
389 pub fn subject(
391 mut self,
392 value: impl Into<StrongRef<'a>>,
393 ) -> BookmarkViewBuilder<'a, bookmark_view_state::SetSubject<S>> {
394 self._fields.2 = Option::Some(value.into());
395 BookmarkViewBuilder {
396 _state: PhantomData,
397 _fields: self._fields,
398 _lifetime: PhantomData,
399 }
400 }
401}
402
403impl<'a, S> BookmarkViewBuilder<'a, S>
404where
405 S: bookmark_view_state::State,
406 S::Item: bookmark_view_state::IsSet,
407 S::Subject: bookmark_view_state::IsSet,
408{
409 pub fn build(self) -> BookmarkView<'a> {
411 BookmarkView {
412 created_at: self._fields.0,
413 item: self._fields.1.unwrap(),
414 subject: self._fields.2.unwrap(),
415 extra_data: Default::default(),
416 }
417 }
418 pub fn build_with_data(
420 self,
421 extra_data: BTreeMap<
422 jacquard_common::deps::smol_str::SmolStr,
423 jacquard_common::types::value::Data<'a>,
424 >,
425 ) -> BookmarkView<'a> {
426 BookmarkView {
427 created_at: self._fields.0,
428 item: self._fields.1.unwrap(),
429 subject: self._fields.2.unwrap(),
430 extra_data: Some(extra_data),
431 }
432 }
433}