// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: space.polymodel.actor.getSession // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[allow(unused_imports)] use alloc::collections::BTreeMap; #[allow(unused_imports)] use core::marker::PhantomData; use jacquard_common::{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::string::{Did, Handle}; use jacquard_common::types::value::Data; use jacquard_derive::IntoStatic; 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::space_polymodel::actor::ProfileView; use crate::space_polymodel::actor::get_session; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct GetSessionOutput { #[serde(flatten)] pub value: get_session::SessionView, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } /// Authenticated viewer identity for client session seeding. If authenticated is true, did, handle, and profile are all present. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct SessionAuthenticated { pub authenticated: bool, pub did: Did, pub handle: Handle, pub profile: ProfileView, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } /// Logged-out session marker. No identity fields are present when authenticated is false. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct SessionUnauthenticated { pub authenticated: bool, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub enum SessionView { #[serde(rename = "space.polymodel.actor.getSession#sessionUnauthenticated")] SessionUnauthenticated(Box>), #[serde(rename = "space.polymodel.actor.getSession#sessionAuthenticated")] SessionAuthenticated(Box>), } /** Request marker for the `space.polymodel.actor.getSession` query. This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/ #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)] pub struct GetSession; /** Response marker for the `space.polymodel.actor.getSession` query. Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output`, which is `GetSessionOutput` for this endpoint.*/ pub struct GetSessionResponse; impl jacquard_common::xrpc::XrpcResp for GetSessionResponse { const NSID: &'static str = "space.polymodel.actor.getSession"; const ENCODING: &'static str = "application/json"; type Output = GetSessionOutput; type Err = jacquard_common::xrpc::GenericError; } impl jacquard_common::xrpc::XrpcRequest for GetSession { const NSID: &'static str = "space.polymodel.actor.getSession"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Response = GetSessionResponse; } /** Endpoint marker for the `space.polymodel.actor.getSession` query. Path: `/xrpc/space.polymodel.actor.getSession`. The request payload type is `GetSession`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/ pub struct GetSessionRequest; impl jacquard_common::xrpc::XrpcEndpoint for GetSessionRequest { const PATH: &'static str = "/xrpc/space.polymodel.actor.getSession"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Request = GetSession; type Response = GetSessionResponse; } impl LexiconSchema for SessionAuthenticated { fn nsid() -> &'static str { "space.polymodel.actor.getSession" } fn def_name() -> &'static str { "sessionAuthenticated" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_space_polymodel_actor_getSession() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } impl LexiconSchema for SessionUnauthenticated { fn nsid() -> &'static str { "space.polymodel.actor.getSession" } fn def_name() -> &'static str { "sessionUnauthenticated" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_space_polymodel_actor_getSession() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } pub mod session_authenticated_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Authenticated; type Did; type Handle; type Profile; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Authenticated = Unset; type Did = Unset; type Handle = Unset; type Profile = Unset; } ///State transition - sets the `authenticated` field to Set pub struct SetAuthenticated(PhantomData St>); impl sealed::Sealed for SetAuthenticated {} impl State for SetAuthenticated { type Authenticated = Set; type Did = St::Did; type Handle = St::Handle; type Profile = St::Profile; } ///State transition - sets the `did` field to Set pub struct SetDid(PhantomData St>); impl sealed::Sealed for SetDid {} impl State for SetDid { type Authenticated = St::Authenticated; type Did = Set; type Handle = St::Handle; type Profile = St::Profile; } ///State transition - sets the `handle` field to Set pub struct SetHandle(PhantomData St>); impl sealed::Sealed for SetHandle {} impl State for SetHandle { type Authenticated = St::Authenticated; type Did = St::Did; type Handle = Set; type Profile = St::Profile; } ///State transition - sets the `profile` field to Set pub struct SetProfile(PhantomData St>); impl sealed::Sealed for SetProfile {} impl State for SetProfile { type Authenticated = St::Authenticated; type Did = St::Did; type Handle = St::Handle; type Profile = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `authenticated` field pub struct authenticated(()); ///Marker type for the `did` field pub struct did(()); ///Marker type for the `handle` field pub struct handle(()); ///Marker type for the `profile` field pub struct profile(()); } } /// Builder for constructing an instance of this type. pub struct SessionAuthenticatedBuilder< St: session_authenticated_state::State, S: BosStr = DefaultStr, > { _state: PhantomData St>, _fields: (Option, Option>, Option>, Option>), _type: PhantomData S>, } impl SessionAuthenticated { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SessionAuthenticatedBuilder< session_authenticated_state::Empty, DefaultStr, > { SessionAuthenticatedBuilder::new() } } impl SessionAuthenticated { /// Create a new builder for this type pub fn builder() -> SessionAuthenticatedBuilder< session_authenticated_state::Empty, S, > { SessionAuthenticatedBuilder::builder() } } impl SessionAuthenticatedBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SessionAuthenticatedBuilder { _state: PhantomData, _fields: (None, None, None, None), _type: PhantomData, } } } impl SessionAuthenticatedBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SessionAuthenticatedBuilder { _state: PhantomData, _fields: (None, None, None, None), _type: PhantomData, } } } impl SessionAuthenticatedBuilder where St: session_authenticated_state::State, St::Authenticated: session_authenticated_state::IsUnset, { /// Set the `authenticated` field (required) pub fn authenticated( mut self, value: impl Into, ) -> SessionAuthenticatedBuilder< session_authenticated_state::SetAuthenticated, S, > { self._fields.0 = Option::Some(value.into()); SessionAuthenticatedBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SessionAuthenticatedBuilder where St: session_authenticated_state::State, St::Did: session_authenticated_state::IsUnset, { /// Set the `did` field (required) pub fn did( mut self, value: impl Into>, ) -> SessionAuthenticatedBuilder, S> { self._fields.1 = Option::Some(value.into()); SessionAuthenticatedBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SessionAuthenticatedBuilder where St: session_authenticated_state::State, St::Handle: session_authenticated_state::IsUnset, { /// Set the `handle` field (required) pub fn handle( mut self, value: impl Into>, ) -> SessionAuthenticatedBuilder, S> { self._fields.2 = Option::Some(value.into()); SessionAuthenticatedBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SessionAuthenticatedBuilder where St: session_authenticated_state::State, St::Profile: session_authenticated_state::IsUnset, { /// Set the `profile` field (required) pub fn profile( mut self, value: impl Into>, ) -> SessionAuthenticatedBuilder, S> { self._fields.3 = Option::Some(value.into()); SessionAuthenticatedBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SessionAuthenticatedBuilder where St: session_authenticated_state::State, St::Authenticated: session_authenticated_state::IsSet, St::Did: session_authenticated_state::IsSet, St::Handle: session_authenticated_state::IsSet, St::Profile: session_authenticated_state::IsSet, { /// Build the final struct. pub fn build(self) -> SessionAuthenticated { SessionAuthenticated { authenticated: self._fields.0.unwrap(), did: self._fields.1.unwrap(), handle: self._fields.2.unwrap(), profile: self._fields.3.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data( self, extra_data: BTreeMap>, ) -> SessionAuthenticated { SessionAuthenticated { authenticated: self._fields.0.unwrap(), did: self._fields.1.unwrap(), handle: self._fields.2.unwrap(), profile: self._fields.3.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_space_polymodel_actor_getSession() -> 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("space.polymodel.actor.getSession"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("main"), LexUserType::XrpcQuery(LexXrpcQuery { parameters: None, ..Default::default() }), ); map.insert( SmolStr::new_static("sessionAuthenticated"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "Authenticated viewer identity for client session seeding. If authenticated is true, did, handle, and profile are all present.", ), ), required: Some( vec![ SmolStr::new_static("authenticated"), SmolStr::new_static("did"), SmolStr::new_static("handle"), SmolStr::new_static("profile") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("authenticated"), LexObjectProperty::Boolean(LexBoolean { ..Default::default() }), ); map.insert( SmolStr::new_static("did"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Did), ..Default::default() }), ); map.insert( SmolStr::new_static("handle"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Handle), ..Default::default() }), ); map.insert( SmolStr::new_static("profile"), LexObjectProperty::Ref(LexRef { r#ref: CowStr::new_static( "space.polymodel.actor.defs#profileView", ), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("sessionUnauthenticated"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "Logged-out session marker. No identity fields are present when authenticated is false.", ), ), required: Some(vec![SmolStr::new_static("authenticated")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("authenticated"), LexObjectProperty::Boolean(LexBoolean { ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("sessionView"), LexUserType::Union(LexRefUnion { refs: vec![ CowStr::new_static("space.polymodel.actor.getSession#sessionUnauthenticated"), CowStr::new_static("space.polymodel.actor.getSession#sessionAuthenticated") ], closed: Some(true), ..Default::default() }), ); map }, ..Default::default() } } pub mod session_unauthenticated_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Authenticated; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Authenticated = Unset; } ///State transition - sets the `authenticated` field to Set pub struct SetAuthenticated(PhantomData St>); impl sealed::Sealed for SetAuthenticated {} impl State for SetAuthenticated { type Authenticated = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `authenticated` field pub struct authenticated(()); } } /// Builder for constructing an instance of this type. pub struct SessionUnauthenticatedBuilder< St: session_unauthenticated_state::State, S: BosStr = DefaultStr, > { _state: PhantomData St>, _fields: (Option,), _type: PhantomData S>, } impl SessionUnauthenticated { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SessionUnauthenticatedBuilder< session_unauthenticated_state::Empty, DefaultStr, > { SessionUnauthenticatedBuilder::new() } } impl SessionUnauthenticated { /// Create a new builder for this type pub fn builder() -> SessionUnauthenticatedBuilder< session_unauthenticated_state::Empty, S, > { SessionUnauthenticatedBuilder::builder() } } impl SessionUnauthenticatedBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SessionUnauthenticatedBuilder { _state: PhantomData, _fields: (None,), _type: PhantomData, } } } impl SessionUnauthenticatedBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SessionUnauthenticatedBuilder { _state: PhantomData, _fields: (None,), _type: PhantomData, } } } impl SessionUnauthenticatedBuilder where St: session_unauthenticated_state::State, St::Authenticated: session_unauthenticated_state::IsUnset, { /// Set the `authenticated` field (required) pub fn authenticated( mut self, value: impl Into, ) -> SessionUnauthenticatedBuilder< session_unauthenticated_state::SetAuthenticated, S, > { self._fields.0 = Option::Some(value.into()); SessionUnauthenticatedBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SessionUnauthenticatedBuilder where St: session_unauthenticated_state::State, St::Authenticated: session_unauthenticated_state::IsSet, { /// Build the final struct. pub fn build(self) -> SessionUnauthenticated { SessionUnauthenticated { authenticated: self._fields.0.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data( self, extra_data: BTreeMap>, ) -> SessionUnauthenticated { SessionUnauthenticated { authenticated: self._fields.0.unwrap(), extra_data: Some(extra_data), } } }