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::deps::smol_str::SmolStr;
14use jacquard_common::types::string::Did;
15use jacquard_common::types::value::Data;
16use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
17use jacquard_derive::IntoStatic;
18use serde::{Deserialize, Serialize};
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(
22 rename_all = "camelCase",
23 bound(deserialize = "S: Deserialize<'de> + BosStr")
24)]
25pub struct CreateInviteCode<S: BosStr = DefaultStr> {
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub for_account: Option<Did<S>>,
28 pub use_count: i64,
29 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
30 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
31}
32
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
34#[serde(
35 rename_all = "camelCase",
36 bound(deserialize = "S: Deserialize<'de> + BosStr")
37)]
38pub struct CreateInviteCodeOutput<S: BosStr = DefaultStr> {
39 pub code: S,
40 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
41 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
42}
43
44pub struct CreateInviteCodeResponse;
48impl jacquard_common::xrpc::XrpcResp for CreateInviteCodeResponse {
49 const NSID: &'static str = "com.atproto.server.createInviteCode";
50 const ENCODING: &'static str = "application/json";
51 type Output<S: BosStr> = CreateInviteCodeOutput<S>;
52 type Err = jacquard_common::xrpc::GenericError;
53}
54
55impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CreateInviteCode<S> {
56 const NSID: &'static str = "com.atproto.server.createInviteCode";
57 const METHOD: jacquard_common::xrpc::XrpcMethod =
58 jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
59 type Response = CreateInviteCodeResponse;
60}
61
62pub struct CreateInviteCodeRequest;
66impl jacquard_common::xrpc::XrpcEndpoint for CreateInviteCodeRequest {
67 const PATH: &'static str = "/xrpc/com.atproto.server.createInviteCode";
68 const METHOD: jacquard_common::xrpc::XrpcMethod =
69 jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
70 type Request<S: BosStr> = CreateInviteCode<S>;
71 type Response = CreateInviteCodeResponse;
72}
73
74pub mod create_invite_code_state {
75
76 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
77 #[allow(unused)]
78 use ::core::marker::PhantomData;
79 mod sealed {
80 pub trait Sealed {}
81 }
82 pub trait State: sealed::Sealed {
84 type UseCount;
85 }
86 pub struct Empty(());
88 impl sealed::Sealed for Empty {}
89 impl State for Empty {
90 type UseCount = Unset;
91 }
92 pub struct SetUseCount<St: State = Empty>(PhantomData<fn() -> St>);
94 impl<St: State> sealed::Sealed for SetUseCount<St> {}
95 impl<St: State> State for SetUseCount<St> {
96 type UseCount = Set<members::use_count>;
97 }
98 #[allow(non_camel_case_types)]
100 pub mod members {
101 pub struct use_count(());
103 }
104}
105
106pub struct CreateInviteCodeBuilder<St: create_invite_code_state::State, S: BosStr = DefaultStr> {
108 _state: PhantomData<fn() -> St>,
109 _fields: (Option<Did<S>>, Option<i64>),
110 _type: PhantomData<fn() -> S>,
111}
112
113impl CreateInviteCode<DefaultStr> {
114 pub fn new() -> CreateInviteCodeBuilder<create_invite_code_state::Empty, DefaultStr> {
116 CreateInviteCodeBuilder::new()
117 }
118}
119
120impl<S: BosStr> CreateInviteCode<S> {
121 pub fn builder() -> CreateInviteCodeBuilder<create_invite_code_state::Empty, S> {
123 CreateInviteCodeBuilder::builder()
124 }
125}
126
127impl CreateInviteCodeBuilder<create_invite_code_state::Empty, DefaultStr> {
128 pub fn new() -> Self {
130 CreateInviteCodeBuilder {
131 _state: PhantomData,
132 _fields: (None, None),
133 _type: PhantomData,
134 }
135 }
136}
137
138impl<S: BosStr> CreateInviteCodeBuilder<create_invite_code_state::Empty, S> {
139 pub fn builder() -> Self {
141 CreateInviteCodeBuilder {
142 _state: PhantomData,
143 _fields: (None, None),
144 _type: PhantomData,
145 }
146 }
147}
148
149impl<St: create_invite_code_state::State, S: BosStr> CreateInviteCodeBuilder<St, S> {
150 pub fn for_account(mut self, value: impl Into<Option<Did<S>>>) -> Self {
152 self._fields.0 = value.into();
153 self
154 }
155 pub fn maybe_for_account(mut self, value: Option<Did<S>>) -> Self {
157 self._fields.0 = value;
158 self
159 }
160}
161
162impl<St, S: BosStr> CreateInviteCodeBuilder<St, S>
163where
164 St: create_invite_code_state::State,
165 St::UseCount: create_invite_code_state::IsUnset,
166{
167 pub fn use_count(
169 mut self,
170 value: impl Into<i64>,
171 ) -> CreateInviteCodeBuilder<create_invite_code_state::SetUseCount<St>, S> {
172 self._fields.1 = Option::Some(value.into());
173 CreateInviteCodeBuilder {
174 _state: PhantomData,
175 _fields: self._fields,
176 _type: PhantomData,
177 }
178 }
179}
180
181impl<St, S: BosStr> CreateInviteCodeBuilder<St, S>
182where
183 St: create_invite_code_state::State,
184 St::UseCount: create_invite_code_state::IsSet,
185{
186 pub fn build(self) -> CreateInviteCode<S> {
188 CreateInviteCode {
189 for_account: self._fields.0,
190 use_count: self._fields.1.unwrap(),
191 extra_data: Default::default(),
192 }
193 }
194 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CreateInviteCode<S> {
196 CreateInviteCode {
197 for_account: self._fields.0,
198 use_count: self._fields.1.unwrap(),
199 extra_data: Some(extra_data),
200 }
201 }
202}