#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::com_deckbelcher::CardRef;
use crate::com_deckbelcher::richtext::Document;
use crate::com_deckbelcher::social::comment;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CardSubject<S: BosStr = DefaultStr> {
pub r#ref: CardRef<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 CardTarget<S: BosStr = DefaultStr> {
pub r#ref: CardRef<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 DeckTarget<S: BosStr = DefaultStr> {
pub r#ref: StrongRef<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",
rename = "com.deckbelcher.social.comment",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Comment<S: BosStr = DefaultStr> {
pub content: Document<S>,
pub created_at: Datetime,
pub subject: CommentSubject<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<CommentTarget<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<Datetime>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CommentSubject<S: BosStr = DefaultStr> {
#[serde(rename = "com.deckbelcher.social.comment#cardSubject")]
CardSubject(Box<comment::CardSubject<S>>),
#[serde(rename = "com.deckbelcher.social.comment#recordSubject")]
RecordSubject(Box<comment::RecordSubject<S>>),
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CommentTarget<S: BosStr = DefaultStr> {
#[serde(rename = "com.deckbelcher.social.comment#cardTarget")]
CardTarget(Box<comment::CardTarget<S>>),
#[serde(rename = "com.deckbelcher.social.comment#deckTarget")]
DeckTarget(Box<comment::DeckTarget<S>>),
#[serde(rename = "com.deckbelcher.social.comment#sectionTarget")]
SectionTarget(Box<comment::SectionTarget<S>>),
#[serde(rename = "com.deckbelcher.social.comment#tagTarget")]
TagTarget(Box<comment::TagTarget<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CommentGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Comment<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct RecordSubject<S: BosStr = DefaultStr> {
pub r#ref: StrongRef<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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SectionTarget<S: BosStr = DefaultStr> {
pub section: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct TagTarget<S: BosStr = DefaultStr> {
pub tag: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Comment<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CommentRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for CardSubject<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"cardSubject"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CardTarget<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"cardTarget"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DeckTarget<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"deckTarget"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CommentRecord;
impl XrpcResp for CommentRecord {
const NSID: &'static str = "com.deckbelcher.social.comment";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CommentGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CommentGetRecordOutput<S>> for Comment<S> {
fn from(output: CommentGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Comment<S> {
const NSID: &'static str = "com.deckbelcher.social.comment";
type Record = CommentRecord;
}
impl Collection for CommentRecord {
const NSID: &'static str = "com.deckbelcher.social.comment";
type Record = CommentRecord;
}
impl<S: BosStr> LexiconSchema for Comment<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for RecordSubject<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"recordSubject"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SectionTarget<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"sectionTarget"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.section;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("section"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.section;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("section"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for TagTarget<S> {
fn nsid() -> &'static str {
"com.deckbelcher.social.comment"
}
fn def_name() -> &'static str {
"tagTarget"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_social_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.tag;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("tag"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.tag;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("tag"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod card_subject_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Ref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Ref = Unset;
}
pub struct SetRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRef<St> {}
impl<St: State> State for SetRef<St> {
type Ref = Set<members::r#ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#ref(());
}
}
pub struct CardSubjectBuilder<S: BosStr, St: card_subject_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<CardRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CardSubject<S> {
pub fn new() -> CardSubjectBuilder<S, card_subject_state::Empty> {
CardSubjectBuilder::new()
}
}
impl<S: BosStr> CardSubjectBuilder<S, card_subject_state::Empty> {
pub fn new() -> Self {
CardSubjectBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CardSubjectBuilder<S, St>
where
St: card_subject_state::State,
St::Ref: card_subject_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<CardRef<S>>,
) -> CardSubjectBuilder<S, card_subject_state::SetRef<St>> {
self._fields.0 = Option::Some(value.into());
CardSubjectBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CardSubjectBuilder<S, St>
where
St: card_subject_state::State,
St::Ref: card_subject_state::IsSet,
{
pub fn build(self) -> CardSubject<S> {
CardSubject {
r#ref: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CardSubject<S> {
CardSubject {
r#ref: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_deckbelcher_social_comment() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("com.deckbelcher.social.comment"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cardSubject"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Subject: a card (global comment on the card itself).",
)),
required: Some(vec![SmolStr::new_static("ref")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("ref"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.deckbelcher.defs#cardRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cardTarget"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Target: a card (in a deck or collection).",
)),
required: Some(vec![SmolStr::new_static("ref")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("ref"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.deckbelcher.defs#cardRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("deckTarget"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Target: a deck (in a collection).")),
required: Some(vec![SmolStr::new_static("ref")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("ref"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Top-level comment on a card, deck, or collection.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("subject"),
SmolStr::new_static("content"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"com.deckbelcher.richtext#document",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static("What this comment is on."),
),
refs: vec![
CowStr::new_static("#cardSubject"),
CowStr::new_static("#recordSubject")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("target"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Optional refinement within subject (card/section/tag in a deck).",
),
),
refs: vec![
CowStr::new_static("#cardTarget"),
CowStr::new_static("#deckTarget"),
CowStr::new_static("#sectionTarget"),
CowStr::new_static("#tagTarget")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("recordSubject"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Subject: an ATProto record (deck, collection).",
)),
required: Some(vec![SmolStr::new_static("ref")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("ref"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sectionTarget"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Target: a deck section (mainboard, sideboard, etc).",
)),
required: Some(vec![SmolStr::new_static("section")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("section"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tagTarget"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Target: a tag package (ramp, removal, wincons, etc).",
)),
required: Some(vec![SmolStr::new_static("tag")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("tag"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod card_target_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Ref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Ref = Unset;
}
pub struct SetRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRef<St> {}
impl<St: State> State for SetRef<St> {
type Ref = Set<members::r#ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#ref(());
}
}
pub struct CardTargetBuilder<S: BosStr, St: card_target_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<CardRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CardTarget<S> {
pub fn new() -> CardTargetBuilder<S, card_target_state::Empty> {
CardTargetBuilder::new()
}
}
impl<S: BosStr> CardTargetBuilder<S, card_target_state::Empty> {
pub fn new() -> Self {
CardTargetBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CardTargetBuilder<S, St>
where
St: card_target_state::State,
St::Ref: card_target_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<CardRef<S>>,
) -> CardTargetBuilder<S, card_target_state::SetRef<St>> {
self._fields.0 = Option::Some(value.into());
CardTargetBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CardTargetBuilder<S, St>
where
St: card_target_state::State,
St::Ref: card_target_state::IsSet,
{
pub fn build(self) -> CardTarget<S> {
CardTarget {
r#ref: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CardTarget<S> {
CardTarget {
r#ref: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod deck_target_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Ref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Ref = Unset;
}
pub struct SetRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRef<St> {}
impl<St: State> State for SetRef<St> {
type Ref = Set<members::r#ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#ref(());
}
}
pub struct DeckTargetBuilder<S: BosStr, St: deck_target_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<StrongRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DeckTarget<S> {
pub fn new() -> DeckTargetBuilder<S, deck_target_state::Empty> {
DeckTargetBuilder::new()
}
}
impl<S: BosStr> DeckTargetBuilder<S, deck_target_state::Empty> {
pub fn new() -> Self {
DeckTargetBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeckTargetBuilder<S, St>
where
St: deck_target_state::State,
St::Ref: deck_target_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<StrongRef<S>>,
) -> DeckTargetBuilder<S, deck_target_state::SetRef<St>> {
self._fields.0 = Option::Some(value.into());
DeckTargetBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DeckTargetBuilder<S, St>
where
St: deck_target_state::State,
St::Ref: deck_target_state::IsSet,
{
pub fn build(self) -> DeckTarget<S> {
DeckTarget {
r#ref: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DeckTarget<S> {
DeckTarget {
r#ref: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod comment_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Subject;
type Content;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
type Content = Unset;
type CreatedAt = Unset;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Subject = Set<members::subject>;
type Content = St::Content;
type CreatedAt = St::CreatedAt;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Subject = St::Subject;
type Content = Set<members::content>;
type CreatedAt = St::CreatedAt;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Subject = St::Subject;
type Content = St::Content;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
pub struct content(());
pub struct created_at(());
}
}
pub struct CommentBuilder<S: BosStr, St: comment_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Document<S>>,
Option<Datetime>,
Option<CommentSubject<S>>,
Option<CommentTarget<S>>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Comment<S> {
pub fn new() -> CommentBuilder<S, comment_state::Empty> {
CommentBuilder::new()
}
}
impl<S: BosStr> CommentBuilder<S, comment_state::Empty> {
pub fn new() -> Self {
CommentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommentBuilder<S, St>
where
St: comment_state::State,
St::Content: comment_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<Document<S>>,
) -> CommentBuilder<S, comment_state::SetContent<St>> {
self._fields.0 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommentBuilder<S, St>
where
St: comment_state::State,
St::CreatedAt: comment_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> CommentBuilder<S, comment_state::SetCreatedAt<St>> {
self._fields.1 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommentBuilder<S, St>
where
St: comment_state::State,
St::Subject: comment_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<CommentSubject<S>>,
) -> CommentBuilder<S, comment_state::SetSubject<St>> {
self._fields.2 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: comment_state::State> CommentBuilder<S, St> {
pub fn target(mut self, value: impl Into<Option<CommentTarget<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_target(mut self, value: Option<CommentTarget<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: comment_state::State> CommentBuilder<S, St> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> CommentBuilder<S, St>
where
St: comment_state::State,
St::Subject: comment_state::IsSet,
St::Content: comment_state::IsSet,
St::CreatedAt: comment_state::IsSet,
{
pub fn build(self) -> Comment<S> {
Comment {
content: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
subject: self._fields.2.unwrap(),
target: self._fields.3,
updated_at: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Comment<S> {
Comment {
content: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
subject: self._fields.2.unwrap(),
target: self._fields.3,
updated_at: self._fields.4,
extra_data: Some(extra_data),
}
}
}
pub mod record_subject_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Ref;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Ref = Unset;
}
pub struct SetRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRef<St> {}
impl<St: State> State for SetRef<St> {
type Ref = Set<members::r#ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct r#ref(());
}
}
pub struct RecordSubjectBuilder<S: BosStr, St: record_subject_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<StrongRef<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> RecordSubject<S> {
pub fn new() -> RecordSubjectBuilder<S, record_subject_state::Empty> {
RecordSubjectBuilder::new()
}
}
impl<S: BosStr> RecordSubjectBuilder<S, record_subject_state::Empty> {
pub fn new() -> Self {
RecordSubjectBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RecordSubjectBuilder<S, St>
where
St: record_subject_state::State,
St::Ref: record_subject_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<StrongRef<S>>,
) -> RecordSubjectBuilder<S, record_subject_state::SetRef<St>> {
self._fields.0 = Option::Some(value.into());
RecordSubjectBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RecordSubjectBuilder<S, St>
where
St: record_subject_state::State,
St::Ref: record_subject_state::IsSet,
{
pub fn build(self) -> RecordSubject<S> {
RecordSubject {
r#ref: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> RecordSubject<S> {
RecordSubject {
r#ref: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}