Skip to main content

jacquard_api/com_atproto/server/
create_invite_code.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.createInviteCode
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_common::types::string::Did;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17
18#[lexicon]
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct CreateInviteCode<'a> {
22    #[serde(skip_serializing_if = "Option::is_none")]
23    #[serde(borrow)]
24    pub for_account: Option<Did<'a>>,
25    pub use_count: i64,
26}
27
28
29#[lexicon]
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
31#[serde(rename_all = "camelCase")]
32pub struct CreateInviteCodeOutput<'a> {
33    #[serde(borrow)]
34    pub code: CowStr<'a>,
35}
36
37/// Response type for com.atproto.server.createInviteCode
38pub struct CreateInviteCodeResponse;
39impl jacquard_common::xrpc::XrpcResp for CreateInviteCodeResponse {
40    const NSID: &'static str = "com.atproto.server.createInviteCode";
41    const ENCODING: &'static str = "application/json";
42    type Output<'de> = CreateInviteCodeOutput<'de>;
43    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
44}
45
46impl<'a> jacquard_common::xrpc::XrpcRequest for CreateInviteCode<'a> {
47    const NSID: &'static str = "com.atproto.server.createInviteCode";
48    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
49        "application/json",
50    );
51    type Response = CreateInviteCodeResponse;
52}
53
54/// Endpoint type for com.atproto.server.createInviteCode
55pub struct CreateInviteCodeRequest;
56impl jacquard_common::xrpc::XrpcEndpoint for CreateInviteCodeRequest {
57    const PATH: &'static str = "/xrpc/com.atproto.server.createInviteCode";
58    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
59        "application/json",
60    );
61    type Request<'de> = CreateInviteCode<'de>;
62    type Response = CreateInviteCodeResponse;
63}
64
65pub mod create_invite_code_state {
66
67    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
68    #[allow(unused)]
69    use ::core::marker::PhantomData;
70    mod sealed {
71        pub trait Sealed {}
72    }
73    /// State trait tracking which required fields have been set
74    pub trait State: sealed::Sealed {
75        type UseCount;
76    }
77    /// Empty state - all required fields are unset
78    pub struct Empty(());
79    impl sealed::Sealed for Empty {}
80    impl State for Empty {
81        type UseCount = Unset;
82    }
83    ///State transition - sets the `use_count` field to Set
84    pub struct SetUseCount<S: State = Empty>(PhantomData<fn() -> S>);
85    impl<S: State> sealed::Sealed for SetUseCount<S> {}
86    impl<S: State> State for SetUseCount<S> {
87        type UseCount = Set<members::use_count>;
88    }
89    /// Marker types for field names
90    #[allow(non_camel_case_types)]
91    pub mod members {
92        ///Marker type for the `use_count` field
93        pub struct use_count(());
94    }
95}
96
97/// Builder for constructing an instance of this type
98pub struct CreateInviteCodeBuilder<'a, S: create_invite_code_state::State> {
99    _state: PhantomData<fn() -> S>,
100    _fields: (Option<Did<'a>>, Option<i64>),
101    _lifetime: PhantomData<&'a ()>,
102}
103
104impl<'a> CreateInviteCode<'a> {
105    /// Create a new builder for this type
106    pub fn new() -> CreateInviteCodeBuilder<'a, create_invite_code_state::Empty> {
107        CreateInviteCodeBuilder::new()
108    }
109}
110
111impl<'a> CreateInviteCodeBuilder<'a, create_invite_code_state::Empty> {
112    /// Create a new builder with all fields unset
113    pub fn new() -> Self {
114        CreateInviteCodeBuilder {
115            _state: PhantomData,
116            _fields: (None, None),
117            _lifetime: PhantomData,
118        }
119    }
120}
121
122impl<'a, S: create_invite_code_state::State> CreateInviteCodeBuilder<'a, S> {
123    /// Set the `forAccount` field (optional)
124    pub fn for_account(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
125        self._fields.0 = value.into();
126        self
127    }
128    /// Set the `forAccount` field to an Option value (optional)
129    pub fn maybe_for_account(mut self, value: Option<Did<'a>>) -> Self {
130        self._fields.0 = value;
131        self
132    }
133}
134
135impl<'a, S> CreateInviteCodeBuilder<'a, S>
136where
137    S: create_invite_code_state::State,
138    S::UseCount: create_invite_code_state::IsUnset,
139{
140    /// Set the `useCount` field (required)
141    pub fn use_count(
142        mut self,
143        value: impl Into<i64>,
144    ) -> CreateInviteCodeBuilder<'a, create_invite_code_state::SetUseCount<S>> {
145        self._fields.1 = Option::Some(value.into());
146        CreateInviteCodeBuilder {
147            _state: PhantomData,
148            _fields: self._fields,
149            _lifetime: PhantomData,
150        }
151    }
152}
153
154impl<'a, S> CreateInviteCodeBuilder<'a, S>
155where
156    S: create_invite_code_state::State,
157    S::UseCount: create_invite_code_state::IsSet,
158{
159    /// Build the final struct
160    pub fn build(self) -> CreateInviteCode<'a> {
161        CreateInviteCode {
162            for_account: self._fields.0,
163            use_count: self._fields.1.unwrap(),
164            extra_data: Default::default(),
165        }
166    }
167    /// Build the final struct with custom extra_data
168    pub fn build_with_data(
169        self,
170        extra_data: BTreeMap<
171            jacquard_common::deps::smol_str::SmolStr,
172            jacquard_common::types::value::Data<'a>,
173        >,
174    ) -> CreateInviteCode<'a> {
175        CreateInviteCode {
176            for_account: self._fields.0,
177            use_count: self._fields.1.unwrap(),
178            extra_data: Some(extra_data),
179        }
180    }
181}