pub mod book;
pub mod buzz;
pub mod get_book;
pub mod get_book_identifiers;
pub mod get_profile;
pub mod hive_book;
pub mod list_genres;
pub mod search_books;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Datetime;
use jacquard_derive::{IntoStatic, lexicon};
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::com_atproto::repo::strong_ref::StrongRef;
use crate::buzz_bookhive;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Abandoned;
impl core::fmt::Display for Abandoned {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "abandoned")
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Activity<'a> {
pub created_at: Datetime,
#[serde(borrow)]
pub hive_id: CowStr<'a>,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(borrow)]
pub r#type: ActivityType<'a>,
#[serde(borrow)]
pub user_did: CowStr<'a>,
#[serde(borrow)]
pub user_handle: CowStr<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ActivityType<'a> {
Review,
Rated,
Started,
Finished,
Other(CowStr<'a>),
}
impl<'a> ActivityType<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Review => "review",
Self::Rated => "rated",
Self::Started => "started",
Self::Finished => "finished",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for ActivityType<'a> {
fn from(s: &'a str) -> Self {
match s {
"review" => Self::Review,
"rated" => Self::Rated,
"started" => Self::Started,
"finished" => Self::Finished,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for ActivityType<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"review" => Self::Review,
"rated" => Self::Rated,
"started" => Self::Started,
"finished" => Self::Finished,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ActivityType<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ActivityType<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ActivityType<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for ActivityType<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for ActivityType<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ActivityType<'_> {
type Output = ActivityType<'static>;
fn into_static(self) -> Self::Output {
match self {
ActivityType::Review => ActivityType::Review,
ActivityType::Rated => ActivityType::Rated,
ActivityType::Started => ActivityType::Started,
ActivityType::Finished => ActivityType::Finished,
ActivityType::Other(v) => ActivityType::Other(v.into_static()),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct BookIdentifiers<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub goodreads_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub hive_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub isbn10: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub isbn13: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BookProgress<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub current_chapter: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub current_page: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub percent: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_chapters: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_pages: Option<i64>,
pub updated_at: Datetime,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Comment<'a> {
#[serde(borrow)]
pub book: StrongRef<'a>,
#[serde(borrow)]
pub comment: CowStr<'a>,
pub created_at: Datetime,
#[serde(borrow)]
pub did: CowStr<'a>,
#[serde(borrow)]
pub handle: CowStr<'a>,
#[serde(borrow)]
pub parent: StrongRef<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Finished;
impl core::fmt::Display for Finished {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "finished")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Owned;
impl core::fmt::Display for Owned {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "owned")
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Profile<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub avatar: Option<CowStr<'a>>,
pub books_read: i64,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(borrow)]
pub display_name: CowStr<'a>,
#[serde(borrow)]
pub handle: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_following: Option<bool>,
pub reviews: i64,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Reading;
impl core::fmt::Display for Reading {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "reading")
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Review<'a> {
pub created_at: Datetime,
#[serde(borrow)]
pub did: CowStr<'a>,
#[serde(borrow)]
pub handle: CowStr<'a>,
#[serde(borrow)]
pub review: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stars: Option<i64>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UserBook<'a> {
#[serde(borrow)]
pub authors: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub book_progress: Option<buzz_bookhive::BookProgress<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cover: Option<CowStr<'a>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub finished_at: Option<Datetime>,
#[serde(borrow)]
pub hive_id: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rating: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub review: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stars: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub started_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub status: Option<UserBookStatus<'a>>,
#[serde(borrow)]
pub thumbnail: CowStr<'a>,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(borrow)]
pub user_did: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub user_handle: Option<CowStr<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UserBookStatus<'a> {
Finished,
Reading,
WantToRead,
Abandoned,
Owned,
Other(CowStr<'a>),
}
impl<'a> UserBookStatus<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Finished => "buzz.bookhive.defs#finished",
Self::Reading => "buzz.bookhive.defs#reading",
Self::WantToRead => "buzz.bookhive.defs#wantToRead",
Self::Abandoned => "buzz.bookhive.defs#abandoned",
Self::Owned => "buzz.bookhive.defs#owned",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for UserBookStatus<'a> {
fn from(s: &'a str) -> Self {
match s {
"buzz.bookhive.defs#finished" => Self::Finished,
"buzz.bookhive.defs#reading" => Self::Reading,
"buzz.bookhive.defs#wantToRead" => Self::WantToRead,
"buzz.bookhive.defs#abandoned" => Self::Abandoned,
"buzz.bookhive.defs#owned" => Self::Owned,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for UserBookStatus<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"buzz.bookhive.defs#finished" => Self::Finished,
"buzz.bookhive.defs#reading" => Self::Reading,
"buzz.bookhive.defs#wantToRead" => Self::WantToRead,
"buzz.bookhive.defs#abandoned" => Self::Abandoned,
"buzz.bookhive.defs#owned" => Self::Owned,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for UserBookStatus<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for UserBookStatus<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for UserBookStatus<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for UserBookStatus<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for UserBookStatus<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for UserBookStatus<'_> {
type Output = UserBookStatus<'static>;
fn into_static(self) -> Self::Output {
match self {
UserBookStatus::Finished => UserBookStatus::Finished,
UserBookStatus::Reading => UserBookStatus::Reading,
UserBookStatus::WantToRead => UserBookStatus::WantToRead,
UserBookStatus::Abandoned => UserBookStatus::Abandoned,
UserBookStatus::Owned => UserBookStatus::Owned,
UserBookStatus::Other(v) => UserBookStatus::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct WantToRead;
impl core::fmt::Display for WantToRead {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "wantToRead")
}
}
impl<'a> LexiconSchema for Activity<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"activity"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for BookIdentifiers<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"bookIdentifiers"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for BookProgress<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"bookProgress"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.current_chapter {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("current_chapter"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.current_page {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("current_page"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.percent {
if *value > 100i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("percent"),
max: 100i64,
actual: *value,
});
}
}
if let Some(ref value) = self.percent {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("percent"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.total_chapters {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("total_chapters"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.total_pages {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("total_pages"),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Comment<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"comment"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.comment;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("comment"),
max: 100000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.comment;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 10000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("comment"),
max: 10000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Profile<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"profile"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.books_read;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("books_read"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.reviews;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("reviews"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Review<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"review"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for UserBook<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.defs"
}
fn def_name() -> &'static str {
"userBook"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.authors;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2048usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("authors"),
max: 2048usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.authors;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("authors"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 5000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 5000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.rating {
if *value > 1000i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("rating"),
max: 1000i64,
actual: *value,
});
}
}
if let Some(ref value) = self.rating {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("rating"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.review {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 15000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("review"),
max: 15000usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.stars {
if *value > 10i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("stars"),
max: 10i64,
actual: *value,
});
}
}
if let Some(ref value) = self.stars {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("stars"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("title"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod activity_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 CreatedAt;
type HiveId;
type Title;
type UserDid;
type UserHandle;
type Type;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type HiveId = Unset;
type Title = Unset;
type UserDid = Unset;
type UserHandle = Unset;
type Type = Unset;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type CreatedAt = Set<members::created_at>;
type HiveId = S::HiveId;
type Title = S::Title;
type UserDid = S::UserDid;
type UserHandle = S::UserHandle;
type Type = S::Type;
}
pub struct SetHiveId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHiveId<S> {}
impl<S: State> State for SetHiveId<S> {
type CreatedAt = S::CreatedAt;
type HiveId = Set<members::hive_id>;
type Title = S::Title;
type UserDid = S::UserDid;
type UserHandle = S::UserHandle;
type Type = S::Type;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type CreatedAt = S::CreatedAt;
type HiveId = S::HiveId;
type Title = Set<members::title>;
type UserDid = S::UserDid;
type UserHandle = S::UserHandle;
type Type = S::Type;
}
pub struct SetUserDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUserDid<S> {}
impl<S: State> State for SetUserDid<S> {
type CreatedAt = S::CreatedAt;
type HiveId = S::HiveId;
type Title = S::Title;
type UserDid = Set<members::user_did>;
type UserHandle = S::UserHandle;
type Type = S::Type;
}
pub struct SetUserHandle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUserHandle<S> {}
impl<S: State> State for SetUserHandle<S> {
type CreatedAt = S::CreatedAt;
type HiveId = S::HiveId;
type Title = S::Title;
type UserDid = S::UserDid;
type UserHandle = Set<members::user_handle>;
type Type = S::Type;
}
pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetType<S> {}
impl<S: State> State for SetType<S> {
type CreatedAt = S::CreatedAt;
type HiveId = S::HiveId;
type Title = S::Title;
type UserDid = S::UserDid;
type UserHandle = S::UserHandle;
type Type = Set<members::r#type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct hive_id(());
pub struct title(());
pub struct user_did(());
pub struct user_handle(());
pub struct r#type(());
}
}
pub struct ActivityBuilder<'a, S: activity_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<ActivityType<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Activity<'a> {
pub fn new() -> ActivityBuilder<'a, activity_state::Empty> {
ActivityBuilder::new()
}
}
impl<'a> ActivityBuilder<'a, activity_state::Empty> {
pub fn new() -> Self {
ActivityBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::CreatedAt: activity_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ActivityBuilder<'a, activity_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::HiveId: activity_state::IsUnset,
{
pub fn hive_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActivityBuilder<'a, activity_state::SetHiveId<S>> {
self._fields.1 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::Title: activity_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActivityBuilder<'a, activity_state::SetTitle<S>> {
self._fields.2 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::Type: activity_state::IsUnset,
{
pub fn r#type(
mut self,
value: impl Into<ActivityType<'a>>,
) -> ActivityBuilder<'a, activity_state::SetType<S>> {
self._fields.3 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::UserDid: activity_state::IsUnset,
{
pub fn user_did(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActivityBuilder<'a, activity_state::SetUserDid<S>> {
self._fields.4 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::UserHandle: activity_state::IsUnset,
{
pub fn user_handle(
mut self,
value: impl Into<CowStr<'a>>,
) -> ActivityBuilder<'a, activity_state::SetUserHandle<S>> {
self._fields.5 = Option::Some(value.into());
ActivityBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActivityBuilder<'a, S>
where
S: activity_state::State,
S::CreatedAt: activity_state::IsSet,
S::HiveId: activity_state::IsSet,
S::Title: activity_state::IsSet,
S::UserDid: activity_state::IsSet,
S::UserHandle: activity_state::IsSet,
S::Type: activity_state::IsSet,
{
pub fn build(self) -> Activity<'a> {
Activity {
created_at: self._fields.0.unwrap(),
hive_id: self._fields.1.unwrap(),
title: self._fields.2.unwrap(),
r#type: self._fields.3.unwrap(),
user_did: self._fields.4.unwrap(),
user_handle: self._fields.5.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>,
>,
) -> Activity<'a> {
Activity {
created_at: self._fields.0.unwrap(),
hive_id: self._fields.1.unwrap(),
title: self._fields.2.unwrap(),
r#type: self._fields.3.unwrap(),
user_did: self._fields.4.unwrap(),
user_handle: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_buzz_bookhive_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("buzz.bookhive.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("abandoned"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("activity"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("type"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("hiveId"), SmolStr::new_static("title"),
SmolStr::new_static("userDid"),
SmolStr::new_static("userHandle")
],
),
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("hiveId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The hive id of the book"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The title of the book"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("type"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("userDid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The DID of the user who added the book"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userHandle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle of the user who added the book",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bookIdentifiers"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("External identifiers for a book"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("goodreadsId"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Goodreads book ID")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hiveId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("BookHive's internal ID"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isbn10"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("10-digit ISBN")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isbn13"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("13-digit ISBN")),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bookProgress"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Reading progress tracking data"),
),
required: Some(vec![SmolStr::new_static("updatedAt")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("currentChapter"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("currentPage"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("percent"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(100i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("totalChapters"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("totalPages"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the progress was last updated"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("comment"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("comment"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("book"), SmolStr::new_static("parent"),
SmolStr::new_static("did"), SmolStr::new_static("handle")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("book"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("comment"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The content of the comment."),
),
max_length: Some(100000usize),
max_graphemes: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Client-declared timestamp when this comment was originally created.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The DID of the user who made the comment",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle of the user who made the comment",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("parent"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("finished"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("owned"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("profile"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("displayName"),
SmolStr::new_static("handle"),
SmolStr::new_static("booksRead"),
SmolStr::new_static("reviews")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("avatar"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("booksRead"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("isFollowing"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reviews"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reading"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("review"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("review"),
SmolStr::new_static("createdAt"), SmolStr::new_static("did"),
SmolStr::new_static("handle")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The date the review was created"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The DID of the user who made the review",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle of the user who made the review",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("review"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The review content")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("stars"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userBook"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("userDid"), SmolStr::new_static("title"),
SmolStr::new_static("authors"),
SmolStr::new_static("hiveId"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("thumbnail")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("authors"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The authors of the book (tab separated)",
),
),
min_length: Some(1usize),
max_length: Some(2048usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bookProgress"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"buzz.bookhive.defs#bookProgress",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cover"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Cover image of the book"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Book description/summary"),
),
max_length: Some(5000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("finishedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The date the user finished reading the book",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hiveId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The book's hive id, used to correlate user's books with the hive",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rating"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(1000i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("review"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The book's review")),
max_graphemes: Some(15000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("stars"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
maximum: Some(10i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The date the user started reading the book",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("thumbnail"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Cover image of the book"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The title of the book"),
),
min_length: Some(1usize),
max_length: Some(512usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userDid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The DID of the user who added the book"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userHandle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle of the user who added the book",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("wantToRead"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map
},
..Default::default()
}
}
pub mod book_progress_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 UpdatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type UpdatedAt = Unset;
}
pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
impl<S: State> State for SetUpdatedAt<S> {
type UpdatedAt = Set<members::updated_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct updated_at(());
}
}
pub struct BookProgressBuilder<'a, S: book_progress_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> BookProgress<'a> {
pub fn new() -> BookProgressBuilder<'a, book_progress_state::Empty> {
BookProgressBuilder::new()
}
}
impl<'a> BookProgressBuilder<'a, book_progress_state::Empty> {
pub fn new() -> Self {
BookProgressBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> {
pub fn current_chapter(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_current_chapter(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> {
pub fn current_page(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_current_page(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> {
pub fn percent(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_percent(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> {
pub fn total_chapters(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_total_chapters(mut self, value: Option<i64>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> {
pub fn total_pages(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_total_pages(mut self, value: Option<i64>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> BookProgressBuilder<'a, S>
where
S: book_progress_state::State,
S::UpdatedAt: book_progress_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> BookProgressBuilder<'a, book_progress_state::SetUpdatedAt<S>> {
self._fields.5 = Option::Some(value.into());
BookProgressBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BookProgressBuilder<'a, S>
where
S: book_progress_state::State,
S::UpdatedAt: book_progress_state::IsSet,
{
pub fn build(self) -> BookProgress<'a> {
BookProgress {
current_chapter: self._fields.0,
current_page: self._fields.1,
percent: self._fields.2,
total_chapters: self._fields.3,
total_pages: self._fields.4,
updated_at: self._fields.5.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>,
>,
) -> BookProgress<'a> {
BookProgress {
current_chapter: self._fields.0,
current_page: self._fields.1,
percent: self._fields.2,
total_chapters: self._fields.3,
total_pages: self._fields.4,
updated_at: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod comment_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 Comment;
type Book;
type Handle;
type CreatedAt;
type Parent;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Comment = Unset;
type Book = Unset;
type Handle = Unset;
type CreatedAt = Unset;
type Parent = Unset;
type Did = Unset;
}
pub struct SetComment<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetComment<S> {}
impl<S: State> State for SetComment<S> {
type Comment = Set<members::comment>;
type Book = S::Book;
type Handle = S::Handle;
type CreatedAt = S::CreatedAt;
type Parent = S::Parent;
type Did = S::Did;
}
pub struct SetBook<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBook<S> {}
impl<S: State> State for SetBook<S> {
type Comment = S::Comment;
type Book = Set<members::book>;
type Handle = S::Handle;
type CreatedAt = S::CreatedAt;
type Parent = S::Parent;
type Did = S::Did;
}
pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHandle<S> {}
impl<S: State> State for SetHandle<S> {
type Comment = S::Comment;
type Book = S::Book;
type Handle = Set<members::handle>;
type CreatedAt = S::CreatedAt;
type Parent = S::Parent;
type Did = S::Did;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Comment = S::Comment;
type Book = S::Book;
type Handle = S::Handle;
type CreatedAt = Set<members::created_at>;
type Parent = S::Parent;
type Did = S::Did;
}
pub struct SetParent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetParent<S> {}
impl<S: State> State for SetParent<S> {
type Comment = S::Comment;
type Book = S::Book;
type Handle = S::Handle;
type CreatedAt = S::CreatedAt;
type Parent = Set<members::parent>;
type Did = S::Did;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Comment = S::Comment;
type Book = S::Book;
type Handle = S::Handle;
type CreatedAt = S::CreatedAt;
type Parent = S::Parent;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct comment(());
pub struct book(());
pub struct handle(());
pub struct created_at(());
pub struct parent(());
pub struct did(());
}
}
pub struct CommentBuilder<'a, S: comment_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<StrongRef<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<StrongRef<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Comment<'a> {
pub fn new() -> CommentBuilder<'a, comment_state::Empty> {
CommentBuilder::new()
}
}
impl<'a> CommentBuilder<'a, comment_state::Empty> {
pub fn new() -> Self {
CommentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Book: comment_state::IsUnset,
{
pub fn book(
mut self,
value: impl Into<StrongRef<'a>>,
) -> CommentBuilder<'a, comment_state::SetBook<S>> {
self._fields.0 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Comment: comment_state::IsUnset,
{
pub fn comment(
mut self,
value: impl Into<CowStr<'a>>,
) -> CommentBuilder<'a, comment_state::SetComment<S>> {
self._fields.1 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::CreatedAt: comment_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> CommentBuilder<'a, comment_state::SetCreatedAt<S>> {
self._fields.2 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Did: comment_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<CowStr<'a>>,
) -> CommentBuilder<'a, comment_state::SetDid<S>> {
self._fields.3 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Handle: comment_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<CowStr<'a>>,
) -> CommentBuilder<'a, comment_state::SetHandle<S>> {
self._fields.4 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Parent: comment_state::IsUnset,
{
pub fn parent(
mut self,
value: impl Into<StrongRef<'a>>,
) -> CommentBuilder<'a, comment_state::SetParent<S>> {
self._fields.5 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommentBuilder<'a, S>
where
S: comment_state::State,
S::Comment: comment_state::IsSet,
S::Book: comment_state::IsSet,
S::Handle: comment_state::IsSet,
S::CreatedAt: comment_state::IsSet,
S::Parent: comment_state::IsSet,
S::Did: comment_state::IsSet,
{
pub fn build(self) -> Comment<'a> {
Comment {
book: self._fields.0.unwrap(),
comment: self._fields.1.unwrap(),
created_at: self._fields.2.unwrap(),
did: self._fields.3.unwrap(),
handle: self._fields.4.unwrap(),
parent: self._fields.5.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>,
>,
) -> Comment<'a> {
Comment {
book: self._fields.0.unwrap(),
comment: self._fields.1.unwrap(),
created_at: self._fields.2.unwrap(),
did: self._fields.3.unwrap(),
handle: self._fields.4.unwrap(),
parent: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod profile_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 Handle;
type BooksRead;
type DisplayName;
type Reviews;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Handle = Unset;
type BooksRead = Unset;
type DisplayName = Unset;
type Reviews = Unset;
}
pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHandle<S> {}
impl<S: State> State for SetHandle<S> {
type Handle = Set<members::handle>;
type BooksRead = S::BooksRead;
type DisplayName = S::DisplayName;
type Reviews = S::Reviews;
}
pub struct SetBooksRead<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBooksRead<S> {}
impl<S: State> State for SetBooksRead<S> {
type Handle = S::Handle;
type BooksRead = Set<members::books_read>;
type DisplayName = S::DisplayName;
type Reviews = S::Reviews;
}
pub struct SetDisplayName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDisplayName<S> {}
impl<S: State> State for SetDisplayName<S> {
type Handle = S::Handle;
type BooksRead = S::BooksRead;
type DisplayName = Set<members::display_name>;
type Reviews = S::Reviews;
}
pub struct SetReviews<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetReviews<S> {}
impl<S: State> State for SetReviews<S> {
type Handle = S::Handle;
type BooksRead = S::BooksRead;
type DisplayName = S::DisplayName;
type Reviews = Set<members::reviews>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct handle(());
pub struct books_read(());
pub struct display_name(());
pub struct reviews(());
}
}
pub struct ProfileBuilder<'a, S: profile_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<i64>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<bool>,
Option<i64>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Profile<'a> {
pub fn new() -> ProfileBuilder<'a, profile_state::Empty> {
ProfileBuilder::new()
}
}
impl<'a> ProfileBuilder<'a, profile_state::Empty> {
pub fn new() -> Self {
ProfileBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn avatar(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_avatar(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::BooksRead: profile_state::IsUnset,
{
pub fn books_read(
mut self,
value: impl Into<i64>,
) -> ProfileBuilder<'a, profile_state::SetBooksRead<S>> {
self._fields.1 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::DisplayName: profile_state::IsUnset,
{
pub fn display_name(
mut self,
value: impl Into<CowStr<'a>>,
) -> ProfileBuilder<'a, profile_state::SetDisplayName<S>> {
self._fields.3 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::Handle: profile_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<CowStr<'a>>,
) -> ProfileBuilder<'a, profile_state::SetHandle<S>> {
self._fields.4 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
pub fn is_following(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_is_following(mut self, value: Option<bool>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::Reviews: profile_state::IsUnset,
{
pub fn reviews(
mut self,
value: impl Into<i64>,
) -> ProfileBuilder<'a, profile_state::SetReviews<S>> {
self._fields.6 = Option::Some(value.into());
ProfileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ProfileBuilder<'a, S>
where
S: profile_state::State,
S::Handle: profile_state::IsSet,
S::BooksRead: profile_state::IsSet,
S::DisplayName: profile_state::IsSet,
S::Reviews: profile_state::IsSet,
{
pub fn build(self) -> Profile<'a> {
Profile {
avatar: self._fields.0,
books_read: self._fields.1.unwrap(),
description: self._fields.2,
display_name: self._fields.3.unwrap(),
handle: self._fields.4.unwrap(),
is_following: self._fields.5,
reviews: self._fields.6.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>,
>,
) -> Profile<'a> {
Profile {
avatar: self._fields.0,
books_read: self._fields.1.unwrap(),
description: self._fields.2,
display_name: self._fields.3.unwrap(),
handle: self._fields.4.unwrap(),
is_following: self._fields.5,
reviews: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod review_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 Review;
type CreatedAt;
type Handle;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Review = Unset;
type CreatedAt = Unset;
type Handle = Unset;
type Did = Unset;
}
pub struct SetReview<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetReview<S> {}
impl<S: State> State for SetReview<S> {
type Review = Set<members::review>;
type CreatedAt = S::CreatedAt;
type Handle = S::Handle;
type Did = S::Did;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Review = S::Review;
type CreatedAt = Set<members::created_at>;
type Handle = S::Handle;
type Did = S::Did;
}
pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHandle<S> {}
impl<S: State> State for SetHandle<S> {
type Review = S::Review;
type CreatedAt = S::CreatedAt;
type Handle = Set<members::handle>;
type Did = S::Did;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Review = S::Review;
type CreatedAt = S::CreatedAt;
type Handle = S::Handle;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct review(());
pub struct created_at(());
pub struct handle(());
pub struct did(());
}
}
pub struct ReviewBuilder<'a, S: review_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Datetime>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<i64>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Review<'a> {
pub fn new() -> ReviewBuilder<'a, review_state::Empty> {
ReviewBuilder::new()
}
}
impl<'a> ReviewBuilder<'a, review_state::Empty> {
pub fn new() -> Self {
ReviewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReviewBuilder<'a, S>
where
S: review_state::State,
S::CreatedAt: review_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ReviewBuilder<'a, review_state::SetCreatedAt<S>> {
self._fields.0 = Option::Some(value.into());
ReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReviewBuilder<'a, S>
where
S: review_state::State,
S::Did: review_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<CowStr<'a>>,
) -> ReviewBuilder<'a, review_state::SetDid<S>> {
self._fields.1 = Option::Some(value.into());
ReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReviewBuilder<'a, S>
where
S: review_state::State,
S::Handle: review_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<CowStr<'a>>,
) -> ReviewBuilder<'a, review_state::SetHandle<S>> {
self._fields.2 = Option::Some(value.into());
ReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReviewBuilder<'a, S>
where
S: review_state::State,
S::Review: review_state::IsUnset,
{
pub fn review(
mut self,
value: impl Into<CowStr<'a>>,
) -> ReviewBuilder<'a, review_state::SetReview<S>> {
self._fields.3 = Option::Some(value.into());
ReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: review_state::State> ReviewBuilder<'a, S> {
pub fn stars(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_stars(mut self, value: Option<i64>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> ReviewBuilder<'a, S>
where
S: review_state::State,
S::Review: review_state::IsSet,
S::CreatedAt: review_state::IsSet,
S::Handle: review_state::IsSet,
S::Did: review_state::IsSet,
{
pub fn build(self) -> Review<'a> {
Review {
created_at: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
handle: self._fields.2.unwrap(),
review: self._fields.3.unwrap(),
stars: self._fields.4,
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>,
>,
) -> Review<'a> {
Review {
created_at: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
handle: self._fields.2.unwrap(),
review: self._fields.3.unwrap(),
stars: self._fields.4,
extra_data: Some(extra_data),
}
}
}
pub mod user_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 Title;
type UserDid;
type Authors;
type HiveId;
type Thumbnail;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Title = Unset;
type UserDid = Unset;
type Authors = Unset;
type HiveId = Unset;
type Thumbnail = Unset;
type CreatedAt = Unset;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Title = Set<members::title>;
type UserDid = S::UserDid;
type Authors = S::Authors;
type HiveId = S::HiveId;
type Thumbnail = S::Thumbnail;
type CreatedAt = S::CreatedAt;
}
pub struct SetUserDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUserDid<S> {}
impl<S: State> State for SetUserDid<S> {
type Title = S::Title;
type UserDid = Set<members::user_did>;
type Authors = S::Authors;
type HiveId = S::HiveId;
type Thumbnail = S::Thumbnail;
type CreatedAt = S::CreatedAt;
}
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 Title = S::Title;
type UserDid = S::UserDid;
type Authors = Set<members::authors>;
type HiveId = S::HiveId;
type Thumbnail = S::Thumbnail;
type CreatedAt = S::CreatedAt;
}
pub struct SetHiveId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHiveId<S> {}
impl<S: State> State for SetHiveId<S> {
type Title = S::Title;
type UserDid = S::UserDid;
type Authors = S::Authors;
type HiveId = Set<members::hive_id>;
type Thumbnail = S::Thumbnail;
type CreatedAt = S::CreatedAt;
}
pub struct SetThumbnail<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetThumbnail<S> {}
impl<S: State> State for SetThumbnail<S> {
type Title = S::Title;
type UserDid = S::UserDid;
type Authors = S::Authors;
type HiveId = S::HiveId;
type Thumbnail = Set<members::thumbnail>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Title = S::Title;
type UserDid = S::UserDid;
type Authors = S::Authors;
type HiveId = S::HiveId;
type Thumbnail = S::Thumbnail;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct title(());
pub struct user_did(());
pub struct authors(());
pub struct hive_id(());
pub struct thumbnail(());
pub struct created_at(());
}
}
pub struct UserBookBuilder<'a, S: user_book_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<buzz_bookhive::BookProgress<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<i64>,
Option<CowStr<'a>>,
Option<i64>,
Option<Datetime>,
Option<UserBookStatus<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> UserBook<'a> {
pub fn new() -> UserBookBuilder<'a, user_book_state::Empty> {
UserBookBuilder::new()
}
}
impl<'a> UserBookBuilder<'a, user_book_state::Empty> {
pub fn new() -> Self {
UserBookBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::Authors: user_book_state::IsUnset,
{
pub fn authors(
mut self,
value: impl Into<CowStr<'a>>,
) -> UserBookBuilder<'a, user_book_state::SetAuthors<S>> {
self._fields.0 = Option::Some(value.into());
UserBookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn book_progress(
mut self,
value: impl Into<Option<buzz_bookhive::BookProgress<'a>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_book_progress(
mut self,
value: Option<buzz_bookhive::BookProgress<'a>>,
) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn cover(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_cover(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::CreatedAt: user_book_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> UserBookBuilder<'a, user_book_state::SetCreatedAt<S>> {
self._fields.3 = Option::Some(value.into());
UserBookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn finished_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_finished_at(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::HiveId: user_book_state::IsUnset,
{
pub fn hive_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> UserBookBuilder<'a, user_book_state::SetHiveId<S>> {
self._fields.6 = Option::Some(value.into());
UserBookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn rating(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_rating(mut self, value: Option<i64>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn review(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_review(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn stars(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_stars(mut self, value: Option<i64>) -> Self {
self._fields.9 = value;
self
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn started_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_started_at(mut self, value: Option<Datetime>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn status(mut self, value: impl Into<Option<UserBookStatus<'a>>>) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<UserBookStatus<'a>>) -> Self {
self._fields.11 = value;
self
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::Thumbnail: user_book_state::IsUnset,
{
pub fn thumbnail(
mut self,
value: impl Into<CowStr<'a>>,
) -> UserBookBuilder<'a, user_book_state::SetThumbnail<S>> {
self._fields.12 = Option::Some(value.into());
UserBookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::Title: user_book_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> UserBookBuilder<'a, user_book_state::SetTitle<S>> {
self._fields.13 = Option::Some(value.into());
UserBookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::UserDid: user_book_state::IsUnset,
{
pub fn user_did(
mut self,
value: impl Into<CowStr<'a>>,
) -> UserBookBuilder<'a, user_book_state::SetUserDid<S>> {
self._fields.14 = Option::Some(value.into());
UserBookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> {
pub fn user_handle(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.15 = value.into();
self
}
pub fn maybe_user_handle(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.15 = value;
self
}
}
impl<'a, S> UserBookBuilder<'a, S>
where
S: user_book_state::State,
S::Title: user_book_state::IsSet,
S::UserDid: user_book_state::IsSet,
S::Authors: user_book_state::IsSet,
S::HiveId: user_book_state::IsSet,
S::Thumbnail: user_book_state::IsSet,
S::CreatedAt: user_book_state::IsSet,
{
pub fn build(self) -> UserBook<'a> {
UserBook {
authors: self._fields.0.unwrap(),
book_progress: self._fields.1,
cover: self._fields.2,
created_at: self._fields.3.unwrap(),
description: self._fields.4,
finished_at: self._fields.5,
hive_id: self._fields.6.unwrap(),
rating: self._fields.7,
review: self._fields.8,
stars: self._fields.9,
started_at: self._fields.10,
status: self._fields.11,
thumbnail: self._fields.12.unwrap(),
title: self._fields.13.unwrap(),
user_did: self._fields.14.unwrap(),
user_handle: self._fields.15,
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>,
>,
) -> UserBook<'a> {
UserBook {
authors: self._fields.0.unwrap(),
book_progress: self._fields.1,
cover: self._fields.2,
created_at: self._fields.3.unwrap(),
description: self._fields.4,
finished_at: self._fields.5,
hive_id: self._fields.6.unwrap(),
rating: self._fields.7,
review: self._fields.8,
stars: self._fields.9,
started_at: self._fields.10,
status: self._fields.11,
thumbnail: self._fields.12.unwrap(),
title: self._fields.13.unwrap(),
user_did: self._fields.14.unwrap(),
user_handle: self._fields.15,
extra_data: Some(extra_data),
}
}
}