Skip to main content

jacquard_api/com_atproto/sync/
list_repos.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.listRepos
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;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::string::{Did, Tid, Cid};
18use jacquard_derive::{IntoStatic, lexicon};
19use jacquard_lexicon::lexicon::LexiconDoc;
20use jacquard_lexicon::schema::LexiconSchema;
21
22#[allow(unused_imports)]
23use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
24use serde::{Serialize, Deserialize};
25use crate::com_atproto::sync::list_repos;
26
27#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
28#[serde(rename_all = "camelCase")]
29pub struct ListRepos<'a> {
30    #[serde(skip_serializing_if = "Option::is_none")]
31    #[serde(borrow)]
32    pub cursor: Option<CowStr<'a>>,
33    ///Defaults to `500`. Min: 1. Max: 1000.
34    #[serde(default = "_default_limit")]
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub limit: Option<i64>,
37}
38
39
40#[lexicon]
41#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
42#[serde(rename_all = "camelCase")]
43pub struct ListReposOutput<'a> {
44    #[serde(skip_serializing_if = "Option::is_none")]
45    #[serde(borrow)]
46    pub cursor: Option<CowStr<'a>>,
47    #[serde(borrow)]
48    pub repos: Vec<list_repos::Repo<'a>>,
49}
50
51
52#[lexicon]
53#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
54#[serde(rename_all = "camelCase")]
55pub struct Repo<'a> {
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub active: Option<bool>,
58    #[serde(borrow)]
59    pub did: Did<'a>,
60    ///Current repo commit CID
61    #[serde(borrow)]
62    pub head: Cid<'a>,
63    pub rev: Tid,
64    ///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.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    #[serde(borrow)]
67    pub status: Option<RepoStatus<'a>>,
68}
69
70/// 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.
71
72#[derive(Debug, Clone, PartialEq, Eq, Hash)]
73pub enum RepoStatus<'a> {
74    Takendown,
75    Suspended,
76    Deleted,
77    Deactivated,
78    Desynchronized,
79    Throttled,
80    Other(CowStr<'a>),
81}
82
83impl<'a> RepoStatus<'a> {
84    pub fn as_str(&self) -> &str {
85        match self {
86            Self::Takendown => "takendown",
87            Self::Suspended => "suspended",
88            Self::Deleted => "deleted",
89            Self::Deactivated => "deactivated",
90            Self::Desynchronized => "desynchronized",
91            Self::Throttled => "throttled",
92            Self::Other(s) => s.as_ref(),
93        }
94    }
95}
96
97impl<'a> From<&'a str> for RepoStatus<'a> {
98    fn from(s: &'a str) -> Self {
99        match s {
100            "takendown" => Self::Takendown,
101            "suspended" => Self::Suspended,
102            "deleted" => Self::Deleted,
103            "deactivated" => Self::Deactivated,
104            "desynchronized" => Self::Desynchronized,
105            "throttled" => Self::Throttled,
106            _ => Self::Other(CowStr::from(s)),
107        }
108    }
109}
110
111impl<'a> From<String> for RepoStatus<'a> {
112    fn from(s: String) -> Self {
113        match s.as_str() {
114            "takendown" => Self::Takendown,
115            "suspended" => Self::Suspended,
116            "deleted" => Self::Deleted,
117            "deactivated" => Self::Deactivated,
118            "desynchronized" => Self::Desynchronized,
119            "throttled" => Self::Throttled,
120            _ => Self::Other(CowStr::from(s)),
121        }
122    }
123}
124
125impl<'a> core::fmt::Display for RepoStatus<'a> {
126    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
127        write!(f, "{}", self.as_str())
128    }
129}
130
131impl<'a> AsRef<str> for RepoStatus<'a> {
132    fn as_ref(&self) -> &str {
133        self.as_str()
134    }
135}
136
137impl<'a> serde::Serialize for RepoStatus<'a> {
138    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
139    where
140        S: serde::Serializer,
141    {
142        serializer.serialize_str(self.as_str())
143    }
144}
145
146impl<'de, 'a> serde::Deserialize<'de> for RepoStatus<'a>
147where
148    'de: 'a,
149{
150    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
151    where
152        D: serde::Deserializer<'de>,
153    {
154        let s = <&'de str>::deserialize(deserializer)?;
155        Ok(Self::from(s))
156    }
157}
158
159impl<'a> Default for RepoStatus<'a> {
160    fn default() -> Self {
161        Self::Other(Default::default())
162    }
163}
164
165impl jacquard_common::IntoStatic for RepoStatus<'_> {
166    type Output = RepoStatus<'static>;
167    fn into_static(self) -> Self::Output {
168        match self {
169            RepoStatus::Takendown => RepoStatus::Takendown,
170            RepoStatus::Suspended => RepoStatus::Suspended,
171            RepoStatus::Deleted => RepoStatus::Deleted,
172            RepoStatus::Deactivated => RepoStatus::Deactivated,
173            RepoStatus::Desynchronized => RepoStatus::Desynchronized,
174            RepoStatus::Throttled => RepoStatus::Throttled,
175            RepoStatus::Other(v) => RepoStatus::Other(v.into_static()),
176        }
177    }
178}
179
180/// Response type for com.atproto.sync.listRepos
181pub struct ListReposResponse;
182impl jacquard_common::xrpc::XrpcResp for ListReposResponse {
183    const NSID: &'static str = "com.atproto.sync.listRepos";
184    const ENCODING: &'static str = "application/json";
185    type Output<'de> = ListReposOutput<'de>;
186    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
187}
188
189impl<'a> jacquard_common::xrpc::XrpcRequest for ListRepos<'a> {
190    const NSID: &'static str = "com.atproto.sync.listRepos";
191    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
192    type Response = ListReposResponse;
193}
194
195/// Endpoint type for com.atproto.sync.listRepos
196pub struct ListReposRequest;
197impl jacquard_common::xrpc::XrpcEndpoint for ListReposRequest {
198    const PATH: &'static str = "/xrpc/com.atproto.sync.listRepos";
199    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
200    type Request<'de> = ListRepos<'de>;
201    type Response = ListReposResponse;
202}
203
204impl<'a> LexiconSchema for Repo<'a> {
205    fn nsid() -> &'static str {
206        "com.atproto.sync.listRepos"
207    }
208    fn def_name() -> &'static str {
209        "repo"
210    }
211    fn lexicon_doc() -> LexiconDoc<'static> {
212        lexicon_doc_com_atproto_sync_listRepos()
213    }
214    fn validate(&self) -> Result<(), ConstraintError> {
215        Ok(())
216    }
217}
218
219fn _default_limit() -> Option<i64> {
220    Some(500i64)
221}
222
223pub mod list_repos_state {
224
225    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
226    #[allow(unused)]
227    use ::core::marker::PhantomData;
228    mod sealed {
229        pub trait Sealed {}
230    }
231    /// State trait tracking which required fields have been set
232    pub trait State: sealed::Sealed {}
233    /// Empty state - all required fields are unset
234    pub struct Empty(());
235    impl sealed::Sealed for Empty {}
236    impl State for Empty {}
237    /// Marker types for field names
238    #[allow(non_camel_case_types)]
239    pub mod members {}
240}
241
242/// Builder for constructing an instance of this type
243pub struct ListReposBuilder<'a, S: list_repos_state::State> {
244    _state: PhantomData<fn() -> S>,
245    _fields: (Option<CowStr<'a>>, Option<i64>),
246    _lifetime: PhantomData<&'a ()>,
247}
248
249impl<'a> ListRepos<'a> {
250    /// Create a new builder for this type
251    pub fn new() -> ListReposBuilder<'a, list_repos_state::Empty> {
252        ListReposBuilder::new()
253    }
254}
255
256impl<'a> ListReposBuilder<'a, list_repos_state::Empty> {
257    /// Create a new builder with all fields unset
258    pub fn new() -> Self {
259        ListReposBuilder {
260            _state: PhantomData,
261            _fields: (None, None),
262            _lifetime: PhantomData,
263        }
264    }
265}
266
267impl<'a, S: list_repos_state::State> ListReposBuilder<'a, S> {
268    /// Set the `cursor` field (optional)
269    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
270        self._fields.0 = value.into();
271        self
272    }
273    /// Set the `cursor` field to an Option value (optional)
274    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
275        self._fields.0 = value;
276        self
277    }
278}
279
280impl<'a, S: list_repos_state::State> ListReposBuilder<'a, S> {
281    /// Set the `limit` field (optional)
282    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
283        self._fields.1 = value.into();
284        self
285    }
286    /// Set the `limit` field to an Option value (optional)
287    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
288        self._fields.1 = value;
289        self
290    }
291}
292
293impl<'a, S> ListReposBuilder<'a, S>
294where
295    S: list_repos_state::State,
296{
297    /// Build the final struct
298    pub fn build(self) -> ListRepos<'a> {
299        ListRepos {
300            cursor: self._fields.0,
301            limit: self._fields.1,
302        }
303    }
304}
305
306pub mod repo_state {
307
308    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
309    #[allow(unused)]
310    use ::core::marker::PhantomData;
311    mod sealed {
312        pub trait Sealed {}
313    }
314    /// State trait tracking which required fields have been set
315    pub trait State: sealed::Sealed {
316        type Did;
317        type Head;
318        type Rev;
319    }
320    /// Empty state - all required fields are unset
321    pub struct Empty(());
322    impl sealed::Sealed for Empty {}
323    impl State for Empty {
324        type Did = Unset;
325        type Head = Unset;
326        type Rev = Unset;
327    }
328    ///State transition - sets the `did` field to Set
329    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
330    impl<S: State> sealed::Sealed for SetDid<S> {}
331    impl<S: State> State for SetDid<S> {
332        type Did = Set<members::did>;
333        type Head = S::Head;
334        type Rev = S::Rev;
335    }
336    ///State transition - sets the `head` field to Set
337    pub struct SetHead<S: State = Empty>(PhantomData<fn() -> S>);
338    impl<S: State> sealed::Sealed for SetHead<S> {}
339    impl<S: State> State for SetHead<S> {
340        type Did = S::Did;
341        type Head = Set<members::head>;
342        type Rev = S::Rev;
343    }
344    ///State transition - sets the `rev` field to Set
345    pub struct SetRev<S: State = Empty>(PhantomData<fn() -> S>);
346    impl<S: State> sealed::Sealed for SetRev<S> {}
347    impl<S: State> State for SetRev<S> {
348        type Did = S::Did;
349        type Head = S::Head;
350        type Rev = Set<members::rev>;
351    }
352    /// Marker types for field names
353    #[allow(non_camel_case_types)]
354    pub mod members {
355        ///Marker type for the `did` field
356        pub struct did(());
357        ///Marker type for the `head` field
358        pub struct head(());
359        ///Marker type for the `rev` field
360        pub struct rev(());
361    }
362}
363
364/// Builder for constructing an instance of this type
365pub struct RepoBuilder<'a, S: repo_state::State> {
366    _state: PhantomData<fn() -> S>,
367    _fields: (
368        Option<bool>,
369        Option<Did<'a>>,
370        Option<Cid<'a>>,
371        Option<Tid>,
372        Option<RepoStatus<'a>>,
373    ),
374    _lifetime: PhantomData<&'a ()>,
375}
376
377impl<'a> Repo<'a> {
378    /// Create a new builder for this type
379    pub fn new() -> RepoBuilder<'a, repo_state::Empty> {
380        RepoBuilder::new()
381    }
382}
383
384impl<'a> RepoBuilder<'a, repo_state::Empty> {
385    /// Create a new builder with all fields unset
386    pub fn new() -> Self {
387        RepoBuilder {
388            _state: PhantomData,
389            _fields: (None, None, None, None, None),
390            _lifetime: PhantomData,
391        }
392    }
393}
394
395impl<'a, S: repo_state::State> RepoBuilder<'a, S> {
396    /// Set the `active` field (optional)
397    pub fn active(mut self, value: impl Into<Option<bool>>) -> Self {
398        self._fields.0 = value.into();
399        self
400    }
401    /// Set the `active` field to an Option value (optional)
402    pub fn maybe_active(mut self, value: Option<bool>) -> Self {
403        self._fields.0 = value;
404        self
405    }
406}
407
408impl<'a, S> RepoBuilder<'a, S>
409where
410    S: repo_state::State,
411    S::Did: repo_state::IsUnset,
412{
413    /// Set the `did` field (required)
414    pub fn did(
415        mut self,
416        value: impl Into<Did<'a>>,
417    ) -> RepoBuilder<'a, repo_state::SetDid<S>> {
418        self._fields.1 = Option::Some(value.into());
419        RepoBuilder {
420            _state: PhantomData,
421            _fields: self._fields,
422            _lifetime: PhantomData,
423        }
424    }
425}
426
427impl<'a, S> RepoBuilder<'a, S>
428where
429    S: repo_state::State,
430    S::Head: repo_state::IsUnset,
431{
432    /// Set the `head` field (required)
433    pub fn head(
434        mut self,
435        value: impl Into<Cid<'a>>,
436    ) -> RepoBuilder<'a, repo_state::SetHead<S>> {
437        self._fields.2 = Option::Some(value.into());
438        RepoBuilder {
439            _state: PhantomData,
440            _fields: self._fields,
441            _lifetime: PhantomData,
442        }
443    }
444}
445
446impl<'a, S> RepoBuilder<'a, S>
447where
448    S: repo_state::State,
449    S::Rev: repo_state::IsUnset,
450{
451    /// Set the `rev` field (required)
452    pub fn rev(
453        mut self,
454        value: impl Into<Tid>,
455    ) -> RepoBuilder<'a, repo_state::SetRev<S>> {
456        self._fields.3 = Option::Some(value.into());
457        RepoBuilder {
458            _state: PhantomData,
459            _fields: self._fields,
460            _lifetime: PhantomData,
461        }
462    }
463}
464
465impl<'a, S: repo_state::State> RepoBuilder<'a, S> {
466    /// Set the `status` field (optional)
467    pub fn status(mut self, value: impl Into<Option<RepoStatus<'a>>>) -> Self {
468        self._fields.4 = value.into();
469        self
470    }
471    /// Set the `status` field to an Option value (optional)
472    pub fn maybe_status(mut self, value: Option<RepoStatus<'a>>) -> Self {
473        self._fields.4 = value;
474        self
475    }
476}
477
478impl<'a, S> RepoBuilder<'a, S>
479where
480    S: repo_state::State,
481    S::Did: repo_state::IsSet,
482    S::Head: repo_state::IsSet,
483    S::Rev: repo_state::IsSet,
484{
485    /// Build the final struct
486    pub fn build(self) -> Repo<'a> {
487        Repo {
488            active: self._fields.0,
489            did: self._fields.1.unwrap(),
490            head: self._fields.2.unwrap(),
491            rev: self._fields.3.unwrap(),
492            status: self._fields.4,
493            extra_data: Default::default(),
494        }
495    }
496    /// Build the final struct with custom extra_data
497    pub fn build_with_data(
498        self,
499        extra_data: BTreeMap<
500            jacquard_common::deps::smol_str::SmolStr,
501            jacquard_common::types::value::Data<'a>,
502        >,
503    ) -> Repo<'a> {
504        Repo {
505            active: self._fields.0,
506            did: self._fields.1.unwrap(),
507            head: self._fields.2.unwrap(),
508            rev: self._fields.3.unwrap(),
509            status: self._fields.4,
510            extra_data: Some(extra_data),
511        }
512    }
513}
514
515fn lexicon_doc_com_atproto_sync_listRepos() -> LexiconDoc<'static> {
516    #[allow(unused_imports)]
517    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
518    use jacquard_lexicon::lexicon::*;
519    use alloc::collections::BTreeMap;
520    LexiconDoc {
521        lexicon: Lexicon::Lexicon1,
522        id: CowStr::new_static("com.atproto.sync.listRepos"),
523        defs: {
524            let mut map = BTreeMap::new();
525            map.insert(
526                SmolStr::new_static("main"),
527                LexUserType::XrpcQuery(LexXrpcQuery {
528                    parameters: Some(
529                        LexXrpcQueryParameter::Params(LexXrpcParameters {
530                            properties: {
531                                #[allow(unused_mut)]
532                                let mut map = BTreeMap::new();
533                                map.insert(
534                                    SmolStr::new_static("cursor"),
535                                    LexXrpcParametersProperty::String(LexString {
536                                        ..Default::default()
537                                    }),
538                                );
539                                map.insert(
540                                    SmolStr::new_static("limit"),
541                                    LexXrpcParametersProperty::Integer(LexInteger {
542                                        ..Default::default()
543                                    }),
544                                );
545                                map
546                            },
547                            ..Default::default()
548                        }),
549                    ),
550                    ..Default::default()
551                }),
552            );
553            map.insert(
554                SmolStr::new_static("repo"),
555                LexUserType::Object(LexObject {
556                    required: Some(
557                        vec![
558                            SmolStr::new_static("did"), SmolStr::new_static("head"),
559                            SmolStr::new_static("rev")
560                        ],
561                    ),
562                    properties: {
563                        #[allow(unused_mut)]
564                        let mut map = BTreeMap::new();
565                        map.insert(
566                            SmolStr::new_static("active"),
567                            LexObjectProperty::Boolean(LexBoolean {
568                                ..Default::default()
569                            }),
570                        );
571                        map.insert(
572                            SmolStr::new_static("did"),
573                            LexObjectProperty::String(LexString {
574                                format: Some(LexStringFormat::Did),
575                                ..Default::default()
576                            }),
577                        );
578                        map.insert(
579                            SmolStr::new_static("head"),
580                            LexObjectProperty::String(LexString {
581                                description: Some(
582                                    CowStr::new_static("Current repo commit CID"),
583                                ),
584                                format: Some(LexStringFormat::Cid),
585                                ..Default::default()
586                            }),
587                        );
588                        map.insert(
589                            SmolStr::new_static("rev"),
590                            LexObjectProperty::String(LexString {
591                                format: Some(LexStringFormat::Tid),
592                                ..Default::default()
593                            }),
594                        );
595                        map.insert(
596                            SmolStr::new_static("status"),
597                            LexObjectProperty::String(LexString {
598                                description: Some(
599                                    CowStr::new_static(
600                                        "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.",
601                                    ),
602                                ),
603                                ..Default::default()
604                            }),
605                        );
606                        map
607                    },
608                    ..Default::default()
609                }),
610            );
611            map
612        },
613        ..Default::default()
614    }
615}