#[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::expedition::camp;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CampConditions<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub light_level: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub weather: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CampLight<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub at_break: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub at_camp: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub regenerated: Option<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",
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.expedition.camp",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Camp<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub broke_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub camp_number: Option<i64>,
pub camped_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub conditions: Option<camp::CampConditions<S>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<i64>,
pub expedition_ref: AtUri<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub light: Option<camp::CampLight<S>>,
pub reason: S,
pub signature: camp::ChronicleSignature<S>,
pub status: 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 CampGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Camp<S>,
}
impl<S: BosStr> Camp<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CampRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for CampConditions<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.expedition.camp"
}
fn def_name() -> &'static str {
"campConditions"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_expedition_camp()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CampLight<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.expedition.camp"
}
fn def_name() -> &'static str {
"campLight"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_expedition_camp()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.at_break {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("at_break"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.at_camp {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("at_camp"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.regenerated {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("regenerated"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ChronicleSignature<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.expedition.camp"
}
fn def_name() -> &'static str {
"chronicleSignature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_expedition_camp()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CampRecord;
impl XrpcResp for CampRecord {
const NSID: &'static str = "net.anisota.chronicle.expedition.camp";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CampGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CampGetRecordOutput<S>> for Camp<S> {
fn from(output: CampGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Camp<S> {
const NSID: &'static str = "net.anisota.chronicle.expedition.camp";
type Record = CampRecord;
}
impl Collection for CampRecord {
const NSID: &'static str = "net.anisota.chronicle.expedition.camp";
type Record = CampRecord;
}
impl<S: BosStr> LexiconSchema for Camp<S> {
fn nsid() -> &'static str {
"net.anisota.chronicle.expedition.camp"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_chronicle_expedition_camp()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.camp_number {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("camp_number"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.duration {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("duration"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
fn lexicon_doc_net_anisota_chronicle_expedition_camp() -> 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.expedition.camp"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("campConditions"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Environmental conditions when camp was made",
)),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("lightLevel"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Time-of-day light condition when camp was made",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("weather"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Weather condition when camp was made",
)),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("campLight"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Light levels at camp start/end")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("atBreak"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("atCamp"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("regenerated"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
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(
"Camp record. Created when a user makes camp during an expedition. Updated when camp is broken. References the parent expedition record via AT URI.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("expeditionRef"),
SmolStr::new_static("status"),
SmolStr::new_static("campedAt"),
SmolStr::new_static("reason"),
SmolStr::new_static("signature"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("brokeAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When camp was broken (only set when status is 'completed')",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("campNumber"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("campedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When camp was set up"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("conditions"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#campConditions"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the record was created"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("duration"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("expeditionRef"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT URI of the parent expedition record (net.anisota.chronicle.expedition)",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("light"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#campLight"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reason"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Why camp was made")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signature"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#chronicleSignature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Whether the camp is currently active or has been broken",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the record was last updated (set on break camp)",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
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),
}
}
}
pub mod camp_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 CampedAt;
type CreatedAt;
type ExpeditionRef;
type Reason;
type Signature;
type Status;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CampedAt = Unset;
type CreatedAt = Unset;
type ExpeditionRef = Unset;
type Reason = Unset;
type Signature = Unset;
type Status = Unset;
}
pub struct SetCampedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCampedAt<St> {}
impl<St: State> State for SetCampedAt<St> {
type CampedAt = Set<members::camped_at>;
type CreatedAt = St::CreatedAt;
type ExpeditionRef = St::ExpeditionRef;
type Reason = St::Reason;
type Signature = St::Signature;
type Status = St::Status;
}
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 CampedAt = St::CampedAt;
type CreatedAt = Set<members::created_at>;
type ExpeditionRef = St::ExpeditionRef;
type Reason = St::Reason;
type Signature = St::Signature;
type Status = St::Status;
}
pub struct SetExpeditionRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetExpeditionRef<St> {}
impl<St: State> State for SetExpeditionRef<St> {
type CampedAt = St::CampedAt;
type CreatedAt = St::CreatedAt;
type ExpeditionRef = Set<members::expedition_ref>;
type Reason = St::Reason;
type Signature = St::Signature;
type Status = St::Status;
}
pub struct SetReason<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetReason<St> {}
impl<St: State> State for SetReason<St> {
type CampedAt = St::CampedAt;
type CreatedAt = St::CreatedAt;
type ExpeditionRef = St::ExpeditionRef;
type Reason = Set<members::reason>;
type Signature = St::Signature;
type Status = St::Status;
}
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 CampedAt = St::CampedAt;
type CreatedAt = St::CreatedAt;
type ExpeditionRef = St::ExpeditionRef;
type Reason = St::Reason;
type Signature = Set<members::signature>;
type Status = St::Status;
}
pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStatus<St> {}
impl<St: State> State for SetStatus<St> {
type CampedAt = St::CampedAt;
type CreatedAt = St::CreatedAt;
type ExpeditionRef = St::ExpeditionRef;
type Reason = St::Reason;
type Signature = St::Signature;
type Status = Set<members::status>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct camped_at(());
pub struct created_at(());
pub struct expedition_ref(());
pub struct reason(());
pub struct signature(());
pub struct status(());
}
}
pub struct CampBuilder<St: camp_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<i64>,
Option<Datetime>,
Option<camp::CampConditions<S>>,
Option<Datetime>,
Option<i64>,
Option<AtUri<S>>,
Option<camp::CampLight<S>>,
Option<S>,
Option<camp::ChronicleSignature<S>>,
Option<S>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl Camp<DefaultStr> {
pub fn new() -> CampBuilder<camp_state::Empty, DefaultStr> {
CampBuilder::new()
}
}
impl<S: BosStr> Camp<S> {
pub fn builder() -> CampBuilder<camp_state::Empty, S> {
CampBuilder::builder()
}
}
impl CampBuilder<camp_state::Empty, DefaultStr> {
pub fn new() -> Self {
CampBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr> CampBuilder<camp_state::Empty, S> {
pub fn builder() -> Self {
CampBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<St: camp_state::State, S: BosStr> CampBuilder<St, S> {
pub fn broke_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_broke_at(mut self, value: Option<Datetime>) -> Self {
self._fields.0 = value;
self
}
}
impl<St: camp_state::State, S: BosStr> CampBuilder<St, S> {
pub fn camp_number(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_camp_number(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::CampedAt: camp_state::IsUnset,
{
pub fn camped_at(
mut self,
value: impl Into<Datetime>,
) -> CampBuilder<camp_state::SetCampedAt<St>, S> {
self._fields.2 = Option::Some(value.into());
CampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: camp_state::State, S: BosStr> CampBuilder<St, S> {
pub fn conditions(mut self, value: impl Into<Option<camp::CampConditions<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_conditions(mut self, value: Option<camp::CampConditions<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::CreatedAt: camp_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> CampBuilder<camp_state::SetCreatedAt<St>, S> {
self._fields.4 = Option::Some(value.into());
CampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: camp_state::State, S: BosStr> CampBuilder<St, S> {
pub fn duration(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_duration(mut self, value: Option<i64>) -> Self {
self._fields.5 = value;
self
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::ExpeditionRef: camp_state::IsUnset,
{
pub fn expedition_ref(
mut self,
value: impl Into<AtUri<S>>,
) -> CampBuilder<camp_state::SetExpeditionRef<St>, S> {
self._fields.6 = Option::Some(value.into());
CampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: camp_state::State, S: BosStr> CampBuilder<St, S> {
pub fn light(mut self, value: impl Into<Option<camp::CampLight<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_light(mut self, value: Option<camp::CampLight<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::Reason: camp_state::IsUnset,
{
pub fn reason(mut self, value: impl Into<S>) -> CampBuilder<camp_state::SetReason<St>, S> {
self._fields.8 = Option::Some(value.into());
CampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::Signature: camp_state::IsUnset,
{
pub fn signature(
mut self,
value: impl Into<camp::ChronicleSignature<S>>,
) -> CampBuilder<camp_state::SetSignature<St>, S> {
self._fields.9 = Option::Some(value.into());
CampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::Status: camp_state::IsUnset,
{
pub fn status(mut self, value: impl Into<S>) -> CampBuilder<camp_state::SetStatus<St>, S> {
self._fields.10 = Option::Some(value.into());
CampBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: camp_state::State, S: BosStr> CampBuilder<St, S> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.11 = value;
self
}
}
impl<St, S: BosStr> CampBuilder<St, S>
where
St: camp_state::State,
St::CampedAt: camp_state::IsSet,
St::CreatedAt: camp_state::IsSet,
St::ExpeditionRef: camp_state::IsSet,
St::Reason: camp_state::IsSet,
St::Signature: camp_state::IsSet,
St::Status: camp_state::IsSet,
{
pub fn build(self) -> Camp<S> {
Camp {
broke_at: self._fields.0,
camp_number: self._fields.1,
camped_at: self._fields.2.unwrap(),
conditions: self._fields.3,
created_at: self._fields.4.unwrap(),
duration: self._fields.5,
expedition_ref: self._fields.6.unwrap(),
light: self._fields.7,
reason: self._fields.8.unwrap(),
signature: self._fields.9.unwrap(),
status: self._fields.10.unwrap(),
updated_at: self._fields.11,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Camp<S> {
Camp {
broke_at: self._fields.0,
camp_number: self._fields.1,
camped_at: self._fields.2.unwrap(),
conditions: self._fields.3,
created_at: self._fields.4.unwrap(),
duration: self._fields.5,
expedition_ref: self._fields.6.unwrap(),
light: self._fields.7,
reason: self._fields.8.unwrap(),
signature: self._fields.9.unwrap(),
status: self._fields.10.unwrap(),
updated_at: self._fields.11,
extra_data: Some(extra_data),
}
}
}