pub mod create_bookmark;
pub mod delete_bookmark;
pub mod get_bookmarks;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Datetime;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::feed::BlockedPost;
use crate::app_bsky::feed::NotFoundPost;
use crate::app_bsky::feed::PostView;
use crate::com_atproto::repo::strong_ref::StrongRef;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Bookmark<'a> {
#[serde(borrow)]
pub subject: StrongRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BookmarkView<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(borrow)]
pub item: BookmarkViewItem<'a>,
#[serde(borrow)]
pub subject: StrongRef<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum BookmarkViewItem<'a> {
#[serde(rename = "app.bsky.feed.defs#blockedPost")]
BlockedPost(Box<BlockedPost<'a>>),
#[serde(rename = "app.bsky.feed.defs#notFoundPost")]
NotFoundPost(Box<NotFoundPost<'a>>),
#[serde(rename = "app.bsky.feed.defs#postView")]
PostView(Box<PostView<'a>>),
}
impl<'a> LexiconSchema for Bookmark<'a> {
fn nsid() -> &'static str {
"app.bsky.bookmark.defs"
}
fn def_name() -> &'static str {
"bookmark"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_bookmark_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for BookmarkView<'a> {
fn nsid() -> &'static str {
"app.bsky.bookmark.defs"
}
fn def_name() -> &'static str {
"bookmarkView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_bookmark_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod bookmark_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
}
}
pub struct BookmarkBuilder<'a, S: bookmark_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<StrongRef<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Bookmark<'a> {
pub fn new() -> BookmarkBuilder<'a, bookmark_state::Empty> {
BookmarkBuilder::new()
}
}
impl<'a> BookmarkBuilder<'a, bookmark_state::Empty> {
pub fn new() -> Self {
BookmarkBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> BookmarkBuilder<'a, S>
where
S: bookmark_state::State,
S::Subject: bookmark_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<StrongRef<'a>>,
) -> BookmarkBuilder<'a, bookmark_state::SetSubject<S>> {
self._fields.0 = Option::Some(value.into());
BookmarkBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BookmarkBuilder<'a, S>
where
S: bookmark_state::State,
S::Subject: bookmark_state::IsSet,
{
pub fn build(self) -> Bookmark<'a> {
Bookmark {
subject: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Bookmark<'a> {
Bookmark {
subject: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_bsky_bookmark_defs() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("app.bsky.bookmark.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("bookmark"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Object used to store bookmark data in stash.",
),
),
required: Some(vec![SmolStr::new_static("subject")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bookmarkView"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("subject"), SmolStr::new_static("item")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("item"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("app.bsky.feed.defs#blockedPost"),
CowStr::new_static("app.bsky.feed.defs#notFoundPost"),
CowStr::new_static("app.bsky.feed.defs#postView")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod bookmark_view_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Item;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Item = Unset;
type Subject = Unset;
}
pub struct SetItem<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetItem<S> {}
impl<S: State> State for SetItem<S> {
type Item = Set<members::item>;
type Subject = S::Subject;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type Item = S::Item;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct item(());
pub struct subject(());
}
}
pub struct BookmarkViewBuilder<'a, S: bookmark_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Datetime>, Option<BookmarkViewItem<'a>>, Option<StrongRef<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> BookmarkView<'a> {
pub fn new() -> BookmarkViewBuilder<'a, bookmark_view_state::Empty> {
BookmarkViewBuilder::new()
}
}
impl<'a> BookmarkViewBuilder<'a, bookmark_view_state::Empty> {
pub fn new() -> Self {
BookmarkViewBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: bookmark_view_state::State> BookmarkViewBuilder<'a, S> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> BookmarkViewBuilder<'a, S>
where
S: bookmark_view_state::State,
S::Item: bookmark_view_state::IsUnset,
{
pub fn item(
mut self,
value: impl Into<BookmarkViewItem<'a>>,
) -> BookmarkViewBuilder<'a, bookmark_view_state::SetItem<S>> {
self._fields.1 = Option::Some(value.into());
BookmarkViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BookmarkViewBuilder<'a, S>
where
S: bookmark_view_state::State,
S::Subject: bookmark_view_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<StrongRef<'a>>,
) -> BookmarkViewBuilder<'a, bookmark_view_state::SetSubject<S>> {
self._fields.2 = Option::Some(value.into());
BookmarkViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BookmarkViewBuilder<'a, S>
where
S: bookmark_view_state::State,
S::Item: bookmark_view_state::IsSet,
S::Subject: bookmark_view_state::IsSet,
{
pub fn build(self) -> BookmarkView<'a> {
BookmarkView {
created_at: self._fields.0,
item: self._fields.1.unwrap(),
subject: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> BookmarkView<'a> {
BookmarkView {
created_at: self._fields.0,
item: self._fields.1.unwrap(),
subject: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}