pub mod checkin;
pub mod drop;
pub mod event;
pub mod find;
pub mod get_book;
pub mod get_books;
pub mod get_library;
pub mod get_location_books;
pub mod list_book_ids;
pub mod list_dropped_books;
pub mod registration;
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct ConfirmedEvent<'a> {
#[serde(borrow)]
pub actor: crate::org_passingreads::Actor<'a>,
#[serde(borrow)]
pub event: ConfirmedEventEvent<'a>,
#[serde(borrow)]
pub location: crate::community_lexicon::location::hthree::Hthree<'a>,
pub occurred_at: jacquard_common::types::string::Datetime,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
}
pub mod confirmed_event_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 Uri;
type Actor;
type OccurredAt;
type Location;
type Event;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Actor = Unset;
type OccurredAt = Unset;
type Location = Unset;
type Event = Unset;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
type Actor = S::Actor;
type OccurredAt = S::OccurredAt;
type Location = S::Location;
type Event = S::Event;
}
pub struct SetActor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetActor<S> {}
impl<S: State> State for SetActor<S> {
type Uri = S::Uri;
type Actor = Set<members::actor>;
type OccurredAt = S::OccurredAt;
type Location = S::Location;
type Event = S::Event;
}
pub struct SetOccurredAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetOccurredAt<S> {}
impl<S: State> State for SetOccurredAt<S> {
type Uri = S::Uri;
type Actor = S::Actor;
type OccurredAt = Set<members::occurred_at>;
type Location = S::Location;
type Event = S::Event;
}
pub struct SetLocation<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLocation<S> {}
impl<S: State> State for SetLocation<S> {
type Uri = S::Uri;
type Actor = S::Actor;
type OccurredAt = S::OccurredAt;
type Location = Set<members::location>;
type Event = S::Event;
}
pub struct SetEvent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEvent<S> {}
impl<S: State> State for SetEvent<S> {
type Uri = S::Uri;
type Actor = S::Actor;
type OccurredAt = S::OccurredAt;
type Location = S::Location;
type Event = Set<members::event>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct actor(());
pub struct occurred_at(());
pub struct location(());
pub struct event(());
}
}
pub struct ConfirmedEventBuilder<'a, S: confirmed_event_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<crate::org_passingreads::Actor<'a>>,
::core::option::Option<ConfirmedEventEvent<'a>>,
::core::option::Option<crate::community_lexicon::location::hthree::Hthree<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> ConfirmedEvent<'a> {
pub fn new() -> ConfirmedEventBuilder<'a, confirmed_event_state::Empty> {
ConfirmedEventBuilder::new()
}
}
impl<'a> ConfirmedEventBuilder<'a, confirmed_event_state::Empty> {
pub fn new() -> Self {
ConfirmedEventBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ConfirmedEventBuilder<'a, S>
where
S: confirmed_event_state::State,
S::Actor: confirmed_event_state::IsUnset,
{
pub fn actor(
mut self,
value: impl Into<crate::org_passingreads::Actor<'a>>,
) -> ConfirmedEventBuilder<'a, confirmed_event_state::SetActor<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
ConfirmedEventBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ConfirmedEventBuilder<'a, S>
where
S: confirmed_event_state::State,
S::Event: confirmed_event_state::IsUnset,
{
pub fn event(
mut self,
value: impl Into<ConfirmedEventEvent<'a>>,
) -> ConfirmedEventBuilder<'a, confirmed_event_state::SetEvent<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
ConfirmedEventBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ConfirmedEventBuilder<'a, S>
where
S: confirmed_event_state::State,
S::Location: confirmed_event_state::IsUnset,
{
pub fn location(
mut self,
value: impl Into<crate::community_lexicon::location::hthree::Hthree<'a>>,
) -> ConfirmedEventBuilder<'a, confirmed_event_state::SetLocation<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
ConfirmedEventBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ConfirmedEventBuilder<'a, S>
where
S: confirmed_event_state::State,
S::OccurredAt: confirmed_event_state::IsUnset,
{
pub fn occurred_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> ConfirmedEventBuilder<'a, confirmed_event_state::SetOccurredAt<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
ConfirmedEventBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ConfirmedEventBuilder<'a, S>
where
S: confirmed_event_state::State,
S::Uri: confirmed_event_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<jacquard_common::types::string::AtUri<'a>>,
) -> ConfirmedEventBuilder<'a, confirmed_event_state::SetUri<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
ConfirmedEventBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ConfirmedEventBuilder<'a, S>
where
S: confirmed_event_state::State,
S::Uri: confirmed_event_state::IsSet,
S::Actor: confirmed_event_state::IsSet,
S::OccurredAt: confirmed_event_state::IsSet,
S::Location: confirmed_event_state::IsSet,
S::Event: confirmed_event_state::IsSet,
{
pub fn build(self) -> ConfirmedEvent<'a> {
ConfirmedEvent {
actor: self.__unsafe_private_named.0.unwrap(),
event: self.__unsafe_private_named.1.unwrap(),
location: self.__unsafe_private_named.2.unwrap(),
occurred_at: self.__unsafe_private_named.3.unwrap(),
uri: self.__unsafe_private_named.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ConfirmedEvent<'a> {
ConfirmedEvent {
actor: self.__unsafe_private_named.0.unwrap(),
event: self.__unsafe_private_named.1.unwrap(),
location: self.__unsafe_private_named.2.unwrap(),
occurred_at: self.__unsafe_private_named.3.unwrap(),
uri: self.__unsafe_private_named.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ConfirmedEventEvent<'a> {
OrgPassingreadsBookCheckin,
OrgPassingreadsBookDrop,
OrgPassingreadsBookFind,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> ConfirmedEventEvent<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::OrgPassingreadsBookCheckin => "org.passingreads.book.checkin",
Self::OrgPassingreadsBookDrop => "org.passingreads.book.drop",
Self::OrgPassingreadsBookFind => "org.passingreads.book.find",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for ConfirmedEventEvent<'a> {
fn from(s: &'a str) -> Self {
match s {
"org.passingreads.book.checkin" => Self::OrgPassingreadsBookCheckin,
"org.passingreads.book.drop" => Self::OrgPassingreadsBookDrop,
"org.passingreads.book.find" => Self::OrgPassingreadsBookFind,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for ConfirmedEventEvent<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"org.passingreads.book.checkin" => Self::OrgPassingreadsBookCheckin,
"org.passingreads.book.drop" => Self::OrgPassingreadsBookDrop,
"org.passingreads.book.find" => Self::OrgPassingreadsBookFind,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for ConfirmedEventEvent<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for ConfirmedEventEvent<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for ConfirmedEventEvent<'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 ConfirmedEventEvent<'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 ConfirmedEventEvent<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for ConfirmedEventEvent<'_> {
type Output = ConfirmedEventEvent<'static>;
fn into_static(self) -> Self::Output {
match self {
ConfirmedEventEvent::OrgPassingreadsBookCheckin => {
ConfirmedEventEvent::OrgPassingreadsBookCheckin
}
ConfirmedEventEvent::OrgPassingreadsBookDrop => {
ConfirmedEventEvent::OrgPassingreadsBookDrop
}
ConfirmedEventEvent::OrgPassingreadsBookFind => {
ConfirmedEventEvent::OrgPassingreadsBookFind
}
ConfirmedEventEvent::Other(v) => ConfirmedEventEvent::Other(v.into_static()),
}
}
}
fn lexicon_doc_org_passingreads_book_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("org.passingreads.book.defs"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("confirmedEvent"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static(
"A confirmed book event for display purposes. Omits cryptographic fields (bookPub, bookSig) and book reference since it's shown in context of a book.",
),
),
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("uri"),
::jacquard_common::deps::smol_str::SmolStr::new_static("actor"),
::jacquard_common::deps::smol_str::SmolStr::new_static("event"),
::jacquard_common::deps::smol_str::SmolStr::new_static("location"),
::jacquard_common::deps::smol_str::SmolStr::new_static("occurredAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"actor",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"org.passingreads.defs#actor",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"event",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static("What event occurred"),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"location",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"community.lexicon.location.hthree#main",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"occurredAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"When this event occurred",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"uri",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The AT URI of this event record",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"registrationView",
),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static(
"A view of a book registration for API responses. Omits cryptographic fields (bookPub, bookSig) and the cover blob.",
),
),
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("registeredBy"),
::jacquard_common::deps::smol_str::SmolStr::new_static("bookId"),
::jacquard_common::deps::smol_str::SmolStr::new_static("title"),
::jacquard_common::deps::smol_str::SmolStr::new_static("authors"),
::jacquard_common::deps::smol_str::SmolStr::new_static("occurredAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"authors",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: Some(
::jacquard_common::CowStr::new_static(
"Authors of this book, in order of credit",
),
),
items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"bookId",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The book's ID (as defined on its QR Code)",
),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"occurredAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"When the book was registered",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"publicationId",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The book's Open Library Edition ID",
),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"registeredBy",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"org.passingreads.defs#actor",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"title",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The title of the book",
),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("statefulBook"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: Some(
::jacquard_common::CowStr::new_static(
"A book with its current state, combining registration data with computed state information.",
),
),
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("uri"),
::jacquard_common::deps::smol_str::SmolStr::new_static("cid"),
::jacquard_common::deps::smol_str::SmolStr::new_static("registration"),
::jacquard_common::deps::smol_str::SmolStr::new_static("state"),
::jacquard_common::deps::smol_str::SmolStr::new_static("currentHolder")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"aspectRatio",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"org.passingreads.defs#aspectRatio",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"cid",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The CID of the book registration record",
),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"coverUrl",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Resolved URL to the cover image (from the registration blob)",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Uri,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"currentHolder",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The DID of the current holder of the book",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Did,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"currentLocation",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"community.lexicon.location.hthree#main",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"events",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: Some(
::jacquard_common::CowStr::new_static(
"List of confirmed events for this book, in chronological order",
),
),
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"#confirmedEvent",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"registration",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"#registrationView",
),
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"state",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The current state of the book, derived from the latest event",
),
),
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"uri",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The AT URI of the book registration record",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
);
map
},
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ConfirmedEvent<'a> {
fn nsid() -> &'static str {
"org.passingreads.book.defs"
}
fn def_name() -> &'static str {
"confirmedEvent"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_org_passingreads_book_defs()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct RegistrationView<'a> {
#[serde(borrow)]
pub authors: Vec<jacquard_common::CowStr<'a>>,
#[serde(borrow)]
pub book_id: jacquard_common::CowStr<'a>,
pub occurred_at: jacquard_common::types::string::Datetime,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub publication_id: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(borrow)]
pub registered_by: crate::org_passingreads::Actor<'a>,
#[serde(borrow)]
pub title: jacquard_common::CowStr<'a>,
}
pub mod registration_view_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 RegisteredBy;
type OccurredAt;
type Title;
type BookId;
type Authors;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type RegisteredBy = Unset;
type OccurredAt = Unset;
type Title = Unset;
type BookId = Unset;
type Authors = Unset;
}
pub struct SetRegisteredBy<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRegisteredBy<S> {}
impl<S: State> State for SetRegisteredBy<S> {
type RegisteredBy = Set<members::registered_by>;
type OccurredAt = S::OccurredAt;
type Title = S::Title;
type BookId = S::BookId;
type Authors = S::Authors;
}
pub struct SetOccurredAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetOccurredAt<S> {}
impl<S: State> State for SetOccurredAt<S> {
type RegisteredBy = S::RegisteredBy;
type OccurredAt = Set<members::occurred_at>;
type Title = S::Title;
type BookId = S::BookId;
type Authors = S::Authors;
}
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 RegisteredBy = S::RegisteredBy;
type OccurredAt = S::OccurredAt;
type Title = Set<members::title>;
type BookId = S::BookId;
type Authors = S::Authors;
}
pub struct SetBookId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBookId<S> {}
impl<S: State> State for SetBookId<S> {
type RegisteredBy = S::RegisteredBy;
type OccurredAt = S::OccurredAt;
type Title = S::Title;
type BookId = Set<members::book_id>;
type Authors = S::Authors;
}
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 RegisteredBy = S::RegisteredBy;
type OccurredAt = S::OccurredAt;
type Title = S::Title;
type BookId = S::BookId;
type Authors = Set<members::authors>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct registered_by(());
pub struct occurred_at(());
pub struct title(());
pub struct book_id(());
pub struct authors(());
}
}
pub struct RegistrationViewBuilder<'a, S: registration_view_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<crate::org_passingreads::Actor<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> RegistrationView<'a> {
pub fn new() -> RegistrationViewBuilder<'a, registration_view_state::Empty> {
RegistrationViewBuilder::new()
}
}
impl<'a> RegistrationViewBuilder<'a, registration_view_state::Empty> {
pub fn new() -> Self {
RegistrationViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RegistrationViewBuilder<'a, S>
where
S: registration_view_state::State,
S::Authors: registration_view_state::IsUnset,
{
pub fn authors(
mut self,
value: impl Into<Vec<jacquard_common::CowStr<'a>>>,
) -> RegistrationViewBuilder<'a, registration_view_state::SetAuthors<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
RegistrationViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RegistrationViewBuilder<'a, S>
where
S: registration_view_state::State,
S::BookId: registration_view_state::IsUnset,
{
pub fn book_id(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> RegistrationViewBuilder<'a, registration_view_state::SetBookId<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
RegistrationViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RegistrationViewBuilder<'a, S>
where
S: registration_view_state::State,
S::OccurredAt: registration_view_state::IsUnset,
{
pub fn occurred_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> RegistrationViewBuilder<'a, registration_view_state::SetOccurredAt<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
RegistrationViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: registration_view_state::State> RegistrationViewBuilder<'a, S> {
pub fn publication_id(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_publication_id(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> RegistrationViewBuilder<'a, S>
where
S: registration_view_state::State,
S::RegisteredBy: registration_view_state::IsUnset,
{
pub fn registered_by(
mut self,
value: impl Into<crate::org_passingreads::Actor<'a>>,
) -> RegistrationViewBuilder<'a, registration_view_state::SetRegisteredBy<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
RegistrationViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RegistrationViewBuilder<'a, S>
where
S: registration_view_state::State,
S::Title: registration_view_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> RegistrationViewBuilder<'a, registration_view_state::SetTitle<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
RegistrationViewBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> RegistrationViewBuilder<'a, S>
where
S: registration_view_state::State,
S::RegisteredBy: registration_view_state::IsSet,
S::OccurredAt: registration_view_state::IsSet,
S::Title: registration_view_state::IsSet,
S::BookId: registration_view_state::IsSet,
S::Authors: registration_view_state::IsSet,
{
pub fn build(self) -> RegistrationView<'a> {
RegistrationView {
authors: self.__unsafe_private_named.0.unwrap(),
book_id: self.__unsafe_private_named.1.unwrap(),
occurred_at: self.__unsafe_private_named.2.unwrap(),
publication_id: self.__unsafe_private_named.3,
registered_by: self.__unsafe_private_named.4.unwrap(),
title: self.__unsafe_private_named.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> RegistrationView<'a> {
RegistrationView {
authors: self.__unsafe_private_named.0.unwrap(),
book_id: self.__unsafe_private_named.1.unwrap(),
occurred_at: self.__unsafe_private_named.2.unwrap(),
publication_id: self.__unsafe_private_named.3,
registered_by: self.__unsafe_private_named.4.unwrap(),
title: self.__unsafe_private_named.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for RegistrationView<'a> {
fn nsid() -> &'static str {
"org.passingreads.book.defs"
}
fn def_name() -> &'static str {
"registrationView"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_org_passingreads_book_defs()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}
#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct StatefulBook<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub aspect_ratio: std::option::Option<crate::org_passingreads::AspectRatio<'a>>,
#[serde(borrow)]
pub cid: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cover_url: std::option::Option<jacquard_common::types::string::UriValue<'a>>,
#[serde(borrow)]
pub current_holder: jacquard_common::types::string::Did<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub current_location: std::option::Option<
crate::community_lexicon::location::hthree::Hthree<'a>,
>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub events: std::option::Option<
Vec<crate::org_passingreads::book::ConfirmedEvent<'a>>,
>,
#[serde(borrow)]
pub registration: crate::org_passingreads::book::RegistrationView<'a>,
#[serde(borrow)]
pub state: StatefulBookState<'a>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
}
pub mod stateful_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 Registration;
type CurrentHolder;
type State;
type Cid;
type Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Registration = Unset;
type CurrentHolder = Unset;
type State = Unset;
type Cid = Unset;
type Uri = Unset;
}
pub struct SetRegistration<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRegistration<S> {}
impl<S: State> State for SetRegistration<S> {
type Registration = Set<members::registration>;
type CurrentHolder = S::CurrentHolder;
type State = S::State;
type Cid = S::Cid;
type Uri = S::Uri;
}
pub struct SetCurrentHolder<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCurrentHolder<S> {}
impl<S: State> State for SetCurrentHolder<S> {
type Registration = S::Registration;
type CurrentHolder = Set<members::current_holder>;
type State = S::State;
type Cid = S::Cid;
type Uri = S::Uri;
}
pub struct SetState<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetState<S> {}
impl<S: State> State for SetState<S> {
type Registration = S::Registration;
type CurrentHolder = S::CurrentHolder;
type State = Set<members::state>;
type Cid = S::Cid;
type Uri = S::Uri;
}
pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCid<S> {}
impl<S: State> State for SetCid<S> {
type Registration = S::Registration;
type CurrentHolder = S::CurrentHolder;
type State = S::State;
type Cid = Set<members::cid>;
type Uri = S::Uri;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Registration = S::Registration;
type CurrentHolder = S::CurrentHolder;
type State = S::State;
type Cid = S::Cid;
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct registration(());
pub struct current_holder(());
pub struct state(());
pub struct cid(());
pub struct uri(());
}
}
pub struct StatefulBookBuilder<'a, S: stateful_book_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<crate::org_passingreads::AspectRatio<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::UriValue<'a>>,
::core::option::Option<jacquard_common::types::string::Did<'a>>,
::core::option::Option<crate::community_lexicon::location::hthree::Hthree<'a>>,
::core::option::Option<Vec<crate::org_passingreads::book::ConfirmedEvent<'a>>>,
::core::option::Option<crate::org_passingreads::book::RegistrationView<'a>>,
::core::option::Option<StatefulBookState<'a>>,
::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> StatefulBook<'a> {
pub fn new() -> StatefulBookBuilder<'a, stateful_book_state::Empty> {
StatefulBookBuilder::new()
}
}
impl<'a> StatefulBookBuilder<'a, stateful_book_state::Empty> {
pub fn new() -> Self {
StatefulBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: stateful_book_state::State> StatefulBookBuilder<'a, S> {
pub fn aspect_ratio(
mut self,
value: impl Into<Option<crate::org_passingreads::AspectRatio<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_aspect_ratio(
mut self,
value: Option<crate::org_passingreads::AspectRatio<'a>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> StatefulBookBuilder<'a, S>
where
S: stateful_book_state::State,
S::Cid: stateful_book_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> StatefulBookBuilder<'a, stateful_book_state::SetCid<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
StatefulBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: stateful_book_state::State> StatefulBookBuilder<'a, S> {
pub fn cover_url(
mut self,
value: impl Into<Option<jacquard_common::types::string::UriValue<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_cover_url(
mut self,
value: Option<jacquard_common::types::string::UriValue<'a>>,
) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S> StatefulBookBuilder<'a, S>
where
S: stateful_book_state::State,
S::CurrentHolder: stateful_book_state::IsUnset,
{
pub fn current_holder(
mut self,
value: impl Into<jacquard_common::types::string::Did<'a>>,
) -> StatefulBookBuilder<'a, stateful_book_state::SetCurrentHolder<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
StatefulBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: stateful_book_state::State> StatefulBookBuilder<'a, S> {
pub fn current_location(
mut self,
value: impl Into<Option<crate::community_lexicon::location::hthree::Hthree<'a>>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_current_location(
mut self,
value: Option<crate::community_lexicon::location::hthree::Hthree<'a>>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S: stateful_book_state::State> StatefulBookBuilder<'a, S> {
pub fn events(
mut self,
value: impl Into<Option<Vec<crate::org_passingreads::book::ConfirmedEvent<'a>>>>,
) -> Self {
self.__unsafe_private_named.5 = value.into();
self
}
pub fn maybe_events(
mut self,
value: Option<Vec<crate::org_passingreads::book::ConfirmedEvent<'a>>>,
) -> Self {
self.__unsafe_private_named.5 = value;
self
}
}
impl<'a, S> StatefulBookBuilder<'a, S>
where
S: stateful_book_state::State,
S::Registration: stateful_book_state::IsUnset,
{
pub fn registration(
mut self,
value: impl Into<crate::org_passingreads::book::RegistrationView<'a>>,
) -> StatefulBookBuilder<'a, stateful_book_state::SetRegistration<S>> {
self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
StatefulBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> StatefulBookBuilder<'a, S>
where
S: stateful_book_state::State,
S::State: stateful_book_state::IsUnset,
{
pub fn state(
mut self,
value: impl Into<StatefulBookState<'a>>,
) -> StatefulBookBuilder<'a, stateful_book_state::SetState<S>> {
self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
StatefulBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> StatefulBookBuilder<'a, S>
where
S: stateful_book_state::State,
S::Uri: stateful_book_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<jacquard_common::types::string::AtUri<'a>>,
) -> StatefulBookBuilder<'a, stateful_book_state::SetUri<S>> {
self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
StatefulBookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> StatefulBookBuilder<'a, S>
where
S: stateful_book_state::State,
S::Registration: stateful_book_state::IsSet,
S::CurrentHolder: stateful_book_state::IsSet,
S::State: stateful_book_state::IsSet,
S::Cid: stateful_book_state::IsSet,
S::Uri: stateful_book_state::IsSet,
{
pub fn build(self) -> StatefulBook<'a> {
StatefulBook {
aspect_ratio: self.__unsafe_private_named.0,
cid: self.__unsafe_private_named.1.unwrap(),
cover_url: self.__unsafe_private_named.2,
current_holder: self.__unsafe_private_named.3.unwrap(),
current_location: self.__unsafe_private_named.4,
events: self.__unsafe_private_named.5,
registration: self.__unsafe_private_named.6.unwrap(),
state: self.__unsafe_private_named.7.unwrap(),
uri: self.__unsafe_private_named.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> StatefulBook<'a> {
StatefulBook {
aspect_ratio: self.__unsafe_private_named.0,
cid: self.__unsafe_private_named.1.unwrap(),
cover_url: self.__unsafe_private_named.2,
current_holder: self.__unsafe_private_named.3.unwrap(),
current_location: self.__unsafe_private_named.4,
events: self.__unsafe_private_named.5,
registration: self.__unsafe_private_named.6.unwrap(),
state: self.__unsafe_private_named.7.unwrap(),
uri: self.__unsafe_private_named.8.unwrap(),
extra_data: Some(extra_data),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum StatefulBookState<'a> {
OrgPassingreadsBookCheckin,
OrgPassingreadsBookDrop,
OrgPassingreadsBookFind,
OrgPassingreadsBookRegistration,
Other(jacquard_common::CowStr<'a>),
}
impl<'a> StatefulBookState<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::OrgPassingreadsBookCheckin => "org.passingreads.book.checkin",
Self::OrgPassingreadsBookDrop => "org.passingreads.book.drop",
Self::OrgPassingreadsBookFind => "org.passingreads.book.find",
Self::OrgPassingreadsBookRegistration => "org.passingreads.book.registration",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for StatefulBookState<'a> {
fn from(s: &'a str) -> Self {
match s {
"org.passingreads.book.checkin" => Self::OrgPassingreadsBookCheckin,
"org.passingreads.book.drop" => Self::OrgPassingreadsBookDrop,
"org.passingreads.book.find" => Self::OrgPassingreadsBookFind,
"org.passingreads.book.registration" => Self::OrgPassingreadsBookRegistration,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> From<String> for StatefulBookState<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"org.passingreads.book.checkin" => Self::OrgPassingreadsBookCheckin,
"org.passingreads.book.drop" => Self::OrgPassingreadsBookDrop,
"org.passingreads.book.find" => Self::OrgPassingreadsBookFind,
"org.passingreads.book.registration" => Self::OrgPassingreadsBookRegistration,
_ => Self::Other(jacquard_common::CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for StatefulBookState<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for StatefulBookState<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for StatefulBookState<'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 StatefulBookState<'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 StatefulBookState<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for StatefulBookState<'_> {
type Output = StatefulBookState<'static>;
fn into_static(self) -> Self::Output {
match self {
StatefulBookState::OrgPassingreadsBookCheckin => {
StatefulBookState::OrgPassingreadsBookCheckin
}
StatefulBookState::OrgPassingreadsBookDrop => {
StatefulBookState::OrgPassingreadsBookDrop
}
StatefulBookState::OrgPassingreadsBookFind => {
StatefulBookState::OrgPassingreadsBookFind
}
StatefulBookState::OrgPassingreadsBookRegistration => {
StatefulBookState::OrgPassingreadsBookRegistration
}
StatefulBookState::Other(v) => StatefulBookState::Other(v.into_static()),
}
}
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for StatefulBook<'a> {
fn nsid() -> &'static str {
"org.passingreads.book.defs"
}
fn def_name() -> &'static str {
"statefulBook"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_org_passingreads_book_defs()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
Ok(())
}
}