#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::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;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ActivitySummary<'a> {
#[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")]
#[serde(borrow)]
pub game_actions: Option<session::GameActions<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub pages_visited: Option<Vec<CowStr<'a>>>,
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GameActions<'a> {
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Session<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub activity_summary: Option<session::ActivitySummary<'a>>,
#[serde(borrow)]
pub client_version: CowStr<'a>,
#[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")]
#[serde(borrow)]
pub end_reason: Option<CowStr<'a>>,
#[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")]
#[serde(borrow)]
pub metadata: Option<session::Metadata<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub parent_session_uri: Option<CowStr<'a>>,
#[serde(borrow)]
pub platform: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub related_log_uris: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub related_progress_uris: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub related_session_uris: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub session_context: Option<session::SessionContext<'a>>,
pub started_at: Datetime,
#[serde(borrow)]
pub status: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<Datetime>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SessionGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Session<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Metadata<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub features: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub network_condition: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub performance_metrics: Option<session::PerformanceMetrics<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct PerformanceMetrics<'a> {
#[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>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SessionContext<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub authentication_method: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub entry_point: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_new_user: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub referrer: Option<CowStr<'a>>,
}
impl<'a> Session<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, SessionRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for ActivitySummary<'a> {
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<'a> LexiconSchema for GameActions<'a> {
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<'de> = SessionGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<SessionGetRecordOutput<'_>> for Session<'_> {
fn from(output: SessionGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Session<'_> {
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<'a> LexiconSchema for Session<'a> {
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<'a> LexiconSchema for Metadata<'a> {
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<'a> LexiconSchema for PerformanceMetrics<'a> {
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<'a> LexiconSchema for SessionContext<'a> {
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 Platform;
type StartedAt;
type Status;
type ClientVersion;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Platform = Unset;
type StartedAt = Unset;
type Status = Unset;
type ClientVersion = Unset;
}
pub struct SetPlatform<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPlatform<S> {}
impl<S: State> State for SetPlatform<S> {
type Platform = Set<members::platform>;
type StartedAt = S::StartedAt;
type Status = S::Status;
type ClientVersion = S::ClientVersion;
}
pub struct SetStartedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStartedAt<S> {}
impl<S: State> State for SetStartedAt<S> {
type Platform = S::Platform;
type StartedAt = Set<members::started_at>;
type Status = S::Status;
type ClientVersion = S::ClientVersion;
}
pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStatus<S> {}
impl<S: State> State for SetStatus<S> {
type Platform = S::Platform;
type StartedAt = S::StartedAt;
type Status = Set<members::status>;
type ClientVersion = S::ClientVersion;
}
pub struct SetClientVersion<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetClientVersion<S> {}
impl<S: State> State for SetClientVersion<S> {
type Platform = S::Platform;
type StartedAt = S::StartedAt;
type Status = S::Status;
type ClientVersion = Set<members::client_version>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct platform(());
pub struct started_at(());
pub struct status(());
pub struct client_version(());
}
}
pub struct SessionBuilder<'a, S: session_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<session::ActivitySummary<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<i64>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<Datetime>,
Option<session::Metadata<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Vec<CowStr<'a>>>,
Option<Vec<CowStr<'a>>>,
Option<Vec<CowStr<'a>>>,
Option<session::SessionContext<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
Option<Datetime>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Session<'a> {
pub fn new() -> SessionBuilder<'a, session_state::Empty> {
SessionBuilder::new()
}
}
impl<'a> SessionBuilder<'a, 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,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn activity_summary(
mut self,
value: impl Into<Option<session::ActivitySummary<'a>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_activity_summary(
mut self,
value: Option<session::ActivitySummary<'a>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> SessionBuilder<'a, S>
where
S: session_state::State,
S::ClientVersion: session_state::IsUnset,
{
pub fn client_version(
mut self,
value: impl Into<CowStr<'a>>,
) -> SessionBuilder<'a, session_state::SetClientVersion<S>> {
self._fields.1 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
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<'a, S: session_state::State> SessionBuilder<'a, S> {
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<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn end_reason(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_end_reason(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
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<'a, S: session_state::State> SessionBuilder<'a, S> {
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<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn metadata(mut self, value: impl Into<Option<session::Metadata<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_metadata(mut self, value: Option<session::Metadata<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn parent_session_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_parent_session_uri(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> SessionBuilder<'a, S>
where
S: session_state::State,
S::Platform: session_state::IsUnset,
{
pub fn platform(
mut self,
value: impl Into<CowStr<'a>>,
) -> SessionBuilder<'a, session_state::SetPlatform<S>> {
self._fields.9 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn related_log_uris(
mut self,
value: impl Into<Option<Vec<CowStr<'a>>>>,
) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_related_log_uris(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn related_progress_uris(
mut self,
value: impl Into<Option<Vec<CowStr<'a>>>>,
) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_related_progress_uris(
mut self,
value: Option<Vec<CowStr<'a>>>,
) -> Self {
self._fields.11 = value;
self
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn related_session_uris(
mut self,
value: impl Into<Option<Vec<CowStr<'a>>>>,
) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_related_session_uris(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
self._fields.12 = value;
self
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
pub fn session_context(
mut self,
value: impl Into<Option<session::SessionContext<'a>>>,
) -> Self {
self._fields.13 = value.into();
self
}
pub fn maybe_session_context(
mut self,
value: Option<session::SessionContext<'a>>,
) -> Self {
self._fields.13 = value;
self
}
}
impl<'a, S> SessionBuilder<'a, S>
where
S: session_state::State,
S::StartedAt: session_state::IsUnset,
{
pub fn started_at(
mut self,
value: impl Into<Datetime>,
) -> SessionBuilder<'a, session_state::SetStartedAt<S>> {
self._fields.14 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SessionBuilder<'a, S>
where
S: session_state::State,
S::Status: session_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<CowStr<'a>>,
) -> SessionBuilder<'a, session_state::SetStatus<S>> {
self._fields.15 = Option::Some(value.into());
SessionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: session_state::State> SessionBuilder<'a, S> {
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<'a, S> SessionBuilder<'a, S>
where
S: session_state::State,
S::Platform: session_state::IsSet,
S::StartedAt: session_state::IsSet,
S::Status: session_state::IsSet,
S::ClientVersion: session_state::IsSet,
{
pub fn build(self) -> Session<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Session<'a> {
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),
}
}
}