#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct GetBook<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub goodreads_id: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub id: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub isbn: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub isbn13: std::option::Option<jacquard_common::CowStr<'a>>,
}
pub mod get_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 {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct GetBookBuilder<'a, S: get_book_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> GetBook<'a> {
pub fn new() -> GetBookBuilder<'a, get_book_state::Empty> {
GetBookBuilder::new()
}
}
impl<'a> GetBookBuilder<'a, get_book_state::Empty> {
pub fn new() -> Self {
GetBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: get_book_state::State> GetBookBuilder<'a, S> {
pub fn goodreads_id(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_goodreads_id(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S: get_book_state::State> GetBookBuilder<'a, S> {
pub fn id(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_id(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: get_book_state::State> GetBookBuilder<'a, S> {
pub fn isbn(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_isbn(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: get_book_state::State> GetBookBuilder<'a, S> {
pub fn isbn13(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_isbn13(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> GetBookBuilder<'a, S>
where
S: get_book_state::State,
{
pub fn build(self) -> GetBook<'a> {
GetBook {
goodreads_id: self.__unsafe_private_named.0,
id: self.__unsafe_private_named.1,
isbn: self.__unsafe_private_named.2,
isbn13: self.__unsafe_private_named.3,
}
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct GetBookOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub activity: std::option::Option<Vec<crate::buzz_bookhive::Activity<'a>>>,
#[serde(borrow)]
pub book: crate::buzz_bookhive::hive_book::HiveBook<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub book_progress: std::option::Option<crate::buzz_bookhive::BookProgress<'a>>,
#[serde(borrow)]
pub comments: Vec<crate::buzz_bookhive::Comment<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cover: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub created_at: std::option::Option<jacquard_common::types::string::Datetime>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub finished_at: std::option::Option<jacquard_common::types::string::Datetime>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub review: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(borrow)]
pub reviews: Vec<crate::buzz_bookhive::Review<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub stars: std::option::Option<i64>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub started_at: std::option::Option<jacquard_common::types::string::Datetime>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub status: std::option::Option<GetBookOutputStatus<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GetBookOutputStatus<'a> {
Finished,
Reading,
WantToRead,
Abandoned,
Owned,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> GetBookOutputStatus<'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 GetBookOutputStatus<'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(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for GetBookOutputStatus<'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(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for GetBookOutputStatus<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for GetBookOutputStatus<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for GetBookOutputStatus<'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 GetBookOutputStatus<'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 GetBookOutputStatus<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for GetBookOutputStatus<'_> {
type Output = GetBookOutputStatus<'static>;
fn into_static(self) -> Self::Output {
match self {
GetBookOutputStatus::Finished => GetBookOutputStatus::Finished,
GetBookOutputStatus::Reading => GetBookOutputStatus::Reading,
GetBookOutputStatus::WantToRead => GetBookOutputStatus::WantToRead,
GetBookOutputStatus::Abandoned => GetBookOutputStatus::Abandoned,
GetBookOutputStatus::Owned => GetBookOutputStatus::Owned,
GetBookOutputStatus::Other(v) => GetBookOutputStatus::Other(v.into_static()),
}
}
}
pub struct GetBookResponse;
impl jacquard_common::xrpc::XrpcResp for GetBookResponse {
const NSID: &'static str = "buzz.bookhive.getBook";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetBookOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetBook<'a> {
const NSID: &'static str = "buzz.bookhive.getBook";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetBookResponse;
}
pub struct GetBookRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetBookRequest {
const PATH: &'static str = "/xrpc/buzz.bookhive.getBook";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetBook<'de>;
type Response = GetBookResponse;
}