#[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};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::net_anisota::chronicle::inventory;
#[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 ChronicleSignature<S: BosStr = DefaultStr> {
pub alg: S,
pub kid: S,
pub nonce: S,
pub sig: S,
pub signed_at: Datetime,
pub version: i64,
#[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 = "net.anisota.chronicle.inventory",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Inventory<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub consumable: Option<bool>,
pub created_at: Datetime,
pub item_id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub item_name: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub item_type: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Data<S>>,
pub quantity: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub rarity: Option<S>,
pub signature: inventory::ChronicleSignature<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<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>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct InventoryGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Inventory<S>,
}
impl<S: BosStr> Inventory<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, InventoryRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for ChronicleSignature<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.inventory"
}
fn def_name() -> &'static str {
"chronicleSignature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_inventory()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct InventoryRecord;
impl XrpcResp for InventoryRecord {
const NSID: &'static str = "net.anisota.chronicle.inventory";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = InventoryGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<InventoryGetRecordOutput<S>> for Inventory<S> {
fn from(output: InventoryGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Inventory<S> {
const NSID: &'static str = "net.anisota.chronicle.inventory";
type Record = InventoryRecord;
}
impl Collection for InventoryRecord {
const NSID: &'static str = "net.anisota.chronicle.inventory";
type Record = InventoryRecord;
}
impl<S: BosStr> LexiconSchema for Inventory<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.inventory"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_inventory()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.item_id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("item_id"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.item_name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("item_name"),
max: 200usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.item_type {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("item_type"),
max: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.quantity;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("quantity"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
pub mod chronicle_signature_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 Alg;
type Kid;
type Nonce;
type Sig;
type SignedAt;
type Version;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Alg = Unset;
type Kid = Unset;
type Nonce = Unset;
type Sig = Unset;
type SignedAt = Unset;
type Version = Unset;
}
pub struct SetAlg<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAlg<St> {}
impl<St: State> State for SetAlg<St> {
type Alg = Set<members::alg>;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetKid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetKid<St> {}
impl<St: State> State for SetKid<St> {
type Alg = St::Alg;
type Kid = Set<members::kid>;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetNonce<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNonce<St> {}
impl<St: State> State for SetNonce<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = Set<members::nonce>;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetSig<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSig<St> {}
impl<St: State> State for SetSig<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = Set<members::sig>;
type SignedAt = St::SignedAt;
type Version = St::Version;
}
pub struct SetSignedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSignedAt<St> {}
impl<St: State> State for SetSignedAt<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = Set<members::signed_at>;
type Version = St::Version;
}
pub struct SetVersion<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVersion<St> {}
impl<St: State> State for SetVersion<St> {
type Alg = St::Alg;
type Kid = St::Kid;
type Nonce = St::Nonce;
type Sig = St::Sig;
type SignedAt = St::SignedAt;
type Version = Set<members::version>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct alg(());
pub struct kid(());
pub struct nonce(());
pub struct sig(());
pub struct signed_at(());
pub struct version(());
}
}
pub struct ChronicleSignatureBuilder<St: chronicle_signature_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<Datetime>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl ChronicleSignature<DefaultStr> {
pub fn new() -> ChronicleSignatureBuilder<chronicle_signature_state::Empty, DefaultStr> {
ChronicleSignatureBuilder::new()
}
}
impl<S: BosStr> ChronicleSignature<S> {
pub fn builder() -> ChronicleSignatureBuilder<chronicle_signature_state::Empty, S> {
ChronicleSignatureBuilder::builder()
}
}
impl ChronicleSignatureBuilder<chronicle_signature_state::Empty, DefaultStr> {
pub fn new() -> Self {
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> ChronicleSignatureBuilder<chronicle_signature_state::Empty, S> {
pub fn builder() -> Self {
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Alg: chronicle_signature_state::IsUnset,
{
pub fn alg(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetAlg<St>, S> {
self._fields.0 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Kid: chronicle_signature_state::IsUnset,
{
pub fn kid(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetKid<St>, S> {
self._fields.1 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Nonce: chronicle_signature_state::IsUnset,
{
pub fn nonce(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetNonce<St>, S> {
self._fields.2 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Sig: chronicle_signature_state::IsUnset,
{
pub fn sig(
mut self,
value: impl Into<S>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetSig<St>, S> {
self._fields.3 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::SignedAt: chronicle_signature_state::IsUnset,
{
pub fn signed_at(
mut self,
value: impl Into<Datetime>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetSignedAt<St>, S> {
self._fields.4 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Version: chronicle_signature_state::IsUnset,
{
pub fn version(
mut self,
value: impl Into<i64>,
) -> ChronicleSignatureBuilder<chronicle_signature_state::SetVersion<St>, S> {
self._fields.5 = Option::Some(value.into());
ChronicleSignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> ChronicleSignatureBuilder<St, S>
where
St: chronicle_signature_state::State,
St::Alg: chronicle_signature_state::IsSet,
St::Kid: chronicle_signature_state::IsSet,
St::Nonce: chronicle_signature_state::IsSet,
St::Sig: chronicle_signature_state::IsSet,
St::SignedAt: chronicle_signature_state::IsSet,
St::Version: chronicle_signature_state::IsSet,
{
pub fn build(self) -> ChronicleSignature<S> {
ChronicleSignature {
alg: self._fields.0.unwrap(),
kid: self._fields.1.unwrap(),
nonce: self._fields.2.unwrap(),
sig: self._fields.3.unwrap(),
signed_at: self._fields.4.unwrap(),
version: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ChronicleSignature<S> {
ChronicleSignature {
alg: self._fields.0.unwrap(),
kid: self._fields.1.unwrap(),
nonce: self._fields.2.unwrap(),
sig: self._fields.3.unwrap(),
signed_at: self._fields.4.unwrap(),
version: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_net_anisota_chronicle_inventory() -> 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("net.anisota.chronicle.inventory"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("chronicleSignature"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"ES256 cryptographic signature proving record authenticity",
)),
required: Some(vec![
SmolStr::new_static("sig"),
SmolStr::new_static("alg"),
SmolStr::new_static("kid"),
SmolStr::new_static("signedAt"),
SmolStr::new_static("nonce"),
SmolStr::new_static("version"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alg"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Signing algorithm (ES256)")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("kid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Key identifier for the signing key",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("nonce"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Unique random nonce to prevent replay",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sig"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Base64-encoded ES256 signature",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signedAt"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("When the record was signed")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("version"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Item record in the player's inventory. rkey is the item ID. Updated via putRecord when quantities change.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("itemId"),
SmolStr::new_static("quantity"),
SmolStr::new_static("signature"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("consumable"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the item was first acquired"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Unique identifier for the item"),
),
max_length: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Display name of the item"),
),
max_length: Some(200usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Item category: power, camera, light, supplies, field, lore",
),
),
max_length: Some(50usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("metadata"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("quantity"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rarity"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Rarity level of the item"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signature"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#chronicleSignature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("source"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("How the item was acquired"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the record was last updated"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod inventory_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 CreatedAt;
type ItemId;
type Quantity;
type Signature;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type ItemId = Unset;
type Quantity = Unset;
type Signature = Unset;
}
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 CreatedAt = Set<members::created_at>;
type ItemId = St::ItemId;
type Quantity = St::Quantity;
type Signature = St::Signature;
}
pub struct SetItemId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetItemId<St> {}
impl<St: State> State for SetItemId<St> {
type CreatedAt = St::CreatedAt;
type ItemId = Set<members::item_id>;
type Quantity = St::Quantity;
type Signature = St::Signature;
}
pub struct SetQuantity<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetQuantity<St> {}
impl<St: State> State for SetQuantity<St> {
type CreatedAt = St::CreatedAt;
type ItemId = St::ItemId;
type Quantity = Set<members::quantity>;
type Signature = St::Signature;
}
pub struct SetSignature<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSignature<St> {}
impl<St: State> State for SetSignature<St> {
type CreatedAt = St::CreatedAt;
type ItemId = St::ItemId;
type Quantity = St::Quantity;
type Signature = Set<members::signature>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct item_id(());
pub struct quantity(());
pub struct signature(());
}
}
pub struct InventoryBuilder<St: inventory_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<bool>,
Option<Datetime>,
Option<S>,
Option<S>,
Option<S>,
Option<Data<S>>,
Option<i64>,
Option<S>,
Option<inventory::ChronicleSignature<S>>,
Option<S>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl Inventory<DefaultStr> {
pub fn new() -> InventoryBuilder<inventory_state::Empty, DefaultStr> {
InventoryBuilder::new()
}
}
impl<S: BosStr> Inventory<S> {
pub fn builder() -> InventoryBuilder<inventory_state::Empty, S> {
InventoryBuilder::builder()
}
}
impl InventoryBuilder<inventory_state::Empty, DefaultStr> {
pub fn new() -> Self {
InventoryBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr> InventoryBuilder<inventory_state::Empty, S> {
pub fn builder() -> Self {
InventoryBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn consumable(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_consumable(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<St, S: BosStr> InventoryBuilder<St, S>
where
St: inventory_state::State,
St::CreatedAt: inventory_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> InventoryBuilder<inventory_state::SetCreatedAt<St>, S> {
self._fields.1 = Option::Some(value.into());
InventoryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> InventoryBuilder<St, S>
where
St: inventory_state::State,
St::ItemId: inventory_state::IsUnset,
{
pub fn item_id(
mut self,
value: impl Into<S>,
) -> InventoryBuilder<inventory_state::SetItemId<St>, S> {
self._fields.2 = Option::Some(value.into());
InventoryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn item_name(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_item_name(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn item_type(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_item_type(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn metadata(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<Data<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<St, S: BosStr> InventoryBuilder<St, S>
where
St: inventory_state::State,
St::Quantity: inventory_state::IsUnset,
{
pub fn quantity(
mut self,
value: impl Into<i64>,
) -> InventoryBuilder<inventory_state::SetQuantity<St>, S> {
self._fields.6 = Option::Some(value.into());
InventoryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn rarity(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_rarity(mut self, value: Option<S>) -> Self {
self._fields.7 = value;
self
}
}
impl<St, S: BosStr> InventoryBuilder<St, S>
where
St: inventory_state::State,
St::Signature: inventory_state::IsUnset,
{
pub fn signature(
mut self,
value: impl Into<inventory::ChronicleSignature<S>>,
) -> InventoryBuilder<inventory_state::SetSignature<St>, S> {
self._fields.8 = Option::Some(value.into());
InventoryBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn source(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_source(mut self, value: Option<S>) -> Self {
self._fields.9 = value;
self
}
}
impl<St: inventory_state::State, S: BosStr> InventoryBuilder<St, S> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.10 = value;
self
}
}
impl<St, S: BosStr> InventoryBuilder<St, S>
where
St: inventory_state::State,
St::CreatedAt: inventory_state::IsSet,
St::ItemId: inventory_state::IsSet,
St::Quantity: inventory_state::IsSet,
St::Signature: inventory_state::IsSet,
{
pub fn build(self) -> Inventory<S> {
Inventory {
consumable: self._fields.0,
created_at: self._fields.1.unwrap(),
item_id: self._fields.2.unwrap(),
item_name: self._fields.3,
item_type: self._fields.4,
metadata: self._fields.5,
quantity: self._fields.6.unwrap(),
rarity: self._fields.7,
signature: self._fields.8.unwrap(),
source: self._fields.9,
updated_at: self._fields.10,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Inventory<S> {
Inventory {
consumable: self._fields.0,
created_at: self._fields.1.unwrap(),
item_id: self._fields.2.unwrap(),
item_name: self._fields.3,
item_type: self._fields.4,
metadata: self._fields.5,
quantity: self._fields.6.unwrap(),
rarity: self._fields.7,
signature: self._fields.8.unwrap(),
source: self._fields.9,
updated_at: self._fields.10,
extra_data: Some(extra_data),
}
}
}