atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.graph.followGate
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Settings controlling follow approval behavior. Absence means auto-accept.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct FollowGate<'a> {
21 pub created_at: jacquard_common::types::string::Datetime,
22 /// If true, previously auto-accepted follows are invalidated when requireApproval is enabled. Appview should treat followAccept records created before this gate's createdAt as invalid.
23 #[serde(skip_serializing_if = "std::option::Option::is_none")]
24 pub invalidate_prior: std::option::Option<bool>,
25 /// If true, follows require manual acceptance.
26 #[serde(skip_serializing_if = "std::option::Option::is_none")]
27 pub require_approval: std::option::Option<bool>,
28}
29
30pub mod follow_gate_state {
31
32 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
33 #[allow(unused)]
34 use ::core::marker::PhantomData;
35 mod sealed {
36 pub trait Sealed {}
37 }
38 /// State trait tracking which required fields have been set
39 pub trait State: sealed::Sealed {
40 type CreatedAt;
41 }
42 /// Empty state - all required fields are unset
43 pub struct Empty(());
44 impl sealed::Sealed for Empty {}
45 impl State for Empty {
46 type CreatedAt = Unset;
47 }
48 ///State transition - sets the `created_at` field to Set
49 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
50 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
51 impl<S: State> State for SetCreatedAt<S> {
52 type CreatedAt = Set<members::created_at>;
53 }
54 /// Marker types for field names
55 #[allow(non_camel_case_types)]
56 pub mod members {
57 ///Marker type for the `created_at` field
58 pub struct created_at(());
59 }
60}
61
62/// Builder for constructing an instance of this type
63pub struct FollowGateBuilder<'a, S: follow_gate_state::State> {
64 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
65 __unsafe_private_named: (
66 ::core::option::Option<jacquard_common::types::string::Datetime>,
67 ::core::option::Option<bool>,
68 ::core::option::Option<bool>,
69 ),
70 _phantom: ::core::marker::PhantomData<&'a ()>,
71}
72
73impl<'a> FollowGate<'a> {
74 /// Create a new builder for this type
75 pub fn new() -> FollowGateBuilder<'a, follow_gate_state::Empty> {
76 FollowGateBuilder::new()
77 }
78}
79
80impl<'a> FollowGateBuilder<'a, follow_gate_state::Empty> {
81 /// Create a new builder with all fields unset
82 pub fn new() -> Self {
83 FollowGateBuilder {
84 _phantom_state: ::core::marker::PhantomData,
85 __unsafe_private_named: (None, None, None),
86 _phantom: ::core::marker::PhantomData,
87 }
88 }
89}
90
91impl<'a, S> FollowGateBuilder<'a, S>
92where
93 S: follow_gate_state::State,
94 S::CreatedAt: follow_gate_state::IsUnset,
95{
96 /// Set the `createdAt` field (required)
97 pub fn created_at(
98 mut self,
99 value: impl Into<jacquard_common::types::string::Datetime>,
100 ) -> FollowGateBuilder<'a, follow_gate_state::SetCreatedAt<S>> {
101 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
102 FollowGateBuilder {
103 _phantom_state: ::core::marker::PhantomData,
104 __unsafe_private_named: self.__unsafe_private_named,
105 _phantom: ::core::marker::PhantomData,
106 }
107 }
108}
109
110impl<'a, S: follow_gate_state::State> FollowGateBuilder<'a, S> {
111 /// Set the `invalidatePrior` field (optional)
112 pub fn invalidate_prior(mut self, value: impl Into<Option<bool>>) -> Self {
113 self.__unsafe_private_named.1 = value.into();
114 self
115 }
116 /// Set the `invalidatePrior` field to an Option value (optional)
117 pub fn maybe_invalidate_prior(mut self, value: Option<bool>) -> Self {
118 self.__unsafe_private_named.1 = value;
119 self
120 }
121}
122
123impl<'a, S: follow_gate_state::State> FollowGateBuilder<'a, S> {
124 /// Set the `requireApproval` field (optional)
125 pub fn require_approval(mut self, value: impl Into<Option<bool>>) -> Self {
126 self.__unsafe_private_named.2 = value.into();
127 self
128 }
129 /// Set the `requireApproval` field to an Option value (optional)
130 pub fn maybe_require_approval(mut self, value: Option<bool>) -> Self {
131 self.__unsafe_private_named.2 = value;
132 self
133 }
134}
135
136impl<'a, S> FollowGateBuilder<'a, S>
137where
138 S: follow_gate_state::State,
139 S::CreatedAt: follow_gate_state::IsSet,
140{
141 /// Build the final struct
142 pub fn build(self) -> FollowGate<'a> {
143 FollowGate {
144 created_at: self.__unsafe_private_named.0.unwrap(),
145 invalidate_prior: self.__unsafe_private_named.1,
146 require_approval: self.__unsafe_private_named.2,
147 extra_data: Default::default(),
148 }
149 }
150 /// Build the final struct with custom extra_data
151 pub fn build_with_data(
152 self,
153 extra_data: std::collections::BTreeMap<
154 jacquard_common::smol_str::SmolStr,
155 jacquard_common::types::value::Data<'a>,
156 >,
157 ) -> FollowGate<'a> {
158 FollowGate {
159 created_at: self.__unsafe_private_named.0.unwrap(),
160 invalidate_prior: self.__unsafe_private_named.1,
161 require_approval: self.__unsafe_private_named.2,
162 extra_data: Some(extra_data),
163 }
164 }
165}
166
167impl<'a> FollowGate<'a> {
168 pub fn uri(
169 uri: impl Into<jacquard_common::CowStr<'a>>,
170 ) -> Result<
171 jacquard_common::types::uri::RecordUri<'a, FollowGateRecord>,
172 jacquard_common::types::uri::UriError,
173 > {
174 jacquard_common::types::uri::RecordUri::try_from_uri(
175 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
176 )
177 }
178}
179
180/// Typed wrapper for GetRecord response with this collection's record type.
181#[derive(
182 serde::Serialize,
183 serde::Deserialize,
184 Debug,
185 Clone,
186 PartialEq,
187 Eq,
188 jacquard_derive::IntoStatic
189)]
190#[serde(rename_all = "camelCase")]
191pub struct FollowGateGetRecordOutput<'a> {
192 #[serde(skip_serializing_if = "std::option::Option::is_none")]
193 #[serde(borrow)]
194 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
195 #[serde(borrow)]
196 pub uri: jacquard_common::types::string::AtUri<'a>,
197 #[serde(borrow)]
198 pub value: FollowGate<'a>,
199}
200
201impl From<FollowGateGetRecordOutput<'_>> for FollowGate<'_> {
202 fn from(output: FollowGateGetRecordOutput<'_>) -> Self {
203 use jacquard_common::IntoStatic;
204 output.value.into_static()
205 }
206}
207
208impl jacquard_common::types::collection::Collection for FollowGate<'_> {
209 const NSID: &'static str = "sh.weaver.graph.followGate";
210 type Record = FollowGateRecord;
211}
212
213/// Marker type for deserializing records from this collection.
214#[derive(Debug, serde::Serialize, serde::Deserialize)]
215pub struct FollowGateRecord;
216impl jacquard_common::xrpc::XrpcResp for FollowGateRecord {
217 const NSID: &'static str = "sh.weaver.graph.followGate";
218 const ENCODING: &'static str = "application/json";
219 type Output<'de> = FollowGateGetRecordOutput<'de>;
220 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
221}
222
223impl jacquard_common::types::collection::Collection for FollowGateRecord {
224 const NSID: &'static str = "sh.weaver.graph.followGate";
225 type Record = FollowGateRecord;
226}
227
228impl<'a> ::jacquard_lexicon::schema::LexiconSchema for FollowGate<'a> {
229 fn nsid() -> &'static str {
230 "sh.weaver.graph.followGate"
231 }
232 fn def_name() -> &'static str {
233 "main"
234 }
235 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
236 lexicon_doc_sh_weaver_graph_followGate()
237 }
238 fn validate(
239 &self,
240 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
241 Ok(())
242 }
243}
244
245fn lexicon_doc_sh_weaver_graph_followGate() -> ::jacquard_lexicon::lexicon::LexiconDoc<
246 'static,
247> {
248 ::jacquard_lexicon::lexicon::LexiconDoc {
249 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
250 id: ::jacquard_common::CowStr::new_static("sh.weaver.graph.followGate"),
251 revision: None,
252 description: None,
253 defs: {
254 let mut map = ::alloc::collections::BTreeMap::new();
255 map.insert(
256 ::jacquard_common::smol_str::SmolStr::new_static("main"),
257 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
258 description: Some(
259 ::jacquard_common::CowStr::new_static(
260 "Settings controlling follow approval behavior. Absence means auto-accept.",
261 ),
262 ),
263 key: Some(::jacquard_common::CowStr::new_static("self")),
264 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
265 description: None,
266 required: Some(
267 vec![
268 ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
269 ],
270 ),
271 nullable: None,
272 properties: {
273 #[allow(unused_mut)]
274 let mut map = ::alloc::collections::BTreeMap::new();
275 map.insert(
276 ::jacquard_common::smol_str::SmolStr::new_static(
277 "createdAt",
278 ),
279 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
280 description: None,
281 format: Some(
282 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
283 ),
284 default: None,
285 min_length: None,
286 max_length: None,
287 min_graphemes: None,
288 max_graphemes: None,
289 r#enum: None,
290 r#const: None,
291 known_values: None,
292 }),
293 );
294 map.insert(
295 ::jacquard_common::smol_str::SmolStr::new_static(
296 "invalidatePrior",
297 ),
298 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
299 description: None,
300 default: None,
301 r#const: None,
302 }),
303 );
304 map.insert(
305 ::jacquard_common::smol_str::SmolStr::new_static(
306 "requireApproval",
307 ),
308 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
309 description: None,
310 default: None,
311 r#const: None,
312 }),
313 );
314 map
315 },
316 }),
317 }),
318 );
319 map
320 },
321 }
322}