atproto blogging
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#[jacquard_derive::lexicon]
9#[derive(
10 serde::Serialize,
11 serde::Deserialize,
12 Debug,
13 Clone,
14 PartialEq,
15 Eq,
16 jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct GetSessionOutput<'a> {
20 #[serde(skip_serializing_if = "std::option::Option::is_none")]
21 pub active: std::option::Option<bool>,
22 #[serde(borrow)]
23 pub did: jacquard_common::types::string::Did<'a>,
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 #[serde(borrow)]
26 pub did_doc: std::option::Option<jacquard_common::types::value::Data<'a>>,
27 #[serde(skip_serializing_if = "std::option::Option::is_none")]
28 #[serde(borrow)]
29 pub email: std::option::Option<jacquard_common::CowStr<'a>>,
30 #[serde(skip_serializing_if = "std::option::Option::is_none")]
31 pub email_auth_factor: std::option::Option<bool>,
32 #[serde(skip_serializing_if = "std::option::Option::is_none")]
33 pub email_confirmed: std::option::Option<bool>,
34 #[serde(borrow)]
35 pub handle: jacquard_common::types::string::Handle<'a>,
36 /// 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.
37 #[serde(skip_serializing_if = "std::option::Option::is_none")]
38 #[serde(borrow)]
39 pub status: std::option::Option<GetSessionOutputStatus<'a>>,
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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub enum GetSessionOutputStatus<'a> {
45 Takendown,
46 Suspended,
47 Deactivated,
48 Other(jacquard_common::CowStr<'a>),
49}
50
51impl<'a> GetSessionOutputStatus<'a> {
52 pub fn as_str(&self) -> &str {
53 match self {
54 Self::Takendown => "takendown",
55 Self::Suspended => "suspended",
56 Self::Deactivated => "deactivated",
57 Self::Other(s) => s.as_ref(),
58 }
59 }
60}
61
62impl<'a> From<&'a str> for GetSessionOutputStatus<'a> {
63 fn from(s: &'a str) -> Self {
64 match s {
65 "takendown" => Self::Takendown,
66 "suspended" => Self::Suspended,
67 "deactivated" => Self::Deactivated,
68 _ => Self::Other(jacquard_common::CowStr::from(s)),
69 }
70 }
71}
72
73impl<'a> From<String> for GetSessionOutputStatus<'a> {
74 fn from(s: String) -> Self {
75 match s.as_str() {
76 "takendown" => Self::Takendown,
77 "suspended" => Self::Suspended,
78 "deactivated" => Self::Deactivated,
79 _ => Self::Other(jacquard_common::CowStr::from(s)),
80 }
81 }
82}
83
84impl<'a> core::fmt::Display for GetSessionOutputStatus<'a> {
85 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
86 write!(f, "{}", self.as_str())
87 }
88}
89
90impl<'a> AsRef<str> for GetSessionOutputStatus<'a> {
91 fn as_ref(&self) -> &str {
92 self.as_str()
93 }
94}
95
96impl<'a> serde::Serialize for GetSessionOutputStatus<'a> {
97 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
98 where
99 S: serde::Serializer,
100 {
101 serializer.serialize_str(self.as_str())
102 }
103}
104
105impl<'de, 'a> serde::Deserialize<'de> for GetSessionOutputStatus<'a>
106where
107 'de: 'a,
108{
109 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
110 where
111 D: serde::Deserializer<'de>,
112 {
113 let s = <&'de str>::deserialize(deserializer)?;
114 Ok(Self::from(s))
115 }
116}
117
118impl<'a> Default for GetSessionOutputStatus<'a> {
119 fn default() -> Self {
120 Self::Other(Default::default())
121 }
122}
123
124impl jacquard_common::IntoStatic for GetSessionOutputStatus<'_> {
125 type Output = GetSessionOutputStatus<'static>;
126 fn into_static(self) -> Self::Output {
127 match self {
128 GetSessionOutputStatus::Takendown => GetSessionOutputStatus::Takendown,
129 GetSessionOutputStatus::Suspended => GetSessionOutputStatus::Suspended,
130 GetSessionOutputStatus::Deactivated => GetSessionOutputStatus::Deactivated,
131 GetSessionOutputStatus::Other(v) => {
132 GetSessionOutputStatus::Other(v.into_static())
133 }
134 }
135 }
136}
137
138/// XRPC request marker type
139#[derive(
140 Debug,
141 Clone,
142 Copy,
143 PartialEq,
144 Eq,
145 serde::Serialize,
146 serde::Deserialize,
147 jacquard_derive::IntoStatic
148)]
149pub struct GetSession;
150/// Response type for
151///com.atproto.server.getSession
152pub struct GetSessionResponse;
153impl jacquard_common::xrpc::XrpcResp for GetSessionResponse {
154 const NSID: &'static str = "com.atproto.server.getSession";
155 const ENCODING: &'static str = "application/json";
156 type Output<'de> = GetSessionOutput<'de>;
157 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
158}
159
160impl jacquard_common::xrpc::XrpcRequest for GetSession {
161 const NSID: &'static str = "com.atproto.server.getSession";
162 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
163 type Response = GetSessionResponse;
164}
165
166/// Endpoint type for
167///com.atproto.server.getSession
168pub struct GetSessionRequest;
169impl jacquard_common::xrpc::XrpcEndpoint for GetSessionRequest {
170 const PATH: &'static str = "/xrpc/com.atproto.server.getSession";
171 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
172 type Request<'de> = GetSession;
173 type Response = GetSessionResponse;
174}