Skip to main content

jacquard_api/com_atproto/server/
get_account_invite_codes.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.getAccountInviteCodes
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;
14use jacquard_derive::{IntoStatic, lexicon, open_union};
15use serde::{Serialize, Deserialize};
16use crate::com_atproto::server::InviteCode;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetAccountInviteCodes {
21    /// Defaults to `true`.
22    #[serde(default = "_default_create_available")]
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub create_available: Option<bool>,
25    /// Defaults to `true`.
26    #[serde(default = "_default_include_used")]
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub include_used: Option<bool>,
29}
30
31
32#[lexicon]
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
34#[serde(rename_all = "camelCase")]
35pub struct GetAccountInviteCodesOutput<'a> {
36    #[serde(borrow)]
37    pub codes: Vec<InviteCode<'a>>,
38}
39
40
41#[open_union]
42#[derive(
43    Serialize,
44    Deserialize,
45    Debug,
46    Clone,
47    PartialEq,
48    Eq,
49    thiserror::Error,
50    miette::Diagnostic,
51    IntoStatic
52)]
53
54#[serde(tag = "error", content = "message")]
55#[serde(bound(deserialize = "'de: 'a"))]
56pub enum GetAccountInviteCodesError<'a> {
57    #[serde(rename = "DuplicateCreate")]
58    DuplicateCreate(Option<CowStr<'a>>),
59}
60
61impl core::fmt::Display for GetAccountInviteCodesError<'_> {
62    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
63        match self {
64            Self::DuplicateCreate(msg) => {
65                write!(f, "DuplicateCreate")?;
66                if let Some(msg) = msg {
67                    write!(f, ": {}", msg)?;
68                }
69                Ok(())
70            }
71            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
72        }
73    }
74}
75
76/// Response type for com.atproto.server.getAccountInviteCodes
77pub struct GetAccountInviteCodesResponse;
78impl jacquard_common::xrpc::XrpcResp for GetAccountInviteCodesResponse {
79    const NSID: &'static str = "com.atproto.server.getAccountInviteCodes";
80    const ENCODING: &'static str = "application/json";
81    type Output<'de> = GetAccountInviteCodesOutput<'de>;
82    type Err<'de> = GetAccountInviteCodesError<'de>;
83}
84
85impl jacquard_common::xrpc::XrpcRequest for GetAccountInviteCodes {
86    const NSID: &'static str = "com.atproto.server.getAccountInviteCodes";
87    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
88    type Response = GetAccountInviteCodesResponse;
89}
90
91/// Endpoint type for com.atproto.server.getAccountInviteCodes
92pub struct GetAccountInviteCodesRequest;
93impl jacquard_common::xrpc::XrpcEndpoint for GetAccountInviteCodesRequest {
94    const PATH: &'static str = "/xrpc/com.atproto.server.getAccountInviteCodes";
95    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
96    type Request<'de> = GetAccountInviteCodes;
97    type Response = GetAccountInviteCodesResponse;
98}
99
100fn _default_create_available() -> Option<bool> {
101    Some(true)
102}
103
104fn _default_include_used() -> Option<bool> {
105    Some(true)
106}
107
108pub mod get_account_invite_codes_state {
109
110    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
111    #[allow(unused)]
112    use ::core::marker::PhantomData;
113    mod sealed {
114        pub trait Sealed {}
115    }
116    /// State trait tracking which required fields have been set
117    pub trait State: sealed::Sealed {}
118    /// Empty state - all required fields are unset
119    pub struct Empty(());
120    impl sealed::Sealed for Empty {}
121    impl State for Empty {}
122    /// Marker types for field names
123    #[allow(non_camel_case_types)]
124    pub mod members {}
125}
126
127/// Builder for constructing an instance of this type
128pub struct GetAccountInviteCodesBuilder<S: get_account_invite_codes_state::State> {
129    _state: PhantomData<fn() -> S>,
130    _fields: (Option<bool>, Option<bool>),
131}
132
133impl GetAccountInviteCodes {
134    /// Create a new builder for this type
135    pub fn new() -> GetAccountInviteCodesBuilder<get_account_invite_codes_state::Empty> {
136        GetAccountInviteCodesBuilder::new()
137    }
138}
139
140impl GetAccountInviteCodesBuilder<get_account_invite_codes_state::Empty> {
141    /// Create a new builder with all fields unset
142    pub fn new() -> Self {
143        GetAccountInviteCodesBuilder {
144            _state: PhantomData,
145            _fields: (None, None),
146        }
147    }
148}
149
150impl<S: get_account_invite_codes_state::State> GetAccountInviteCodesBuilder<S> {
151    /// Set the `createAvailable` field (optional)
152    pub fn create_available(mut self, value: impl Into<Option<bool>>) -> Self {
153        self._fields.0 = value.into();
154        self
155    }
156    /// Set the `createAvailable` field to an Option value (optional)
157    pub fn maybe_create_available(mut self, value: Option<bool>) -> Self {
158        self._fields.0 = value;
159        self
160    }
161}
162
163impl<S: get_account_invite_codes_state::State> GetAccountInviteCodesBuilder<S> {
164    /// Set the `includeUsed` field (optional)
165    pub fn include_used(mut self, value: impl Into<Option<bool>>) -> Self {
166        self._fields.1 = value.into();
167        self
168    }
169    /// Set the `includeUsed` field to an Option value (optional)
170    pub fn maybe_include_used(mut self, value: Option<bool>) -> Self {
171        self._fields.1 = value;
172        self
173    }
174}
175
176impl<S> GetAccountInviteCodesBuilder<S>
177where
178    S: get_account_invite_codes_state::State,
179{
180    /// Build the final struct
181    pub fn build(self) -> GetAccountInviteCodes {
182        GetAccountInviteCodes {
183            create_available: self._fields.0,
184            include_used: self._fields.1,
185        }
186    }
187}