#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Book<'a> {
#[serde(borrow)]
pub authors: Vec<crate::sh_weaver::actor::Author<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub content_warnings: std::option::Option<
crate::sh_weaver::notebook::ContentWarnings<'a>,
>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub created_at: std::option::Option<jacquard_common::types::string::Datetime>,
#[serde(borrow)]
pub entry_list: Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub path: std::option::Option<crate::sh_weaver::notebook::Path<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub publish_global: std::option::Option<bool>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub rating: std::option::Option<crate::sh_weaver::notebook::ContentRating<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub tags: std::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub theme: std::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub title: std::option::Option<crate::sh_weaver::notebook::Title<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub updated_at: std::option::Option<jacquard_common::types::string::Datetime>,
}
pub mod book_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 Authors;
type EntryList;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Authors = Unset;
type EntryList = Unset;
}
pub struct SetAuthors<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAuthors<S> {}
impl<S: State> State for SetAuthors<S> {
type Authors = Set<members::authors>;
type EntryList = S::EntryList;
}
pub struct SetEntryList<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEntryList<S> {}
impl<S: State> State for SetEntryList<S> {
type Authors = S::Authors;
type EntryList = Set<members::entry_list>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct authors(());
pub struct entry_list(());
}
}
pub struct BookBuilder<'a, S: book_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<crate::sh_weaver::actor::Author<'a>>>,
::core::option::Option<crate::sh_weaver::notebook::ContentWarnings<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
::core::option::Option<crate::sh_weaver::notebook::Path<'a>>,
::core::option::Option<bool>,
::core::option::Option<crate::sh_weaver::notebook::ContentRating<'a>>,
::core::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
::core::option::Option<crate::sh_weaver::notebook::Title<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Book<'a> {
pub fn new() -> BookBuilder<'a, book_state::Empty> {
BookBuilder::new()
}
}
impl<'a> BookBuilder<'a, book_state::Empty> {
pub fn new() -> Self {
BookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> BookBuilder<'a, S>
where
S: book_state::State,
S::Authors: book_state::IsUnset,
{
pub fn authors(
mut self,
value: impl Into<Vec<crate::sh_weaver::actor::Author<'a>>>,
) -> BookBuilder<'a, book_state::SetAuthors<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
BookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn content_warnings(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::ContentWarnings<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_content_warnings(
mut self,
value: Option<crate::sh_weaver::notebook::ContentWarnings<'a>>,
) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn created_at(
mut self,
value: impl Into<Option<jacquard_common::types::string::Datetime>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_created_at(
mut self,
value: Option<jacquard_common::types::string::Datetime>,
) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S> BookBuilder<'a, S>
where
S: book_state::State,
S::EntryList: book_state::IsUnset,
{
pub fn entry_list(
mut self,
value: impl Into<Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
) -> BookBuilder<'a, book_state::SetEntryList<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
BookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn path(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::Path<'a>>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_path(
mut self,
value: Option<crate::sh_weaver::notebook::Path<'a>>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn publish_global(mut self, value: impl Into<Option<bool>>) -> Self {
self.__unsafe_private_named.5 = value.into();
self
}
pub fn maybe_publish_global(mut self, value: Option<bool>) -> Self {
self.__unsafe_private_named.5 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn rating(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::ContentRating<'a>>>,
) -> Self {
self.__unsafe_private_named.6 = value.into();
self
}
pub fn maybe_rating(
mut self,
value: Option<crate::sh_weaver::notebook::ContentRating<'a>>,
) -> Self {
self.__unsafe_private_named.6 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn tags(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::Tags<'a>>>,
) -> Self {
self.__unsafe_private_named.7 = value.into();
self
}
pub fn maybe_tags(
mut self,
value: Option<crate::sh_weaver::notebook::Tags<'a>>,
) -> Self {
self.__unsafe_private_named.7 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn theme(
mut self,
value: impl Into<Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
) -> Self {
self.__unsafe_private_named.8 = value.into();
self
}
pub fn maybe_theme(
mut self,
value: Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
) -> Self {
self.__unsafe_private_named.8 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn title(
mut self,
value: impl Into<Option<crate::sh_weaver::notebook::Title<'a>>>,
) -> Self {
self.__unsafe_private_named.9 = value.into();
self
}
pub fn maybe_title(
mut self,
value: Option<crate::sh_weaver::notebook::Title<'a>>,
) -> Self {
self.__unsafe_private_named.9 = value;
self
}
}
impl<'a, S: book_state::State> BookBuilder<'a, S> {
pub fn updated_at(
mut self,
value: impl Into<Option<jacquard_common::types::string::Datetime>>,
) -> Self {
self.__unsafe_private_named.10 = value.into();
self
}
pub fn maybe_updated_at(
mut self,
value: Option<jacquard_common::types::string::Datetime>,
) -> Self {
self.__unsafe_private_named.10 = value;
self
}
}
impl<'a, S> BookBuilder<'a, S>
where
S: book_state::State,
S::Authors: book_state::IsSet,
S::EntryList: book_state::IsSet,
{
pub fn build(self) -> Book<'a> {
Book {
authors: self.__unsafe_private_named.0.unwrap(),
content_warnings: self.__unsafe_private_named.1,
created_at: self.__unsafe_private_named.2,
entry_list: self.__unsafe_private_named.3.unwrap(),
path: self.__unsafe_private_named.4,
publish_global: self.__unsafe_private_named.5,
rating: self.__unsafe_private_named.6,
tags: self.__unsafe_private_named.7,
theme: self.__unsafe_private_named.8,
title: self.__unsafe_private_named.9,
updated_at: self.__unsafe_private_named.10,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Book<'a> {
Book {
authors: self.__unsafe_private_named.0.unwrap(),
content_warnings: self.__unsafe_private_named.1,
created_at: self.__unsafe_private_named.2,
entry_list: self.__unsafe_private_named.3.unwrap(),
path: self.__unsafe_private_named.4,
publish_global: self.__unsafe_private_named.5,
rating: self.__unsafe_private_named.6,
tags: self.__unsafe_private_named.7,
theme: self.__unsafe_private_named.8,
title: self.__unsafe_private_named.9,
updated_at: self.__unsafe_private_named.10,
extra_data: Some(extra_data),
}
}
}
impl<'a> Book<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, BookRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct BookGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Book<'a>,
}
impl From<BookGetRecordOutput<'_>> for Book<'_> {
fn from(output: BookGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Book<'_> {
const NSID: &'static str = "sh.weaver.notebook.book";
type Record = BookRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct BookRecord;
impl jacquard_common::xrpc::XrpcResp for BookRecord {
const NSID: &'static str = "sh.weaver.notebook.book";
const ENCODING: &'static str = "application/json";
type Output<'de> = BookGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for BookRecord {
const NSID: &'static str = "sh.weaver.notebook.book";
type Record = BookRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Book<'a> {
fn nsid() -> &'static str {
"sh.weaver.notebook.book"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_book()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}
fn lexicon_doc_sh_weaver_notebook_book() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.book"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"Authors of a Weaver notebook.",
),
),
key: Some(::jacquard_common::CowStr::new_static("tid")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("authors"),
::jacquard_common::deps::smol_str::SmolStr::new_static("entryList")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"authors",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.actor.defs#author",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"contentWarnings",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#contentWarnings",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Client-declared timestamp when this was originally created.",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"entryList",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"com.atproto.repo.strongRef",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"path",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#path",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"publishGlobal",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
description: None,
default: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"rating",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#contentRating",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"tags",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#tags",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"theme",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"com.atproto.repo.strongRef",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"title",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"sh.weaver.notebook.defs#title",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"updatedAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Client-declared timestamp of last modification. Used for canonicality tiebreaking in multi-author scenarios.",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}