atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.getRepoStatus
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9 serde::Serialize,
10 serde::Deserialize,
11 Debug,
12 Clone,
13 PartialEq,
14 Eq,
15 jacquard_derive::IntoStatic
16)]
17#[serde(rename_all = "camelCase")]
18pub struct GetRepoStatus<'a> {
19 #[serde(borrow)]
20 pub did: jacquard_common::types::string::Did<'a>,
21}
22
23pub mod get_repo_status_state {
24
25 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
26 #[allow(unused)]
27 use ::core::marker::PhantomData;
28 mod sealed {
29 pub trait Sealed {}
30 }
31 /// State trait tracking which required fields have been set
32 pub trait State: sealed::Sealed {
33 type Did;
34 }
35 /// Empty state - all required fields are unset
36 pub struct Empty(());
37 impl sealed::Sealed for Empty {}
38 impl State for Empty {
39 type Did = Unset;
40 }
41 ///State transition - sets the `did` field to Set
42 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
43 impl<S: State> sealed::Sealed for SetDid<S> {}
44 impl<S: State> State for SetDid<S> {
45 type Did = Set<members::did>;
46 }
47 /// Marker types for field names
48 #[allow(non_camel_case_types)]
49 pub mod members {
50 ///Marker type for the `did` field
51 pub struct did(());
52 }
53}
54
55/// Builder for constructing an instance of this type
56pub struct GetRepoStatusBuilder<'a, S: get_repo_status_state::State> {
57 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
58 __unsafe_private_named: (
59 ::core::option::Option<jacquard_common::types::string::Did<'a>>,
60 ),
61 _phantom: ::core::marker::PhantomData<&'a ()>,
62}
63
64impl<'a> GetRepoStatus<'a> {
65 /// Create a new builder for this type
66 pub fn new() -> GetRepoStatusBuilder<'a, get_repo_status_state::Empty> {
67 GetRepoStatusBuilder::new()
68 }
69}
70
71impl<'a> GetRepoStatusBuilder<'a, get_repo_status_state::Empty> {
72 /// Create a new builder with all fields unset
73 pub fn new() -> Self {
74 GetRepoStatusBuilder {
75 _phantom_state: ::core::marker::PhantomData,
76 __unsafe_private_named: (None,),
77 _phantom: ::core::marker::PhantomData,
78 }
79 }
80}
81
82impl<'a, S> GetRepoStatusBuilder<'a, S>
83where
84 S: get_repo_status_state::State,
85 S::Did: get_repo_status_state::IsUnset,
86{
87 /// Set the `did` field (required)
88 pub fn did(
89 mut self,
90 value: impl Into<jacquard_common::types::string::Did<'a>>,
91 ) -> GetRepoStatusBuilder<'a, get_repo_status_state::SetDid<S>> {
92 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
93 GetRepoStatusBuilder {
94 _phantom_state: ::core::marker::PhantomData,
95 __unsafe_private_named: self.__unsafe_private_named,
96 _phantom: ::core::marker::PhantomData,
97 }
98 }
99}
100
101impl<'a, S> GetRepoStatusBuilder<'a, S>
102where
103 S: get_repo_status_state::State,
104 S::Did: get_repo_status_state::IsSet,
105{
106 /// Build the final struct
107 pub fn build(self) -> GetRepoStatus<'a> {
108 GetRepoStatus {
109 did: self.__unsafe_private_named.0.unwrap(),
110 }
111 }
112}
113
114#[jacquard_derive::lexicon]
115#[derive(
116 serde::Serialize,
117 serde::Deserialize,
118 Debug,
119 Clone,
120 PartialEq,
121 Eq,
122 jacquard_derive::IntoStatic
123)]
124#[serde(rename_all = "camelCase")]
125pub struct GetRepoStatusOutput<'a> {
126 pub active: bool,
127 #[serde(borrow)]
128 pub did: jacquard_common::types::string::Did<'a>,
129 /// Optional field, the current rev of the repo, if active=true
130 #[serde(skip_serializing_if = "std::option::Option::is_none")]
131 pub rev: std::option::Option<jacquard_common::types::string::Tid>,
132 /// 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.
133 #[serde(skip_serializing_if = "std::option::Option::is_none")]
134 #[serde(borrow)]
135 pub status: std::option::Option<GetRepoStatusOutputStatus<'a>>,
136}
137
138/// 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.
139#[derive(Debug, Clone, PartialEq, Eq, Hash)]
140pub enum GetRepoStatusOutputStatus<'a> {
141 Takendown,
142 Suspended,
143 Deleted,
144 Deactivated,
145 Desynchronized,
146 Throttled,
147 Other(jacquard_common::CowStr<'a>),
148}
149
150impl<'a> GetRepoStatusOutputStatus<'a> {
151 pub fn as_str(&self) -> &str {
152 match self {
153 Self::Takendown => "takendown",
154 Self::Suspended => "suspended",
155 Self::Deleted => "deleted",
156 Self::Deactivated => "deactivated",
157 Self::Desynchronized => "desynchronized",
158 Self::Throttled => "throttled",
159 Self::Other(s) => s.as_ref(),
160 }
161 }
162}
163
164impl<'a> From<&'a str> for GetRepoStatusOutputStatus<'a> {
165 fn from(s: &'a str) -> Self {
166 match s {
167 "takendown" => Self::Takendown,
168 "suspended" => Self::Suspended,
169 "deleted" => Self::Deleted,
170 "deactivated" => Self::Deactivated,
171 "desynchronized" => Self::Desynchronized,
172 "throttled" => Self::Throttled,
173 _ => Self::Other(jacquard_common::CowStr::from(s)),
174 }
175 }
176}
177
178impl<'a> From<String> for GetRepoStatusOutputStatus<'a> {
179 fn from(s: String) -> Self {
180 match s.as_str() {
181 "takendown" => Self::Takendown,
182 "suspended" => Self::Suspended,
183 "deleted" => Self::Deleted,
184 "deactivated" => Self::Deactivated,
185 "desynchronized" => Self::Desynchronized,
186 "throttled" => Self::Throttled,
187 _ => Self::Other(jacquard_common::CowStr::from(s)),
188 }
189 }
190}
191
192impl<'a> core::fmt::Display for GetRepoStatusOutputStatus<'a> {
193 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
194 write!(f, "{}", self.as_str())
195 }
196}
197
198impl<'a> AsRef<str> for GetRepoStatusOutputStatus<'a> {
199 fn as_ref(&self) -> &str {
200 self.as_str()
201 }
202}
203
204impl<'a> serde::Serialize for GetRepoStatusOutputStatus<'a> {
205 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
206 where
207 S: serde::Serializer,
208 {
209 serializer.serialize_str(self.as_str())
210 }
211}
212
213impl<'de, 'a> serde::Deserialize<'de> for GetRepoStatusOutputStatus<'a>
214where
215 'de: 'a,
216{
217 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
218 where
219 D: serde::Deserializer<'de>,
220 {
221 let s = <&'de str>::deserialize(deserializer)?;
222 Ok(Self::from(s))
223 }
224}
225
226impl<'a> Default for GetRepoStatusOutputStatus<'a> {
227 fn default() -> Self {
228 Self::Other(Default::default())
229 }
230}
231
232impl jacquard_common::IntoStatic for GetRepoStatusOutputStatus<'_> {
233 type Output = GetRepoStatusOutputStatus<'static>;
234 fn into_static(self) -> Self::Output {
235 match self {
236 GetRepoStatusOutputStatus::Takendown => GetRepoStatusOutputStatus::Takendown,
237 GetRepoStatusOutputStatus::Suspended => GetRepoStatusOutputStatus::Suspended,
238 GetRepoStatusOutputStatus::Deleted => GetRepoStatusOutputStatus::Deleted,
239 GetRepoStatusOutputStatus::Deactivated => {
240 GetRepoStatusOutputStatus::Deactivated
241 }
242 GetRepoStatusOutputStatus::Desynchronized => {
243 GetRepoStatusOutputStatus::Desynchronized
244 }
245 GetRepoStatusOutputStatus::Throttled => GetRepoStatusOutputStatus::Throttled,
246 GetRepoStatusOutputStatus::Other(v) => {
247 GetRepoStatusOutputStatus::Other(v.into_static())
248 }
249 }
250 }
251}
252
253#[jacquard_derive::open_union]
254#[derive(
255 serde::Serialize,
256 serde::Deserialize,
257 Debug,
258 Clone,
259 PartialEq,
260 Eq,
261 thiserror::Error,
262 miette::Diagnostic,
263 jacquard_derive::IntoStatic
264)]
265#[serde(tag = "error", content = "message")]
266#[serde(bound(deserialize = "'de: 'a"))]
267pub enum GetRepoStatusError<'a> {
268 #[serde(rename = "RepoNotFound")]
269 RepoNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
270}
271
272impl core::fmt::Display for GetRepoStatusError<'_> {
273 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
274 match self {
275 Self::RepoNotFound(msg) => {
276 write!(f, "RepoNotFound")?;
277 if let Some(msg) = msg {
278 write!(f, ": {}", msg)?;
279 }
280 Ok(())
281 }
282 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
283 }
284 }
285}
286
287/// Response type for
288///com.atproto.sync.getRepoStatus
289pub struct GetRepoStatusResponse;
290impl jacquard_common::xrpc::XrpcResp for GetRepoStatusResponse {
291 const NSID: &'static str = "com.atproto.sync.getRepoStatus";
292 const ENCODING: &'static str = "application/json";
293 type Output<'de> = GetRepoStatusOutput<'de>;
294 type Err<'de> = GetRepoStatusError<'de>;
295}
296
297impl<'a> jacquard_common::xrpc::XrpcRequest for GetRepoStatus<'a> {
298 const NSID: &'static str = "com.atproto.sync.getRepoStatus";
299 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
300 type Response = GetRepoStatusResponse;
301}
302
303/// Endpoint type for
304///com.atproto.sync.getRepoStatus
305pub struct GetRepoStatusRequest;
306impl jacquard_common::xrpc::XrpcEndpoint for GetRepoStatusRequest {
307 const PATH: &'static str = "/xrpc/com.atproto.sync.getRepoStatus";
308 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
309 type Request<'de> = GetRepoStatus<'de>;
310 type Response = GetRepoStatusResponse;
311}