#[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_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::buzz_bookhive::list_genres;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GenreWithCount<'a> {
pub count: i64,
#[serde(borrow)]
pub genre: CowStr<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListGenres {
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(default = "_default_min_books")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_books: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub offset: Option<i64>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListGenresOutput<'a> {
#[serde(borrow)]
pub genres: Vec<list_genres::GenreWithCount<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub offset: Option<i64>,
}
impl<'a> LexiconSchema for GenreWithCount<'a> {
fn nsid() -> &'static str {
"buzz.bookhive.listGenres"
}
fn def_name() -> &'static str {
"genreWithCount"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_buzz_bookhive_listGenres()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct ListGenresResponse;
impl jacquard_common::xrpc::XrpcResp for ListGenresResponse {
const NSID: &'static str = "buzz.bookhive.listGenres";
const ENCODING: &'static str = "application/json";
type Output<'de> = ListGenresOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl jacquard_common::xrpc::XrpcRequest for ListGenres {
const NSID: &'static str = "buzz.bookhive.listGenres";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ListGenresResponse;
}
pub struct ListGenresRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ListGenresRequest {
const PATH: &'static str = "/xrpc/buzz.bookhive.listGenres";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = ListGenres;
type Response = ListGenresResponse;
}
pub mod genre_with_count_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 Count;
type Genre;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Count = Unset;
type Genre = Unset;
}
pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCount<S> {}
impl<S: State> State for SetCount<S> {
type Count = Set<members::count>;
type Genre = S::Genre;
}
pub struct SetGenre<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetGenre<S> {}
impl<S: State> State for SetGenre<S> {
type Count = S::Count;
type Genre = Set<members::genre>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct count(());
pub struct genre(());
}
}
pub struct GenreWithCountBuilder<'a, S: genre_with_count_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GenreWithCount<'a> {
pub fn new() -> GenreWithCountBuilder<'a, genre_with_count_state::Empty> {
GenreWithCountBuilder::new()
}
}
impl<'a> GenreWithCountBuilder<'a, genre_with_count_state::Empty> {
pub fn new() -> Self {
GenreWithCountBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GenreWithCountBuilder<'a, S>
where
S: genre_with_count_state::State,
S::Count: genre_with_count_state::IsUnset,
{
pub fn count(
mut self,
value: impl Into<i64>,
) -> GenreWithCountBuilder<'a, genre_with_count_state::SetCount<S>> {
self._fields.0 = Option::Some(value.into());
GenreWithCountBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GenreWithCountBuilder<'a, S>
where
S: genre_with_count_state::State,
S::Genre: genre_with_count_state::IsUnset,
{
pub fn genre(
mut self,
value: impl Into<CowStr<'a>>,
) -> GenreWithCountBuilder<'a, genre_with_count_state::SetGenre<S>> {
self._fields.1 = Option::Some(value.into());
GenreWithCountBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GenreWithCountBuilder<'a, S>
where
S: genre_with_count_state::State,
S::Count: genre_with_count_state::IsSet,
S::Genre: genre_with_count_state::IsSet,
{
pub fn build(self) -> GenreWithCount<'a> {
GenreWithCount {
count: self._fields.0.unwrap(),
genre: self._fields.1.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>,
>,
) -> GenreWithCount<'a> {
GenreWithCount {
count: self._fields.0.unwrap(),
genre: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_buzz_bookhive_listGenres() -> 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.listGenres"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("genreWithCount"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("genre"), SmolStr::new_static("count")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("count"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("genre"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Genre name")),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("limit"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("minBooks"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("offset"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn _default_limit() -> Option<i64> {
Some(50i64)
}
fn _default_min_books() -> Option<i64> {
Some(0i64)
}
pub mod list_genres_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 ListGenresBuilder<S: list_genres_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>, Option<i64>),
}
impl ListGenres {
pub fn new() -> ListGenresBuilder<list_genres_state::Empty> {
ListGenresBuilder::new()
}
}
impl ListGenresBuilder<list_genres_state::Empty> {
pub fn new() -> Self {
ListGenresBuilder {
_state: PhantomData,
_fields: (None, None, None),
}
}
}
impl<S: list_genres_state::State> ListGenresBuilder<S> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: list_genres_state::State> ListGenresBuilder<S> {
pub fn min_books(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_min_books(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: list_genres_state::State> ListGenresBuilder<S> {
pub fn offset(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_offset(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<S> ListGenresBuilder<S>
where
S: list_genres_state::State,
{
pub fn build(self) -> ListGenres {
ListGenres {
limit: self._fields.0,
min_books: self._fields.1,
offset: self._fields.2,
}
}
}