atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.refreshSession
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 RefreshSessionOutput<'a> {
20 #[serde(borrow)]
21 pub access_jwt: jacquard_common::CowStr<'a>,
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 pub active: std::option::Option<bool>,
24 #[serde(borrow)]
25 pub did: jacquard_common::types::string::Did<'a>,
26 #[serde(skip_serializing_if = "std::option::Option::is_none")]
27 #[serde(borrow)]
28 pub did_doc: std::option::Option<jacquard_common::types::value::Data<'a>>,
29 #[serde(borrow)]
30 pub handle: jacquard_common::types::string::Handle<'a>,
31 #[serde(borrow)]
32 pub refresh_jwt: jacquard_common::CowStr<'a>,
33 /// Hosting status of the account. If not specified, then assume 'active'.
34 #[serde(skip_serializing_if = "std::option::Option::is_none")]
35 #[serde(borrow)]
36 pub status: std::option::Option<RefreshSessionOutputStatus<'a>>,
37}
38
39/// Hosting status of the account. If not specified, then assume 'active'.
40#[derive(Debug, Clone, PartialEq, Eq, Hash)]
41pub enum RefreshSessionOutputStatus<'a> {
42 Takendown,
43 Suspended,
44 Deactivated,
45 Other(jacquard_common::CowStr<'a>),
46}
47
48impl<'a> RefreshSessionOutputStatus<'a> {
49 pub fn as_str(&self) -> &str {
50 match self {
51 Self::Takendown => "takendown",
52 Self::Suspended => "suspended",
53 Self::Deactivated => "deactivated",
54 Self::Other(s) => s.as_ref(),
55 }
56 }
57}
58
59impl<'a> From<&'a str> for RefreshSessionOutputStatus<'a> {
60 fn from(s: &'a str) -> Self {
61 match s {
62 "takendown" => Self::Takendown,
63 "suspended" => Self::Suspended,
64 "deactivated" => Self::Deactivated,
65 _ => Self::Other(jacquard_common::CowStr::from(s)),
66 }
67 }
68}
69
70impl<'a> From<String> for RefreshSessionOutputStatus<'a> {
71 fn from(s: String) -> Self {
72 match s.as_str() {
73 "takendown" => Self::Takendown,
74 "suspended" => Self::Suspended,
75 "deactivated" => Self::Deactivated,
76 _ => Self::Other(jacquard_common::CowStr::from(s)),
77 }
78 }
79}
80
81impl<'a> core::fmt::Display for RefreshSessionOutputStatus<'a> {
82 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83 write!(f, "{}", self.as_str())
84 }
85}
86
87impl<'a> AsRef<str> for RefreshSessionOutputStatus<'a> {
88 fn as_ref(&self) -> &str {
89 self.as_str()
90 }
91}
92
93impl<'a> serde::Serialize for RefreshSessionOutputStatus<'a> {
94 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
95 where
96 S: serde::Serializer,
97 {
98 serializer.serialize_str(self.as_str())
99 }
100}
101
102impl<'de, 'a> serde::Deserialize<'de> for RefreshSessionOutputStatus<'a>
103where
104 'de: 'a,
105{
106 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
107 where
108 D: serde::Deserializer<'de>,
109 {
110 let s = <&'de str>::deserialize(deserializer)?;
111 Ok(Self::from(s))
112 }
113}
114
115impl<'a> Default for RefreshSessionOutputStatus<'a> {
116 fn default() -> Self {
117 Self::Other(Default::default())
118 }
119}
120
121impl jacquard_common::IntoStatic for RefreshSessionOutputStatus<'_> {
122 type Output = RefreshSessionOutputStatus<'static>;
123 fn into_static(self) -> Self::Output {
124 match self {
125 RefreshSessionOutputStatus::Takendown => {
126 RefreshSessionOutputStatus::Takendown
127 }
128 RefreshSessionOutputStatus::Suspended => {
129 RefreshSessionOutputStatus::Suspended
130 }
131 RefreshSessionOutputStatus::Deactivated => {
132 RefreshSessionOutputStatus::Deactivated
133 }
134 RefreshSessionOutputStatus::Other(v) => {
135 RefreshSessionOutputStatus::Other(v.into_static())
136 }
137 }
138 }
139}
140
141#[jacquard_derive::open_union]
142#[derive(
143 serde::Serialize,
144 serde::Deserialize,
145 Debug,
146 Clone,
147 PartialEq,
148 Eq,
149 thiserror::Error,
150 miette::Diagnostic,
151 jacquard_derive::IntoStatic
152)]
153#[serde(tag = "error", content = "message")]
154#[serde(bound(deserialize = "'de: 'a"))]
155pub enum RefreshSessionError<'a> {
156 #[serde(rename = "AccountTakedown")]
157 AccountTakedown(std::option::Option<jacquard_common::CowStr<'a>>),
158}
159
160impl core::fmt::Display for RefreshSessionError<'_> {
161 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
162 match self {
163 Self::AccountTakedown(msg) => {
164 write!(f, "AccountTakedown")?;
165 if let Some(msg) = msg {
166 write!(f, ": {}", msg)?;
167 }
168 Ok(())
169 }
170 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
171 }
172 }
173}
174
175/// XRPC request marker type
176#[derive(
177 Debug,
178 Clone,
179 Copy,
180 PartialEq,
181 Eq,
182 serde::Serialize,
183 serde::Deserialize,
184 jacquard_derive::IntoStatic
185)]
186pub struct RefreshSession;
187/// Response type for
188///com.atproto.server.refreshSession
189pub struct RefreshSessionResponse;
190impl jacquard_common::xrpc::XrpcResp for RefreshSessionResponse {
191 const NSID: &'static str = "com.atproto.server.refreshSession";
192 const ENCODING: &'static str = "application/json";
193 type Output<'de> = RefreshSessionOutput<'de>;
194 type Err<'de> = RefreshSessionError<'de>;
195}
196
197impl jacquard_common::xrpc::XrpcRequest for RefreshSession {
198 const NSID: &'static str = "com.atproto.server.refreshSession";
199 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
200 "application/json",
201 );
202 type Response = RefreshSessionResponse;
203}
204
205/// Endpoint type for
206///com.atproto.server.refreshSession
207pub struct RefreshSessionRequest;
208impl jacquard_common::xrpc::XrpcEndpoint for RefreshSessionRequest {
209 const PATH: &'static str = "/xrpc/com.atproto.server.refreshSession";
210 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
211 "application/json",
212 );
213 type Request<'de> = RefreshSession;
214 type Response = RefreshSessionResponse;
215}