jacquard_api/com_atproto/server/
create_invite_code.rs1#[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
37pub 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
54pub 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 pub trait State: sealed::Sealed {
75 type UseCount;
76 }
77 pub struct Empty(());
79 impl sealed::Sealed for Empty {}
80 impl State for Empty {
81 type UseCount = Unset;
82 }
83 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 #[allow(non_camel_case_types)]
91 pub mod members {
92 pub struct use_count(());
94 }
95}
96
97pub 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 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 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 pub fn for_account(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
125 self._fields.0 = value.into();
126 self
127 }
128 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 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 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 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}