#[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::{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::net_anisota::beta::game::session;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ActivitySummary<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub current_level: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub current_xp: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub game_actions: Option<session::GameActions<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pages_visited: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_events: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub xp_gained_this_session: 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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GameActions<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub daily_rewards_claimed: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub feeds_loaded: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub items_collected: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub level_ups: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub posts_viewed: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub specimens_collected: 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",
rename = "net.anisota.beta.game.session",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Session<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_summary: Option<session::ActivitySummary<S>>,
pub client_version: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub end_reason: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ended_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_activity_at: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<session::Metadata<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_session_uri: Option<S>,
pub platform: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub related_log_uris: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub related_progress_uris: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub related_session_uris: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub session_context: Option<session::SessionContext<S>>,
pub started_at: Datetime,
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 SessionGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Session<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Metadata<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub features: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub network_condition: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub performance_metrics: Option<session::PerformanceMetrics<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 PerformanceMetrics<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub average_response_time: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: 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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SessionContext<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub authentication_method: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub entry_point: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_new_user: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub referrer: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Session<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, SessionRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for ActivitySummary<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.session"
}
fn def_name() -> &'static str {
"activitySummary"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_session()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.current_level {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("current_level"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.current_xp {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("current_xp"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.total_events {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("total_events"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.xp_gained_this_session {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("xp_gained_this_session"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for GameActions<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.session"
}
fn def_name() -> &'static str {
"gameActions"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_session()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.daily_rewards_claimed {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("daily_rewards_claimed"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.feeds_loaded {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("feeds_loaded"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.items_collected {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("items_collected"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.level_ups {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("level_ups"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.posts_viewed {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("posts_viewed"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.specimens_collected {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("specimens_collected"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SessionRecord;
impl XrpcResp for SessionRecord {
const NSID: &'static str = "net.anisota.beta.game.session";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = SessionGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<SessionGetRecordOutput<S>> for Session<S> {
fn from(output: SessionGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Session<S> {
const NSID: &'static str = "net.anisota.beta.game.session";
type Record = SessionRecord;
}
impl Collection for SessionRecord {
const NSID: &'static str = "net.anisota.beta.game.session";
type Record = SessionRecord;
}
impl<S: BosStr> LexiconSchema for Session<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.session"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_session()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.duration {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("duration"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Metadata<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.session"
}
fn def_name() -> &'static str {
"metadata"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_session()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for PerformanceMetrics<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.session"
}
fn def_name() -> &'static str {
"performanceMetrics"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_session()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.average_response_time {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("average_response_time"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.error_count {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("error_count"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SessionContext<S> {
fn nsid() -> &'static str {
"net.anisota.beta.game.session"
}
fn def_name() -> &'static str {
"sessionContext"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_beta_game_session()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn lexicon_doc_net_anisota_beta_game_session() -> 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("net.anisota.beta.game.session"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("activitySummary"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Summary of activity during this session"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("currentLevel"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("currentXP"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gameActions"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#gameActions"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("pagesVisited"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("List of unique pages/routes visited"),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("totalEvents"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("xpGainedThisSession"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gameActions"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Game-specific actions performed"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("dailyRewardsClaimed"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("feedsLoaded"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("itemsCollected"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("levelUps"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("postsViewed"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("specimensCollected"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A game session record tracking a continuous period of user engagement with the application",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("startedAt"),
SmolStr::new_static("status"),
SmolStr::new_static("platform"),
SmolStr::new_static("clientVersion")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("activitySummary"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#activitySummary"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("clientVersion"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Version of the client application"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the session 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("endReason"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Why the session ended"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("endedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the session ended (ISO 8601)"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lastActivityAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp of the last recorded activity in this session",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("metadata"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#metadata"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("parentSessionUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"URI of the previous session if this is a continuation (e.g., after brief inactivity)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("platform"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Platform where the session occurred"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("relatedLogUris"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"URIs of log records that occurred during this session",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("relatedProgressUris"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"URIs of progress records created during this session",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("relatedSessionUris"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"URIs of related sessions (e.g., same day, same device)",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sessionContext"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#sessionContext"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the session began (ISO 8601)"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Current status of the session"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the session record was last updated",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("metadata"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Additional session metadata")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("features"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"List of features used during the session",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("networkCondition"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Network condition during session"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("performanceMetrics"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#performanceMetrics"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("performanceMetrics"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Performance-related data")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("averageResponseTime"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("errorCount"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sessionContext"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Context about how the session started"),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("authenticationMethod"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("How the user was authenticated"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("entryPoint"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("How the user entered the app"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isNewUser"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("referrer"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Referrer URL if applicable"),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod session_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 ClientVersion;
type Platform;
type Status;
type StartedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ClientVersion = Unset;
type Platform = Unset;
type Status = Unset;
type StartedAt = Unset;
}
pub struct SetClientVersion<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetClientVersion<St> {}
impl<St: State> State for SetClientVersion<St> {
type ClientVersion = Set<members::client_version>;
type Platform = St::Platform;
type Status = St::Status;
type StartedAt = St::StartedAt;
}
pub struct SetPlatform<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPlatform<St> {}
impl<St: State> State for SetPlatform<St> {
type ClientVersion = St::ClientVersion;
type Platform = Set<members::platform>;
type Status = St::Status;
type StartedAt = St::StartedAt;
}
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 ClientVersion = St::ClientVersion;
type Platform = St::Platform;
type Status = Set<members::status>;
type StartedAt = St::StartedAt;
}
pub struct SetStartedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStartedAt<St> {}
impl<St: State> State for SetStartedAt<St> {
type ClientVersion = St::ClientVersion;
type Platform = St::Platform;
type Status = St::Status;
type StartedAt = Set<members::started_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct client_version(());
pub struct platform(());
pub struct status(());
pub struct started_at(());
}
}
pub struct SessionBuilder<S: BosStr, St: session_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<session::ActivitySummary<S>>,
Option<S>,
Option<Datetime>,
Option<i64>,
Option<S>,
Option<Datetime>,
Option<Datetime>,
Option<session::Metadata<S>>,
Option<S>,
Option<S>,
Option<Vec<S>>,
Option<Vec<S>>,
Option<Vec<S>>,
Option<session::SessionContext<S>>,
Option<Datetime>,
Option<S>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Session<S> {
pub fn new() -> SessionBuilder<S, session_state::Empty> {
SessionBuilder::new()
}
}
impl<S: BosStr> SessionBuilder<S, session_state::Empty> {
pub fn new() -> Self {
SessionBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn activity_summary(
mut self,
value: impl Into<Option<session::ActivitySummary<S>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_activity_summary(
mut self,
value: Option<session::ActivitySummary<S>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> SessionBuilder<S, St>
where
St: session_state::State,
St::ClientVersion: session_state::IsUnset,
{
pub fn client_version(
mut self,
value: impl Into<S>,
) -> SessionBuilder<S, session_state::SetClientVersion<St>> {
self._fields.1 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn duration(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_duration(mut self, value: Option<i64>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn end_reason(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_end_reason(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn ended_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_ended_at(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn last_activity_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_last_activity_at(mut self, value: Option<Datetime>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn metadata(mut self, value: impl Into<Option<session::Metadata<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<session::Metadata<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn parent_session_uri(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_parent_session_uri(mut self, value: Option<S>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> SessionBuilder<S, St>
where
St: session_state::State,
St::Platform: session_state::IsUnset,
{
pub fn platform(
mut self,
value: impl Into<S>,
) -> SessionBuilder<S, session_state::SetPlatform<St>> {
self._fields.9 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn related_log_uris(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_related_log_uris(mut self, value: Option<Vec<S>>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn related_progress_uris(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_related_progress_uris(mut self, value: Option<Vec<S>>) -> Self {
self._fields.11 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn related_session_uris(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_related_session_uris(mut self, value: Option<Vec<S>>) -> Self {
self._fields.12 = value;
self
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn session_context(
mut self,
value: impl Into<Option<session::SessionContext<S>>>,
) -> Self {
self._fields.13 = value.into();
self
}
pub fn maybe_session_context(
mut self,
value: Option<session::SessionContext<S>>,
) -> Self {
self._fields.13 = value;
self
}
}
impl<S: BosStr, St> SessionBuilder<S, St>
where
St: session_state::State,
St::StartedAt: session_state::IsUnset,
{
pub fn started_at(
mut self,
value: impl Into<Datetime>,
) -> SessionBuilder<S, session_state::SetStartedAt<St>> {
self._fields.14 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SessionBuilder<S, St>
where
St: session_state::State,
St::Status: session_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<S>,
) -> SessionBuilder<S, session_state::SetStatus<St>> {
self._fields.15 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: session_state::State> SessionBuilder<S, St> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.16 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.16 = value;
self
}
}
impl<S: BosStr, St> SessionBuilder<S, St>
where
St: session_state::State,
St::ClientVersion: session_state::IsSet,
St::Platform: session_state::IsSet,
St::Status: session_state::IsSet,
St::StartedAt: session_state::IsSet,
{
pub fn build(self) -> Session<S> {
Session {
activity_summary: self._fields.0,
client_version: self._fields.1.unwrap(),
created_at: self._fields.2,
duration: self._fields.3,
end_reason: self._fields.4,
ended_at: self._fields.5,
last_activity_at: self._fields.6,
metadata: self._fields.7,
parent_session_uri: self._fields.8,
platform: self._fields.9.unwrap(),
related_log_uris: self._fields.10,
related_progress_uris: self._fields.11,
related_session_uris: self._fields.12,
session_context: self._fields.13,
started_at: self._fields.14.unwrap(),
status: self._fields.15.unwrap(),
updated_at: self._fields.16,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Session<S> {
Session {
activity_summary: self._fields.0,
client_version: self._fields.1.unwrap(),
created_at: self._fields.2,
duration: self._fields.3,
end_reason: self._fields.4,
ended_at: self._fields.5,
last_activity_at: self._fields.6,
metadata: self._fields.7,
parent_session_uri: self._fields.8,
platform: self._fields.9.unwrap(),
related_log_uris: self._fields.10,
related_progress_uris: self._fields.11,
related_session_uris: self._fields.12,
session_context: self._fields.13,
started_at: self._fields.14.unwrap(),
status: self._fields.15.unwrap(),
updated_at: self._fields.16,
extra_data: Some(extra_data),
}
}
}