Skip to main content

jacquard_api/com_atproto/server/
get_session.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.getSession
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::string::{Did, Handle};
16use jacquard_common::types::value::Data;
17use jacquard_derive::IntoStatic;
18use serde::{Serialize, Deserialize};
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
22pub struct GetSessionOutput<S: BosStr = DefaultStr> {
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub active: Option<bool>,
25    pub did: Did<S>,
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub did_doc: Option<Data<S>>,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub email: Option<S>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub email_auth_factor: Option<bool>,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub email_confirmed: Option<bool>,
34    pub handle: Handle<S>,
35    ///If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub status: Option<GetSessionOutputStatus<S>>,
38    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
39    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
40}
41
42/// If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.
43
44#[derive(Debug, Clone, PartialEq, Eq, Hash)]
45pub enum GetSessionOutputStatus<S: BosStr = DefaultStr> {
46    Takendown,
47    Suspended,
48    Deactivated,
49    Other(S),
50}
51
52impl<S: BosStr> GetSessionOutputStatus<S> {
53    pub fn as_str(&self) -> &str {
54        match self {
55            Self::Takendown => "takendown",
56            Self::Suspended => "suspended",
57            Self::Deactivated => "deactivated",
58            Self::Other(s) => s.as_ref(),
59        }
60    }
61    /// Construct from a string-like value, matching known values.
62    pub fn from_value(s: S) -> Self {
63        match s.as_ref() {
64            "takendown" => Self::Takendown,
65            "suspended" => Self::Suspended,
66            "deactivated" => Self::Deactivated,
67            _ => Self::Other(s),
68        }
69    }
70}
71
72impl<S: BosStr> core::fmt::Display for GetSessionOutputStatus<S> {
73    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
74        write!(f, "{}", self.as_str())
75    }
76}
77
78impl<S: BosStr> AsRef<str> for GetSessionOutputStatus<S> {
79    fn as_ref(&self) -> &str {
80        self.as_str()
81    }
82}
83
84impl<S: BosStr> Serialize for GetSessionOutputStatus<S> {
85    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
86    where
87        Ser: serde::Serializer,
88    {
89        serializer.serialize_str(self.as_str())
90    }
91}
92
93impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for GetSessionOutputStatus<S> {
94    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
95    where
96        D: serde::Deserializer<'de>,
97    {
98        let s = S::deserialize(deserializer)?;
99        Ok(Self::from_value(s))
100    }
101}
102
103impl<S: BosStr + Default> Default for GetSessionOutputStatus<S> {
104    fn default() -> Self {
105        Self::Other(Default::default())
106    }
107}
108
109impl<S: BosStr> jacquard_common::IntoStatic for GetSessionOutputStatus<S>
110where
111    S: BosStr + jacquard_common::IntoStatic,
112    S::Output: BosStr,
113{
114    type Output = GetSessionOutputStatus<S::Output>;
115    fn into_static(self) -> Self::Output {
116        match self {
117            GetSessionOutputStatus::Takendown => GetSessionOutputStatus::Takendown,
118            GetSessionOutputStatus::Suspended => GetSessionOutputStatus::Suspended,
119            GetSessionOutputStatus::Deactivated => GetSessionOutputStatus::Deactivated,
120            GetSessionOutputStatus::Other(v) => {
121                GetSessionOutputStatus::Other(v.into_static())
122            }
123        }
124    }
125}
126
127/** Request marker for the `com.atproto.server.getSession` query.
128
129This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/
130
131#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
132pub struct GetSession;
133/** Response marker for the `com.atproto.server.getSession` query.
134
135Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetSessionOutput<S>` for this endpoint.*/
136pub struct GetSessionResponse;
137impl jacquard_common::xrpc::XrpcResp for GetSessionResponse {
138    const NSID: &'static str = "com.atproto.server.getSession";
139    const ENCODING: &'static str = "application/json";
140    type Output<S: BosStr> = GetSessionOutput<S>;
141    type Err = jacquard_common::xrpc::GenericError;
142}
143
144impl jacquard_common::xrpc::XrpcRequest for GetSession {
145    const NSID: &'static str = "com.atproto.server.getSession";
146    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
147    type Response = GetSessionResponse;
148}
149
150/** Endpoint marker for the `com.atproto.server.getSession` query.
151
152Path: `/xrpc/com.atproto.server.getSession`. The request payload type is `GetSession`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
153pub struct GetSessionRequest;
154impl jacquard_common::xrpc::XrpcEndpoint for GetSessionRequest {
155    const PATH: &'static str = "/xrpc/com.atproto.server.getSession";
156    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
157    type Request<S: BosStr> = GetSession;
158    type Response = GetSessionResponse;
159}