#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, 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};
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::world_ptah::temp::character;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CharacterProperties<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub abilities: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub affiliation: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub age: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub role: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub species: Option<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 = "world.ptah.temp.character",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Character<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub authorship_record: Option<Did<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub canonical_status: Option<CharacterCanonicalStatus<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub control_type: Option<CharacterControlType<S>>,
pub created_at: Datetime,
pub creator_did: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub origin_type: Option<CharacterOriginType<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<character::CharacterProperties<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub role_reference: Option<AtUri<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source_reference: Option<S>,
pub world_reference: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CharacterCanonicalStatus<S: BosStr = DefaultStr> {
CanonicalStatusOfficial,
CanonicalStatusCommunity,
CanonicalStatusApocryphal,
Other(S),
}
impl<S: BosStr> CharacterCanonicalStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::CanonicalStatusOfficial => {
"world.ptah.temp.defs#canonicalStatusOfficial"
}
Self::CanonicalStatusCommunity => {
"world.ptah.temp.defs#canonicalStatusCommunity"
}
Self::CanonicalStatusApocryphal => {
"world.ptah.temp.defs#canonicalStatusApocryphal"
}
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"world.ptah.temp.defs#canonicalStatusOfficial" => {
Self::CanonicalStatusOfficial
}
"world.ptah.temp.defs#canonicalStatusCommunity" => {
Self::CanonicalStatusCommunity
}
"world.ptah.temp.defs#canonicalStatusApocryphal" => {
Self::CanonicalStatusApocryphal
}
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for CharacterCanonicalStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for CharacterCanonicalStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for CharacterCanonicalStatus<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for CharacterCanonicalStatus<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for CharacterCanonicalStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for CharacterCanonicalStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = CharacterCanonicalStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
CharacterCanonicalStatus::CanonicalStatusOfficial => {
CharacterCanonicalStatus::CanonicalStatusOfficial
}
CharacterCanonicalStatus::CanonicalStatusCommunity => {
CharacterCanonicalStatus::CanonicalStatusCommunity
}
CharacterCanonicalStatus::CanonicalStatusApocryphal => {
CharacterCanonicalStatus::CanonicalStatusApocryphal
}
CharacterCanonicalStatus::Other(v) => {
CharacterCanonicalStatus::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CharacterControlType<S: BosStr = DefaultStr> {
Exclusive,
Open,
Delegated,
Other(S),
}
impl<S: BosStr> CharacterControlType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Exclusive => "exclusive",
Self::Open => "open",
Self::Delegated => "delegated",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"exclusive" => Self::Exclusive,
"open" => Self::Open,
"delegated" => Self::Delegated,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for CharacterControlType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for CharacterControlType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for CharacterControlType<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for CharacterControlType<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for CharacterControlType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for CharacterControlType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = CharacterControlType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
CharacterControlType::Exclusive => CharacterControlType::Exclusive,
CharacterControlType::Open => CharacterControlType::Open,
CharacterControlType::Delegated => CharacterControlType::Delegated,
CharacterControlType::Other(v) => {
CharacterControlType::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CharacterOriginType<S: BosStr = DefaultStr> {
SourceTypeOriginalIp,
SourceTypePublicDomain,
Contributed,
Other(S),
}
impl<S: BosStr> CharacterOriginType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::SourceTypeOriginalIp => "world.ptah.temp.defs#sourceTypeOriginalIP",
Self::SourceTypePublicDomain => "world.ptah.temp.defs#sourceTypePublicDomain",
Self::Contributed => "contributed",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"world.ptah.temp.defs#sourceTypeOriginalIP" => Self::SourceTypeOriginalIp,
"world.ptah.temp.defs#sourceTypePublicDomain" => Self::SourceTypePublicDomain,
"contributed" => Self::Contributed,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for CharacterOriginType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for CharacterOriginType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for CharacterOriginType<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for CharacterOriginType<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for CharacterOriginType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for CharacterOriginType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = CharacterOriginType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
CharacterOriginType::SourceTypeOriginalIp => {
CharacterOriginType::SourceTypeOriginalIp
}
CharacterOriginType::SourceTypePublicDomain => {
CharacterOriginType::SourceTypePublicDomain
}
CharacterOriginType::Contributed => CharacterOriginType::Contributed,
CharacterOriginType::Other(v) => CharacterOriginType::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CharacterGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Character<S>,
}
impl<S: BosStr> Character<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CharacterRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for CharacterProperties<S> {
fn nsid() -> &'static str {
"world.ptah.temp.character"
}
fn def_name() -> &'static str {
"characterProperties"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_world_ptah_temp_character()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.abilities {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2560usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("abilities"),
max: 2560usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.abilities {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("abilities"),
max: 256usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.affiliation {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("affiliation"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.affiliation {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("affiliation"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.age {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("age"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.age {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("age"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.role {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("role"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.role {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("role"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.species {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("species"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.species {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("species"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CharacterRecord;
impl XrpcResp for CharacterRecord {
const NSID: &'static str = "world.ptah.temp.character";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CharacterGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CharacterGetRecordOutput<S>> for Character<S> {
fn from(output: CharacterGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Character<S> {
const NSID: &'static str = "world.ptah.temp.character";
type Record = CharacterRecord;
}
impl Collection for CharacterRecord {
const NSID: &'static str = "world.ptah.temp.character";
type Record = CharacterRecord;
}
impl<S: BosStr> LexiconSchema for Character<S> {
fn nsid() -> &'static str {
"world.ptah.temp.character"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_world_ptah_temp_character()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10240usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 10240usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.description {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1024usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 1024usize,
actual: count,
});
}
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("name"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.source_reference {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10240usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("source_reference"),
max: 10240usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.source_reference {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1024usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("source_reference"),
max: 1024usize,
actual: count,
});
}
}
}
Ok(())
}
}
fn lexicon_doc_world_ptah_temp_character() -> 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("world.ptah.temp.character"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("characterProperties"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Flexible key-value properties for any kind of world. All fields optional — worlds define what matters.",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("abilities"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Notable abilities or powers."),
),
max_length: Some(2560usize),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("affiliation"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("age"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("role"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Narrative or social role within the world.",
),
),
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("species"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A birth certificate crossed with a passport. Ptah speaks the name and the thing exists — the character exists because it was named and the naming is permanent.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"),
SmolStr::new_static("creatorDID"),
SmolStr::new_static("worldReference"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("authorshipRecord"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Permanent, immutable link back to the creator. This never changes even if the character gets contributed to, built on, or rendered a thousand different ways.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("canonicalStatus"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The canonical standing of this character within its world.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("controlType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"How control of this character is governed. Solves the Ghost Character problem in public domain worlds.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Timestamp of character creation."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("creatorDID"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Who created this character. This never changes — it is the provenance that travels.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Who this character is, in plain language.",
),
),
max_length: Some(10240usize),
max_graphemes: Some(1024usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("What the character is called."),
),
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("originType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The intellectual property origin of this character.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("properties"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#characterProperties"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("roleReference"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The AT URI of the Role record this character is an instance of. If present, this character is a specific performance of a shared role rather than a wholly original character.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sourceReference"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"If originType is publicDomain, the specific source.",
),
),
max_length: Some(10240usize),
max_graphemes: Some(1024usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("worldReference"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The AT URI of the world record this character belongs to.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod character_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 Name;
type WorldReference;
type CreatorDid;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type WorldReference = Unset;
type CreatorDid = Unset;
type CreatedAt = Unset;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Name = Set<members::name>;
type WorldReference = St::WorldReference;
type CreatorDid = St::CreatorDid;
type CreatedAt = St::CreatedAt;
}
pub struct SetWorldReference<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWorldReference<St> {}
impl<St: State> State for SetWorldReference<St> {
type Name = St::Name;
type WorldReference = Set<members::world_reference>;
type CreatorDid = St::CreatorDid;
type CreatedAt = St::CreatedAt;
}
pub struct SetCreatorDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatorDid<St> {}
impl<St: State> State for SetCreatorDid<St> {
type Name = St::Name;
type WorldReference = St::WorldReference;
type CreatorDid = Set<members::creator_did>;
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 Name = St::Name;
type WorldReference = St::WorldReference;
type CreatorDid = St::CreatorDid;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct world_reference(());
pub struct creator_did(());
pub struct created_at(());
}
}
pub struct CharacterBuilder<S: BosStr, St: character_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<CharacterCanonicalStatus<S>>,
Option<CharacterControlType<S>>,
Option<Datetime>,
Option<Did<S>>,
Option<S>,
Option<S>,
Option<CharacterOriginType<S>>,
Option<character::CharacterProperties<S>>,
Option<AtUri<S>>,
Option<S>,
Option<AtUri<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Character<S> {
pub fn new() -> CharacterBuilder<S, character_state::Empty> {
CharacterBuilder::new()
}
}
impl<S: BosStr> CharacterBuilder<S, character_state::Empty> {
pub fn new() -> Self {
CharacterBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn authorship_record(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_authorship_record(mut self, value: Option<Did<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn canonical_status(
mut self,
value: impl Into<Option<CharacterCanonicalStatus<S>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_canonical_status(
mut self,
value: Option<CharacterCanonicalStatus<S>>,
) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn control_type(
mut self,
value: impl Into<Option<CharacterControlType<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_control_type(mut self, value: Option<CharacterControlType<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> CharacterBuilder<S, St>
where
St: character_state::State,
St::CreatedAt: character_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> CharacterBuilder<S, character_state::SetCreatedAt<St>> {
self._fields.3 = Option::Some(value.into());
CharacterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CharacterBuilder<S, St>
where
St: character_state::State,
St::CreatorDid: character_state::IsUnset,
{
pub fn creator_did(
mut self,
value: impl Into<Did<S>>,
) -> CharacterBuilder<S, character_state::SetCreatorDid<St>> {
self._fields.4 = Option::Some(value.into());
CharacterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St> CharacterBuilder<S, St>
where
St: character_state::State,
St::Name: character_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> CharacterBuilder<S, character_state::SetName<St>> {
self._fields.6 = Option::Some(value.into());
CharacterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn origin_type(
mut self,
value: impl Into<Option<CharacterOriginType<S>>>,
) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_origin_type(mut self, value: Option<CharacterOriginType<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn properties(
mut self,
value: impl Into<Option<character::CharacterProperties<S>>>,
) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_properties(
mut self,
value: Option<character::CharacterProperties<S>>,
) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn role_reference(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_role_reference(mut self, value: Option<AtUri<S>>) -> Self {
self._fields.9 = value;
self
}
}
impl<S: BosStr, St: character_state::State> CharacterBuilder<S, St> {
pub fn source_reference(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_source_reference(mut self, value: Option<S>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> CharacterBuilder<S, St>
where
St: character_state::State,
St::WorldReference: character_state::IsUnset,
{
pub fn world_reference(
mut self,
value: impl Into<AtUri<S>>,
) -> CharacterBuilder<S, character_state::SetWorldReference<St>> {
self._fields.11 = Option::Some(value.into());
CharacterBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CharacterBuilder<S, St>
where
St: character_state::State,
St::Name: character_state::IsSet,
St::WorldReference: character_state::IsSet,
St::CreatorDid: character_state::IsSet,
St::CreatedAt: character_state::IsSet,
{
pub fn build(self) -> Character<S> {
Character {
authorship_record: self._fields.0,
canonical_status: self._fields.1,
control_type: self._fields.2,
created_at: self._fields.3.unwrap(),
creator_did: self._fields.4.unwrap(),
description: self._fields.5,
name: self._fields.6.unwrap(),
origin_type: self._fields.7,
properties: self._fields.8,
role_reference: self._fields.9,
source_reference: self._fields.10,
world_reference: self._fields.11.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> Character<S> {
Character {
authorship_record: self._fields.0,
canonical_status: self._fields.1,
control_type: self._fields.2,
created_at: self._fields.3.unwrap(),
creator_did: self._fields.4.unwrap(),
description: self._fields.5,
name: self._fields.6.unwrap(),
origin_type: self._fields.7,
properties: self._fields.8,
role_reference: self._fields.9,
source_reference: self._fields.10,
world_reference: self._fields.11.unwrap(),
extra_data: Some(extra_data),
}
}
}