pub mod actor;
pub mod book;
#[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::{Did, Handle};
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};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Actor<'a> {
#[serde(borrow)]
pub did: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub display_name: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub handle: Option<Handle<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AspectRatio<'a> {
pub height: i64,
pub width: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct BookIdEntry<'a> {
#[serde(borrow)]
pub id: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LocationEntry<'a> {
pub book_count: i64,
#[serde(borrow)]
pub h3: CowStr<'a>,
}
impl<'a> LexiconSchema for Actor<'a> {
fn nsid() -> &'static str {
"org.passingreads.defs"
}
fn def_name() -> &'static str {
"actor"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_passingreads_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.display_name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("display_name"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for AspectRatio<'a> {
fn nsid() -> &'static str {
"org.passingreads.defs"
}
fn def_name() -> &'static str {
"aspectRatio"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_passingreads_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.height;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("height"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.width;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("width"),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for BookIdEntry<'a> {
fn nsid() -> &'static str {
"org.passingreads.defs"
}
fn def_name() -> &'static str {
"bookIdEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_passingreads_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for LocationEntry<'a> {
fn nsid() -> &'static str {
"org.passingreads.defs"
}
fn def_name() -> &'static str {
"locationEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_passingreads_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod actor_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 Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
}
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 Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct ActorBuilder<'a, S: actor_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Did<'a>>, Option<CowStr<'a>>, Option<Handle<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Actor<'a> {
pub fn new() -> ActorBuilder<'a, actor_state::Empty> {
ActorBuilder::new()
}
}
impl<'a> ActorBuilder<'a, actor_state::Empty> {
pub fn new() -> Self {
ActorBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ActorBuilder<'a, S>
where
S: actor_state::State,
S::Did: actor_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> ActorBuilder<'a, actor_state::SetDid<S>> {
self._fields.0 = Option::Some(value.into());
ActorBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: actor_state::State> ActorBuilder<'a, S> {
pub fn display_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_display_name(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: actor_state::State> ActorBuilder<'a, S> {
pub fn handle(mut self, value: impl Into<Option<Handle<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_handle(mut self, value: Option<Handle<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> ActorBuilder<'a, S>
where
S: actor_state::State,
S::Did: actor_state::IsSet,
{
pub fn build(self) -> Actor<'a> {
Actor {
did: self._fields.0.unwrap(),
display_name: self._fields.1,
handle: self._fields.2,
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>,
>,
) -> Actor<'a> {
Actor {
did: self._fields.0.unwrap(),
display_name: self._fields.1,
handle: self._fields.2,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_passingreads_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("org.passingreads.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("actor"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Basic actor information for embedding in responses",
),
),
required: Some(vec![SmolStr::new_static("did")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("aspectRatio"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any unit.",
),
),
required: Some(
vec![SmolStr::new_static("width"), SmolStr::new_static("height")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bookIdEntry"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Book ID entry for SSG")),
required: Some(vec![SmolStr::new_static("id")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("locationEntry"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Location entry with book count for SSG"),
),
required: Some(
vec![SmolStr::new_static("h3"), SmolStr::new_static("bookCount")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("bookCount"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("h3"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod aspect_ratio_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 Width;
type Height;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Width = Unset;
type Height = Unset;
}
pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWidth<S> {}
impl<S: State> State for SetWidth<S> {
type Width = Set<members::width>;
type Height = S::Height;
}
pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHeight<S> {}
impl<S: State> State for SetHeight<S> {
type Width = S::Width;
type Height = Set<members::height>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct width(());
pub struct height(());
}
}
pub struct AspectRatioBuilder<'a, S: aspect_ratio_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> AspectRatio<'a> {
pub fn new() -> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
AspectRatioBuilder::new()
}
}
impl<'a> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
pub fn new() -> Self {
AspectRatioBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> AspectRatioBuilder<'a, S>
where
S: aspect_ratio_state::State,
S::Height: aspect_ratio_state::IsUnset,
{
pub fn height(
mut self,
value: impl Into<i64>,
) -> AspectRatioBuilder<'a, aspect_ratio_state::SetHeight<S>> {
self._fields.0 = Option::Some(value.into());
AspectRatioBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AspectRatioBuilder<'a, S>
where
S: aspect_ratio_state::State,
S::Width: aspect_ratio_state::IsUnset,
{
pub fn width(
mut self,
value: impl Into<i64>,
) -> AspectRatioBuilder<'a, aspect_ratio_state::SetWidth<S>> {
self._fields.1 = Option::Some(value.into());
AspectRatioBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AspectRatioBuilder<'a, S>
where
S: aspect_ratio_state::State,
S::Width: aspect_ratio_state::IsSet,
S::Height: aspect_ratio_state::IsSet,
{
pub fn build(self) -> AspectRatio<'a> {
AspectRatio {
height: self._fields.0.unwrap(),
width: 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>,
>,
) -> AspectRatio<'a> {
AspectRatio {
height: self._fields.0.unwrap(),
width: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod location_entry_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 H3;
type BookCount;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type H3 = Unset;
type BookCount = Unset;
}
pub struct SetH3<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetH3<S> {}
impl<S: State> State for SetH3<S> {
type H3 = Set<members::h3>;
type BookCount = S::BookCount;
}
pub struct SetBookCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBookCount<S> {}
impl<S: State> State for SetBookCount<S> {
type H3 = S::H3;
type BookCount = Set<members::book_count>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct h3(());
pub struct book_count(());
}
}
pub struct LocationEntryBuilder<'a, S: location_entry_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LocationEntry<'a> {
pub fn new() -> LocationEntryBuilder<'a, location_entry_state::Empty> {
LocationEntryBuilder::new()
}
}
impl<'a> LocationEntryBuilder<'a, location_entry_state::Empty> {
pub fn new() -> Self {
LocationEntryBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> LocationEntryBuilder<'a, S>
where
S: location_entry_state::State,
S::BookCount: location_entry_state::IsUnset,
{
pub fn book_count(
mut self,
value: impl Into<i64>,
) -> LocationEntryBuilder<'a, location_entry_state::SetBookCount<S>> {
self._fields.0 = Option::Some(value.into());
LocationEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LocationEntryBuilder<'a, S>
where
S: location_entry_state::State,
S::H3: location_entry_state::IsUnset,
{
pub fn h3(
mut self,
value: impl Into<CowStr<'a>>,
) -> LocationEntryBuilder<'a, location_entry_state::SetH3<S>> {
self._fields.1 = Option::Some(value.into());
LocationEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LocationEntryBuilder<'a, S>
where
S: location_entry_state::State,
S::H3: location_entry_state::IsSet,
S::BookCount: location_entry_state::IsSet,
{
pub fn build(self) -> LocationEntry<'a> {
LocationEntry {
book_count: self._fields.0.unwrap(),
h3: 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>,
>,
) -> LocationEntry<'a> {
LocationEntry {
book_count: self._fields.0.unwrap(),
h3: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}