atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.deckbelcher.actor.profile
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// A DeckBelcher user profile.
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 Profile<'a> {
21 /// Timestamp when the profile was created.
22 pub created_at: jacquard_common::types::string::Datetime,
23 /// Free-form profile description.
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 #[serde(borrow)]
26 pub description: std::option::Option<jacquard_common::CowStr<'a>>,
27 /// Annotations of text in the profile description (mentions, URLs, hashtags, etc).
28 #[serde(skip_serializing_if = "std::option::Option::is_none")]
29 #[serde(borrow)]
30 pub description_facets: std::option::Option<
31 Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>,
32 >,
33 /// User's display name.
34 #[serde(skip_serializing_if = "std::option::Option::is_none")]
35 #[serde(borrow)]
36 pub display_name: std::option::Option<jacquard_common::CowStr<'a>>,
37 /// Free-form pronouns text.
38 #[serde(skip_serializing_if = "std::option::Option::is_none")]
39 #[serde(borrow)]
40 pub pronouns: std::option::Option<jacquard_common::CowStr<'a>>,
41}
42
43pub mod profile_state {
44
45 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
46 #[allow(unused)]
47 use ::core::marker::PhantomData;
48 mod sealed {
49 pub trait Sealed {}
50 }
51 /// State trait tracking which required fields have been set
52 pub trait State: sealed::Sealed {
53 type CreatedAt;
54 }
55 /// Empty state - all required fields are unset
56 pub struct Empty(());
57 impl sealed::Sealed for Empty {}
58 impl State for Empty {
59 type CreatedAt = Unset;
60 }
61 ///State transition - sets the `created_at` field to Set
62 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
63 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
64 impl<S: State> State for SetCreatedAt<S> {
65 type CreatedAt = Set<members::created_at>;
66 }
67 /// Marker types for field names
68 #[allow(non_camel_case_types)]
69 pub mod members {
70 ///Marker type for the `created_at` field
71 pub struct created_at(());
72 }
73}
74
75/// Builder for constructing an instance of this type
76pub struct ProfileBuilder<'a, S: profile_state::State> {
77 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
78 __unsafe_private_named: (
79 ::core::option::Option<jacquard_common::types::string::Datetime>,
80 ::core::option::Option<jacquard_common::CowStr<'a>>,
81 ::core::option::Option<Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>>,
82 ::core::option::Option<jacquard_common::CowStr<'a>>,
83 ::core::option::Option<jacquard_common::CowStr<'a>>,
84 ),
85 _phantom: ::core::marker::PhantomData<&'a ()>,
86}
87
88impl<'a> Profile<'a> {
89 /// Create a new builder for this type
90 pub fn new() -> ProfileBuilder<'a, profile_state::Empty> {
91 ProfileBuilder::new()
92 }
93}
94
95impl<'a> ProfileBuilder<'a, profile_state::Empty> {
96 /// Create a new builder with all fields unset
97 pub fn new() -> Self {
98 ProfileBuilder {
99 _phantom_state: ::core::marker::PhantomData,
100 __unsafe_private_named: (None, None, None, None, None),
101 _phantom: ::core::marker::PhantomData,
102 }
103 }
104}
105
106impl<'a, S> ProfileBuilder<'a, S>
107where
108 S: profile_state::State,
109 S::CreatedAt: profile_state::IsUnset,
110{
111 /// Set the `createdAt` field (required)
112 pub fn created_at(
113 mut self,
114 value: impl Into<jacquard_common::types::string::Datetime>,
115 ) -> ProfileBuilder<'a, profile_state::SetCreatedAt<S>> {
116 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
117 ProfileBuilder {
118 _phantom_state: ::core::marker::PhantomData,
119 __unsafe_private_named: self.__unsafe_private_named,
120 _phantom: ::core::marker::PhantomData,
121 }
122 }
123}
124
125impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
126 /// Set the `description` field (optional)
127 pub fn description(
128 mut self,
129 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
130 ) -> Self {
131 self.__unsafe_private_named.1 = value.into();
132 self
133 }
134 /// Set the `description` field to an Option value (optional)
135 pub fn maybe_description(
136 mut self,
137 value: Option<jacquard_common::CowStr<'a>>,
138 ) -> Self {
139 self.__unsafe_private_named.1 = value;
140 self
141 }
142}
143
144impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
145 /// Set the `descriptionFacets` field (optional)
146 pub fn description_facets(
147 mut self,
148 value: impl Into<Option<Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>>>,
149 ) -> Self {
150 self.__unsafe_private_named.2 = value.into();
151 self
152 }
153 /// Set the `descriptionFacets` field to an Option value (optional)
154 pub fn maybe_description_facets(
155 mut self,
156 value: Option<Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>>,
157 ) -> Self {
158 self.__unsafe_private_named.2 = value;
159 self
160 }
161}
162
163impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
164 /// Set the `displayName` field (optional)
165 pub fn display_name(
166 mut self,
167 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
168 ) -> Self {
169 self.__unsafe_private_named.3 = value.into();
170 self
171 }
172 /// Set the `displayName` field to an Option value (optional)
173 pub fn maybe_display_name(
174 mut self,
175 value: Option<jacquard_common::CowStr<'a>>,
176 ) -> Self {
177 self.__unsafe_private_named.3 = value;
178 self
179 }
180}
181
182impl<'a, S: profile_state::State> ProfileBuilder<'a, S> {
183 /// Set the `pronouns` field (optional)
184 pub fn pronouns(
185 mut self,
186 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
187 ) -> Self {
188 self.__unsafe_private_named.4 = value.into();
189 self
190 }
191 /// Set the `pronouns` field to an Option value (optional)
192 pub fn maybe_pronouns(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
193 self.__unsafe_private_named.4 = value;
194 self
195 }
196}
197
198impl<'a, S> ProfileBuilder<'a, S>
199where
200 S: profile_state::State,
201 S::CreatedAt: profile_state::IsSet,
202{
203 /// Build the final struct
204 pub fn build(self) -> Profile<'a> {
205 Profile {
206 created_at: self.__unsafe_private_named.0.unwrap(),
207 description: self.__unsafe_private_named.1,
208 description_facets: self.__unsafe_private_named.2,
209 display_name: self.__unsafe_private_named.3,
210 pronouns: self.__unsafe_private_named.4,
211 extra_data: Default::default(),
212 }
213 }
214 /// Build the final struct with custom extra_data
215 pub fn build_with_data(
216 self,
217 extra_data: std::collections::BTreeMap<
218 jacquard_common::smol_str::SmolStr,
219 jacquard_common::types::value::Data<'a>,
220 >,
221 ) -> Profile<'a> {
222 Profile {
223 created_at: self.__unsafe_private_named.0.unwrap(),
224 description: self.__unsafe_private_named.1,
225 description_facets: self.__unsafe_private_named.2,
226 display_name: self.__unsafe_private_named.3,
227 pronouns: self.__unsafe_private_named.4,
228 extra_data: Some(extra_data),
229 }
230 }
231}
232
233impl<'a> Profile<'a> {
234 pub fn uri(
235 uri: impl Into<jacquard_common::CowStr<'a>>,
236 ) -> Result<
237 jacquard_common::types::uri::RecordUri<'a, ProfileRecord>,
238 jacquard_common::types::uri::UriError,
239 > {
240 jacquard_common::types::uri::RecordUri::try_from_uri(
241 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
242 )
243 }
244}
245
246/// Typed wrapper for GetRecord response with this collection's record type.
247#[derive(
248 serde::Serialize,
249 serde::Deserialize,
250 Debug,
251 Clone,
252 PartialEq,
253 Eq,
254 jacquard_derive::IntoStatic
255)]
256#[serde(rename_all = "camelCase")]
257pub struct ProfileGetRecordOutput<'a> {
258 #[serde(skip_serializing_if = "std::option::Option::is_none")]
259 #[serde(borrow)]
260 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
261 #[serde(borrow)]
262 pub uri: jacquard_common::types::string::AtUri<'a>,
263 #[serde(borrow)]
264 pub value: Profile<'a>,
265}
266
267impl From<ProfileGetRecordOutput<'_>> for Profile<'_> {
268 fn from(output: ProfileGetRecordOutput<'_>) -> Self {
269 use jacquard_common::IntoStatic;
270 output.value.into_static()
271 }
272}
273
274impl jacquard_common::types::collection::Collection for Profile<'_> {
275 const NSID: &'static str = "com.deckbelcher.actor.profile";
276 type Record = ProfileRecord;
277}
278
279/// Marker type for deserializing records from this collection.
280#[derive(Debug, serde::Serialize, serde::Deserialize)]
281pub struct ProfileRecord;
282impl jacquard_common::xrpc::XrpcResp for ProfileRecord {
283 const NSID: &'static str = "com.deckbelcher.actor.profile";
284 const ENCODING: &'static str = "application/json";
285 type Output<'de> = ProfileGetRecordOutput<'de>;
286 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
287}
288
289impl jacquard_common::types::collection::Collection for ProfileRecord {
290 const NSID: &'static str = "com.deckbelcher.actor.profile";
291 type Record = ProfileRecord;
292}
293
294impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Profile<'a> {
295 fn nsid() -> &'static str {
296 "com.deckbelcher.actor.profile"
297 }
298 fn def_name() -> &'static str {
299 "main"
300 }
301 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
302 lexicon_doc_com_deckbelcher_actor_profile()
303 }
304 fn validate(
305 &self,
306 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
307 if let Some(ref value) = self.description {
308 #[allow(unused_comparisons)]
309 if <str>::len(value.as_ref()) > 2560usize {
310 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
311 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
312 "description",
313 ),
314 max: 2560usize,
315 actual: <str>::len(value.as_ref()),
316 });
317 }
318 }
319 if let Some(ref value) = self.description {
320 {
321 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
322 value.as_ref(),
323 true,
324 )
325 .count();
326 if count > 256usize {
327 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
328 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
329 "description",
330 ),
331 max: 256usize,
332 actual: count,
333 });
334 }
335 }
336 }
337 if let Some(ref value) = self.display_name {
338 #[allow(unused_comparisons)]
339 if <str>::len(value.as_ref()) > 640usize {
340 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
341 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
342 "display_name",
343 ),
344 max: 640usize,
345 actual: <str>::len(value.as_ref()),
346 });
347 }
348 }
349 if let Some(ref value) = self.display_name {
350 {
351 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
352 value.as_ref(),
353 true,
354 )
355 .count();
356 if count > 64usize {
357 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
358 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
359 "display_name",
360 ),
361 max: 64usize,
362 actual: count,
363 });
364 }
365 }
366 }
367 if let Some(ref value) = self.pronouns {
368 #[allow(unused_comparisons)]
369 if <str>::len(value.as_ref()) > 200usize {
370 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
371 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
372 "pronouns",
373 ),
374 max: 200usize,
375 actual: <str>::len(value.as_ref()),
376 });
377 }
378 }
379 if let Some(ref value) = self.pronouns {
380 {
381 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
382 value.as_ref(),
383 true,
384 )
385 .count();
386 if count > 20usize {
387 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
388 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
389 "pronouns",
390 ),
391 max: 20usize,
392 actual: count,
393 });
394 }
395 }
396 }
397 Ok(())
398 }
399}
400
401fn lexicon_doc_com_deckbelcher_actor_profile() -> ::jacquard_lexicon::lexicon::LexiconDoc<
402 'static,
403> {
404 ::jacquard_lexicon::lexicon::LexiconDoc {
405 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
406 id: ::jacquard_common::CowStr::new_static("com.deckbelcher.actor.profile"),
407 revision: None,
408 description: None,
409 defs: {
410 let mut map = ::alloc::collections::BTreeMap::new();
411 map.insert(
412 ::jacquard_common::smol_str::SmolStr::new_static("main"),
413 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
414 description: Some(
415 ::jacquard_common::CowStr::new_static(
416 "A DeckBelcher user profile.",
417 ),
418 ),
419 key: Some(::jacquard_common::CowStr::new_static("literal:self")),
420 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
421 description: None,
422 required: Some(
423 vec![
424 ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
425 ],
426 ),
427 nullable: None,
428 properties: {
429 #[allow(unused_mut)]
430 let mut map = ::alloc::collections::BTreeMap::new();
431 map.insert(
432 ::jacquard_common::smol_str::SmolStr::new_static(
433 "createdAt",
434 ),
435 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
436 description: Some(
437 ::jacquard_common::CowStr::new_static(
438 "Timestamp when the profile was created.",
439 ),
440 ),
441 format: Some(
442 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
443 ),
444 default: None,
445 min_length: None,
446 max_length: None,
447 min_graphemes: None,
448 max_graphemes: None,
449 r#enum: None,
450 r#const: None,
451 known_values: None,
452 }),
453 );
454 map.insert(
455 ::jacquard_common::smol_str::SmolStr::new_static(
456 "description",
457 ),
458 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
459 description: Some(
460 ::jacquard_common::CowStr::new_static(
461 "Free-form profile description.",
462 ),
463 ),
464 format: None,
465 default: None,
466 min_length: None,
467 max_length: Some(2560usize),
468 min_graphemes: None,
469 max_graphemes: Some(256usize),
470 r#enum: None,
471 r#const: None,
472 known_values: None,
473 }),
474 );
475 map.insert(
476 ::jacquard_common::smol_str::SmolStr::new_static(
477 "descriptionFacets",
478 ),
479 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
480 description: Some(
481 ::jacquard_common::CowStr::new_static(
482 "Annotations of text in the profile description (mentions, URLs, hashtags, etc).",
483 ),
484 ),
485 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
486 description: None,
487 r#ref: ::jacquard_common::CowStr::new_static(
488 "com.deckbelcher.richtext.facet",
489 ),
490 }),
491 min_length: None,
492 max_length: None,
493 }),
494 );
495 map.insert(
496 ::jacquard_common::smol_str::SmolStr::new_static(
497 "displayName",
498 ),
499 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
500 description: Some(
501 ::jacquard_common::CowStr::new_static(
502 "User's display name.",
503 ),
504 ),
505 format: None,
506 default: None,
507 min_length: None,
508 max_length: Some(640usize),
509 min_graphemes: None,
510 max_graphemes: Some(64usize),
511 r#enum: None,
512 r#const: None,
513 known_values: None,
514 }),
515 );
516 map.insert(
517 ::jacquard_common::smol_str::SmolStr::new_static(
518 "pronouns",
519 ),
520 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
521 description: Some(
522 ::jacquard_common::CowStr::new_static(
523 "Free-form pronouns text.",
524 ),
525 ),
526 format: None,
527 default: None,
528 min_length: None,
529 max_length: Some(200usize),
530 min_graphemes: None,
531 max_graphemes: Some(20usize),
532 r#enum: None,
533 r#const: None,
534 known_values: None,
535 }),
536 );
537 map
538 },
539 }),
540 }),
541 );
542 map
543 },
544 }
545}