#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, Handle, AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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_shinolabs::pinksea::app_view_defs;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Author<S: BosStr = DefaultStr> {
pub did: Did<S>,
pub handle: Handle<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct HydratedOekaki<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
pub at: UriValue<S>,
pub author: app_view_defs::Author<S>,
pub cid: Cid<S>,
pub creation_time: Datetime,
pub image: UriValue<S>,
pub nsfw: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct OekakiTombstone<S: BosStr = DefaultStr> {
pub former_at: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Author<S> {
fn nsid() -> &'static str {
"com.shinolabs.pinksea.appViewDefs"
}
fn def_name() -> &'static str {
"author"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_shinolabs_pinksea_appViewDefs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for HydratedOekaki<S> {
fn nsid() -> &'static str {
"com.shinolabs.pinksea.appViewDefs"
}
fn def_name() -> &'static str {
"hydratedOekaki"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_shinolabs_pinksea_appViewDefs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.tags {
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("tags"),
max: 10usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for OekakiTombstone<S> {
fn nsid() -> &'static str {
"com.shinolabs.pinksea.appViewDefs"
}
fn def_name() -> &'static str {
"oekakiTombstone"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_shinolabs_pinksea_appViewDefs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod author_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;
type Handle;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
type Handle = Unset;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
type Handle = St::Handle;
}
pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHandle<St> {}
impl<St: State> State for SetHandle<St> {
type Did = St::Did;
type Handle = Set<members::handle>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
pub struct handle(());
}
}
pub struct AuthorBuilder<S: BosStr, St: author_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>, Option<Handle<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Author<S> {
pub fn new() -> AuthorBuilder<S, author_state::Empty> {
AuthorBuilder::new()
}
}
impl<S: BosStr> AuthorBuilder<S, author_state::Empty> {
pub fn new() -> Self {
AuthorBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AuthorBuilder<S, St>
where
St: author_state::State,
St::Did: author_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> AuthorBuilder<S, author_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
AuthorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AuthorBuilder<S, St>
where
St: author_state::State,
St::Handle: author_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<Handle<S>>,
) -> AuthorBuilder<S, author_state::SetHandle<St>> {
self._fields.1 = Option::Some(value.into());
AuthorBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AuthorBuilder<S, St>
where
St: author_state::State,
St::Did: author_state::IsSet,
St::Handle: author_state::IsSet,
{
pub fn build(self) -> Author<S> {
Author {
did: self._fields.0.unwrap(),
handle: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Author<S> {
Author {
did: self._fields.0.unwrap(),
handle: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_shinolabs_pinksea_appViewDefs() -> 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("com.shinolabs.pinksea.appViewDefs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("An author for an oekaki post"),
),
required: Some(
vec![SmolStr::new_static("did"), SmolStr::new_static("handle")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The DID of the author"),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The handle of the author."),
),
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hydratedOekaki"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A hydrated oekaki post returned from the PinkSea app view.",
),
),
required: Some(
vec![
SmolStr::new_static("author"), SmolStr::new_static("image"),
SmolStr::new_static("at"), SmolStr::new_static("cid"),
SmolStr::new_static("creationTime"),
SmolStr::new_static("nsfw")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Alt text description of the image, for accessibility.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("at"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The AT protocol link."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#author"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The oekaki CID.")),
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("creationTime"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The creation time.")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("image"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The image link.")),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("nsfw"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tags"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("An array of tags this image had."),
),
items: LexArrayItem::String(LexString {
max_length: Some(640usize),
..Default::default()
}),
max_length: Some(10usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("oekakiTombstone"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("A tombstone for a missing oekaki."),
),
required: Some(vec![SmolStr::new_static("formerAt")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("formerAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The AT uri of the former oekaki."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod hydrated_oekaki_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 Image;
type CreationTime;
type Nsfw;
type Cid;
type Author;
type At;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Image = Unset;
type CreationTime = Unset;
type Nsfw = Unset;
type Cid = Unset;
type Author = Unset;
type At = Unset;
}
pub struct SetImage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetImage<St> {}
impl<St: State> State for SetImage<St> {
type Image = Set<members::image>;
type CreationTime = St::CreationTime;
type Nsfw = St::Nsfw;
type Cid = St::Cid;
type Author = St::Author;
type At = St::At;
}
pub struct SetCreationTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreationTime<St> {}
impl<St: State> State for SetCreationTime<St> {
type Image = St::Image;
type CreationTime = Set<members::creation_time>;
type Nsfw = St::Nsfw;
type Cid = St::Cid;
type Author = St::Author;
type At = St::At;
}
pub struct SetNsfw<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNsfw<St> {}
impl<St: State> State for SetNsfw<St> {
type Image = St::Image;
type CreationTime = St::CreationTime;
type Nsfw = Set<members::nsfw>;
type Cid = St::Cid;
type Author = St::Author;
type At = St::At;
}
pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCid<St> {}
impl<St: State> State for SetCid<St> {
type Image = St::Image;
type CreationTime = St::CreationTime;
type Nsfw = St::Nsfw;
type Cid = Set<members::cid>;
type Author = St::Author;
type At = St::At;
}
pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAuthor<St> {}
impl<St: State> State for SetAuthor<St> {
type Image = St::Image;
type CreationTime = St::CreationTime;
type Nsfw = St::Nsfw;
type Cid = St::Cid;
type Author = Set<members::author>;
type At = St::At;
}
pub struct SetAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAt<St> {}
impl<St: State> State for SetAt<St> {
type Image = St::Image;
type CreationTime = St::CreationTime;
type Nsfw = St::Nsfw;
type Cid = St::Cid;
type Author = St::Author;
type At = Set<members::at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct image(());
pub struct creation_time(());
pub struct nsfw(());
pub struct cid(());
pub struct author(());
pub struct at(());
}
}
pub struct HydratedOekakiBuilder<S: BosStr, St: hydrated_oekaki_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<UriValue<S>>,
Option<app_view_defs::Author<S>>,
Option<Cid<S>>,
Option<Datetime>,
Option<UriValue<S>>,
Option<bool>,
Option<Vec<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> HydratedOekaki<S> {
pub fn new() -> HydratedOekakiBuilder<S, hydrated_oekaki_state::Empty> {
HydratedOekakiBuilder::new()
}
}
impl<S: BosStr> HydratedOekakiBuilder<S, hydrated_oekaki_state::Empty> {
pub fn new() -> Self {
HydratedOekakiBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: hydrated_oekaki_state::State> HydratedOekakiBuilder<S, St> {
pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::At: hydrated_oekaki_state::IsUnset,
{
pub fn at(
mut self,
value: impl Into<UriValue<S>>,
) -> HydratedOekakiBuilder<S, hydrated_oekaki_state::SetAt<St>> {
self._fields.1 = Option::Some(value.into());
HydratedOekakiBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::Author: hydrated_oekaki_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<app_view_defs::Author<S>>,
) -> HydratedOekakiBuilder<S, hydrated_oekaki_state::SetAuthor<St>> {
self._fields.2 = Option::Some(value.into());
HydratedOekakiBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::Cid: hydrated_oekaki_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> HydratedOekakiBuilder<S, hydrated_oekaki_state::SetCid<St>> {
self._fields.3 = Option::Some(value.into());
HydratedOekakiBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::CreationTime: hydrated_oekaki_state::IsUnset,
{
pub fn creation_time(
mut self,
value: impl Into<Datetime>,
) -> HydratedOekakiBuilder<S, hydrated_oekaki_state::SetCreationTime<St>> {
self._fields.4 = Option::Some(value.into());
HydratedOekakiBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::Image: hydrated_oekaki_state::IsUnset,
{
pub fn image(
mut self,
value: impl Into<UriValue<S>>,
) -> HydratedOekakiBuilder<S, hydrated_oekaki_state::SetImage<St>> {
self._fields.5 = Option::Some(value.into());
HydratedOekakiBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::Nsfw: hydrated_oekaki_state::IsUnset,
{
pub fn nsfw(
mut self,
value: impl Into<bool>,
) -> HydratedOekakiBuilder<S, hydrated_oekaki_state::SetNsfw<St>> {
self._fields.6 = Option::Some(value.into());
HydratedOekakiBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: hydrated_oekaki_state::State> HydratedOekakiBuilder<S, St> {
pub fn tags(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_tags(mut self, value: Option<Vec<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St> HydratedOekakiBuilder<S, St>
where
St: hydrated_oekaki_state::State,
St::Image: hydrated_oekaki_state::IsSet,
St::CreationTime: hydrated_oekaki_state::IsSet,
St::Nsfw: hydrated_oekaki_state::IsSet,
St::Cid: hydrated_oekaki_state::IsSet,
St::Author: hydrated_oekaki_state::IsSet,
St::At: hydrated_oekaki_state::IsSet,
{
pub fn build(self) -> HydratedOekaki<S> {
HydratedOekaki {
alt: self._fields.0,
at: self._fields.1.unwrap(),
author: self._fields.2.unwrap(),
cid: self._fields.3.unwrap(),
creation_time: self._fields.4.unwrap(),
image: self._fields.5.unwrap(),
nsfw: self._fields.6.unwrap(),
tags: self._fields.7,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> HydratedOekaki<S> {
HydratedOekaki {
alt: self._fields.0,
at: self._fields.1.unwrap(),
author: self._fields.2.unwrap(),
cid: self._fields.3.unwrap(),
creation_time: self._fields.4.unwrap(),
image: self._fields.5.unwrap(),
nsfw: self._fields.6.unwrap(),
tags: self._fields.7,
extra_data: Some(extra_data),
}
}
}
pub mod oekaki_tombstone_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 FormerAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type FormerAt = Unset;
}
pub struct SetFormerAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFormerAt<St> {}
impl<St: State> State for SetFormerAt<St> {
type FormerAt = Set<members::former_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct former_at(());
}
}
pub struct OekakiTombstoneBuilder<S: BosStr, St: oekaki_tombstone_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtUri<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> OekakiTombstone<S> {
pub fn new() -> OekakiTombstoneBuilder<S, oekaki_tombstone_state::Empty> {
OekakiTombstoneBuilder::new()
}
}
impl<S: BosStr> OekakiTombstoneBuilder<S, oekaki_tombstone_state::Empty> {
pub fn new() -> Self {
OekakiTombstoneBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> OekakiTombstoneBuilder<S, St>
where
St: oekaki_tombstone_state::State,
St::FormerAt: oekaki_tombstone_state::IsUnset,
{
pub fn former_at(
mut self,
value: impl Into<AtUri<S>>,
) -> OekakiTombstoneBuilder<S, oekaki_tombstone_state::SetFormerAt<St>> {
self._fields.0 = Option::Some(value.into());
OekakiTombstoneBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> OekakiTombstoneBuilder<S, St>
where
St: oekaki_tombstone_state::State,
St::FormerAt: oekaki_tombstone_state::IsSet,
{
pub fn build(self) -> OekakiTombstone<S> {
OekakiTombstone {
former_at: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> OekakiTombstone<S> {
OekakiTombstone {
former_at: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}