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