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::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
44/** Response marker for the `com.atproto.server.createInviteCode` procedure.
45
46Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `CreateInviteCodeOutput<S>` for this endpoint.*/
47pub 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
62/** Endpoint marker for the `com.atproto.server.createInviteCode` procedure.
63
64Path: `/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.*/
65pub 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    /// State trait tracking which required fields have been set
83    pub trait State: sealed::Sealed {
84        type UseCount;
85    }
86    /// Empty state - all required fields are unset
87    pub struct Empty(());
88    impl sealed::Sealed for Empty {}
89    impl State for Empty {
90        type UseCount = Unset;
91    }
92    ///State transition - sets the `use_count` field to Set
93    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    /// Marker types for field names
99    #[allow(non_camel_case_types)]
100    pub mod members {
101        ///Marker type for the `use_count` field
102        pub struct use_count(());
103    }
104}
105
106/// Builder for constructing an instance of this type.
107pub 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    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
115    pub fn new() -> CreateInviteCodeBuilder<create_invite_code_state::Empty, DefaultStr> {
116        CreateInviteCodeBuilder::new()
117    }
118}
119
120impl<S: BosStr> CreateInviteCode<S> {
121    /// Create a new builder for this type
122    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    /// Create a new builder with all fields unset, using the default string type, if needed
129    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    /// Create a new builder with all fields unset
140    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    /// Set the `forAccount` field (optional)
151    pub fn for_account(mut self, value: impl Into<Option<Did<S>>>) -> Self {
152        self._fields.0 = value.into();
153        self
154    }
155    /// Set the `forAccount` field to an Option value (optional)
156    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    /// Set the `useCount` field (required)
168    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    /// Build the final struct.
187    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    /// Build the final struct with custom extra_data.
195    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}