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;
use jacquard_common::{BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, 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;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Bookmark<S: BosStr = DefaultStr> {
pub subject: StrongRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BookmarkView<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
pub item: BookmarkViewItem<S>,
pub subject: StrongRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum BookmarkViewItem<S: BosStr = DefaultStr> {
#[serde(rename = "app.bsky.feed.defs#blockedPost")]
BlockedPost(Box<BlockedPost<S>>),
#[serde(rename = "app.bsky.feed.defs#notFoundPost")]
NotFoundPost(Box<NotFoundPost<S>>),
#[serde(rename = "app.bsky.feed.defs#postView")]
PostView(Box<PostView<S>>),
}
impl<S: BosStr> LexiconSchema for Bookmark<S> {
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<S: BosStr> LexiconSchema for BookmarkView<S> {
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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
}
}
pub struct BookmarkBuilder<S: BosStr, St: bookmark_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<StrongRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Bookmark<S> {
pub fn new() -> BookmarkBuilder<S, bookmark_state::Empty> {
BookmarkBuilder::new()
}
}
impl<S: BosStr> BookmarkBuilder<S, bookmark_state::Empty> {
pub fn new() -> Self {
BookmarkBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BookmarkBuilder<S, St>
where
St: bookmark_state::State,
St::Subject: bookmark_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<StrongRef<S>>,
) -> BookmarkBuilder<S, bookmark_state::SetSubject<St>> {
self._fields.0 = Option::Some(value.into());
BookmarkBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BookmarkBuilder<S, St>
where
St: bookmark_state::State,
St::Subject: bookmark_state::IsSet,
{
pub fn build(self) -> Bookmark<S> {
Bookmark {
subject: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Bookmark<S> {
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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetItem<St> {}
impl<St: State> State for SetItem<St> {
type Item = Set<members::item>;
type Subject = St::Subject;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Item = St::Item;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct item(());
pub struct subject(());
}
}
pub struct BookmarkViewBuilder<S: BosStr, St: bookmark_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>, Option<BookmarkViewItem<S>>, Option<StrongRef<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> BookmarkView<S> {
pub fn new() -> BookmarkViewBuilder<S, bookmark_view_state::Empty> {
BookmarkViewBuilder::new()
}
}
impl<S: BosStr> BookmarkViewBuilder<S, bookmark_view_state::Empty> {
pub fn new() -> Self {
BookmarkViewBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: bookmark_view_state::State> BookmarkViewBuilder<S, St> {
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<S: BosStr, St> BookmarkViewBuilder<S, St>
where
St: bookmark_view_state::State,
St::Item: bookmark_view_state::IsUnset,
{
pub fn item(
mut self,
value: impl Into<BookmarkViewItem<S>>,
) -> BookmarkViewBuilder<S, bookmark_view_state::SetItem<St>> {
self._fields.1 = Option::Some(value.into());
BookmarkViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BookmarkViewBuilder<S, St>
where
St: bookmark_view_state::State,
St::Subject: bookmark_view_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<StrongRef<S>>,
) -> BookmarkViewBuilder<S, bookmark_view_state::SetSubject<St>> {
self._fields.2 = Option::Some(value.into());
BookmarkViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BookmarkViewBuilder<S, St>
where
St: bookmark_view_state::State,
St::Item: bookmark_view_state::IsSet,
St::Subject: bookmark_view_state::IsSet,
{
pub fn build(self) -> BookmarkView<S> {
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<SmolStr, Data<S>>,
) -> BookmarkView<S> {
BookmarkView {
created_at: self._fields.0,
item: self._fields.1.unwrap(),
subject: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}