1pub mod declaration;
9pub mod delete_account;
10pub mod export_account_data;
11
12
13#[allow(unused_imports)]
14use alloc::collections::BTreeMap;
15
16#[allow(unused_imports)]
17use core::marker::PhantomData;
18use jacquard_common::CowStr;
19
20#[allow(unused_imports)]
21use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
22use jacquard_common::types::string::{Did, Handle, UriValue};
23use jacquard_derive::{IntoStatic, lexicon};
24use jacquard_lexicon::lexicon::LexiconDoc;
25use jacquard_lexicon::schema::LexiconSchema;
26
27#[allow(unused_imports)]
28use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
29use serde::{Serialize, Deserialize};
30use crate::app_bsky::actor::ProfileAssociated;
31use crate::app_bsky::actor::VerificationState;
32use crate::app_bsky::actor::ViewerState;
33use crate::com_atproto::label::Label;
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase")]
38pub struct ProfileViewBasic<'a> {
39 #[serde(skip_serializing_if = "Option::is_none")]
40 #[serde(borrow)]
41 pub associated: Option<ProfileAssociated<'a>>,
42 #[serde(skip_serializing_if = "Option::is_none")]
43 #[serde(borrow)]
44 pub avatar: Option<UriValue<'a>>,
45 #[serde(skip_serializing_if = "Option::is_none")]
47 pub chat_disabled: Option<bool>,
48 #[serde(borrow)]
49 pub did: Did<'a>,
50 #[serde(skip_serializing_if = "Option::is_none")]
51 #[serde(borrow)]
52 pub display_name: Option<CowStr<'a>>,
53 #[serde(borrow)]
54 pub handle: Handle<'a>,
55 #[serde(skip_serializing_if = "Option::is_none")]
56 #[serde(borrow)]
57 pub labels: Option<Vec<Label<'a>>>,
58 #[serde(skip_serializing_if = "Option::is_none")]
59 #[serde(borrow)]
60 pub verification: Option<VerificationState<'a>>,
61 #[serde(skip_serializing_if = "Option::is_none")]
62 #[serde(borrow)]
63 pub viewer: Option<ViewerState<'a>>,
64}
65
66impl<'a> LexiconSchema for ProfileViewBasic<'a> {
67 fn nsid() -> &'static str {
68 "chat.bsky.actor.defs"
69 }
70 fn def_name() -> &'static str {
71 "profileViewBasic"
72 }
73 fn lexicon_doc() -> LexiconDoc<'static> {
74 lexicon_doc_chat_bsky_actor_defs()
75 }
76 fn validate(&self) -> Result<(), ConstraintError> {
77 if let Some(ref value) = self.display_name {
78 #[allow(unused_comparisons)]
79 if <str>::len(value.as_ref()) > 640usize {
80 return Err(ConstraintError::MaxLength {
81 path: ValidationPath::from_field("display_name"),
82 max: 640usize,
83 actual: <str>::len(value.as_ref()),
84 });
85 }
86 }
87 if let Some(ref value) = self.display_name {
88 {
89 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
90 if count > 64usize {
91 return Err(ConstraintError::MaxGraphemes {
92 path: ValidationPath::from_field("display_name"),
93 max: 64usize,
94 actual: count,
95 });
96 }
97 }
98 }
99 Ok(())
100 }
101}
102
103pub mod profile_view_basic_state {
104
105 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
106 #[allow(unused)]
107 use ::core::marker::PhantomData;
108 mod sealed {
109 pub trait Sealed {}
110 }
111 pub trait State: sealed::Sealed {
113 type Did;
114 type Handle;
115 }
116 pub struct Empty(());
118 impl sealed::Sealed for Empty {}
119 impl State for Empty {
120 type Did = Unset;
121 type Handle = Unset;
122 }
123 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
125 impl<S: State> sealed::Sealed for SetDid<S> {}
126 impl<S: State> State for SetDid<S> {
127 type Did = Set<members::did>;
128 type Handle = S::Handle;
129 }
130 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
132 impl<S: State> sealed::Sealed for SetHandle<S> {}
133 impl<S: State> State for SetHandle<S> {
134 type Did = S::Did;
135 type Handle = Set<members::handle>;
136 }
137 #[allow(non_camel_case_types)]
139 pub mod members {
140 pub struct did(());
142 pub struct handle(());
144 }
145}
146
147pub struct ProfileViewBasicBuilder<'a, S: profile_view_basic_state::State> {
149 _state: PhantomData<fn() -> S>,
150 _fields: (
151 Option<ProfileAssociated<'a>>,
152 Option<UriValue<'a>>,
153 Option<bool>,
154 Option<Did<'a>>,
155 Option<CowStr<'a>>,
156 Option<Handle<'a>>,
157 Option<Vec<Label<'a>>>,
158 Option<VerificationState<'a>>,
159 Option<ViewerState<'a>>,
160 ),
161 _lifetime: PhantomData<&'a ()>,
162}
163
164impl<'a> ProfileViewBasic<'a> {
165 pub fn new() -> ProfileViewBasicBuilder<'a, profile_view_basic_state::Empty> {
167 ProfileViewBasicBuilder::new()
168 }
169}
170
171impl<'a> ProfileViewBasicBuilder<'a, profile_view_basic_state::Empty> {
172 pub fn new() -> Self {
174 ProfileViewBasicBuilder {
175 _state: PhantomData,
176 _fields: (None, None, None, None, None, None, None, None, None),
177 _lifetime: PhantomData,
178 }
179 }
180}
181
182impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
183 pub fn associated(
185 mut self,
186 value: impl Into<Option<ProfileAssociated<'a>>>,
187 ) -> Self {
188 self._fields.0 = value.into();
189 self
190 }
191 pub fn maybe_associated(mut self, value: Option<ProfileAssociated<'a>>) -> Self {
193 self._fields.0 = value;
194 self
195 }
196}
197
198impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
199 pub fn avatar(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
201 self._fields.1 = value.into();
202 self
203 }
204 pub fn maybe_avatar(mut self, value: Option<UriValue<'a>>) -> Self {
206 self._fields.1 = value;
207 self
208 }
209}
210
211impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
212 pub fn chat_disabled(mut self, value: impl Into<Option<bool>>) -> Self {
214 self._fields.2 = value.into();
215 self
216 }
217 pub fn maybe_chat_disabled(mut self, value: Option<bool>) -> Self {
219 self._fields.2 = value;
220 self
221 }
222}
223
224impl<'a, S> ProfileViewBasicBuilder<'a, S>
225where
226 S: profile_view_basic_state::State,
227 S::Did: profile_view_basic_state::IsUnset,
228{
229 pub fn did(
231 mut self,
232 value: impl Into<Did<'a>>,
233 ) -> ProfileViewBasicBuilder<'a, profile_view_basic_state::SetDid<S>> {
234 self._fields.3 = Option::Some(value.into());
235 ProfileViewBasicBuilder {
236 _state: PhantomData,
237 _fields: self._fields,
238 _lifetime: PhantomData,
239 }
240 }
241}
242
243impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
244 pub fn display_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
246 self._fields.4 = value.into();
247 self
248 }
249 pub fn maybe_display_name(mut self, value: Option<CowStr<'a>>) -> Self {
251 self._fields.4 = value;
252 self
253 }
254}
255
256impl<'a, S> ProfileViewBasicBuilder<'a, S>
257where
258 S: profile_view_basic_state::State,
259 S::Handle: profile_view_basic_state::IsUnset,
260{
261 pub fn handle(
263 mut self,
264 value: impl Into<Handle<'a>>,
265 ) -> ProfileViewBasicBuilder<'a, profile_view_basic_state::SetHandle<S>> {
266 self._fields.5 = Option::Some(value.into());
267 ProfileViewBasicBuilder {
268 _state: PhantomData,
269 _fields: self._fields,
270 _lifetime: PhantomData,
271 }
272 }
273}
274
275impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
276 pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> Self {
278 self._fields.6 = value.into();
279 self
280 }
281 pub fn maybe_labels(mut self, value: Option<Vec<Label<'a>>>) -> Self {
283 self._fields.6 = value;
284 self
285 }
286}
287
288impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
289 pub fn verification(
291 mut self,
292 value: impl Into<Option<VerificationState<'a>>>,
293 ) -> Self {
294 self._fields.7 = value.into();
295 self
296 }
297 pub fn maybe_verification(mut self, value: Option<VerificationState<'a>>) -> Self {
299 self._fields.7 = value;
300 self
301 }
302}
303
304impl<'a, S: profile_view_basic_state::State> ProfileViewBasicBuilder<'a, S> {
305 pub fn viewer(mut self, value: impl Into<Option<ViewerState<'a>>>) -> Self {
307 self._fields.8 = value.into();
308 self
309 }
310 pub fn maybe_viewer(mut self, value: Option<ViewerState<'a>>) -> Self {
312 self._fields.8 = value;
313 self
314 }
315}
316
317impl<'a, S> ProfileViewBasicBuilder<'a, S>
318where
319 S: profile_view_basic_state::State,
320 S::Did: profile_view_basic_state::IsSet,
321 S::Handle: profile_view_basic_state::IsSet,
322{
323 pub fn build(self) -> ProfileViewBasic<'a> {
325 ProfileViewBasic {
326 associated: self._fields.0,
327 avatar: self._fields.1,
328 chat_disabled: self._fields.2,
329 did: self._fields.3.unwrap(),
330 display_name: self._fields.4,
331 handle: self._fields.5.unwrap(),
332 labels: self._fields.6,
333 verification: self._fields.7,
334 viewer: self._fields.8,
335 extra_data: Default::default(),
336 }
337 }
338 pub fn build_with_data(
340 self,
341 extra_data: BTreeMap<
342 jacquard_common::deps::smol_str::SmolStr,
343 jacquard_common::types::value::Data<'a>,
344 >,
345 ) -> ProfileViewBasic<'a> {
346 ProfileViewBasic {
347 associated: self._fields.0,
348 avatar: self._fields.1,
349 chat_disabled: self._fields.2,
350 did: self._fields.3.unwrap(),
351 display_name: self._fields.4,
352 handle: self._fields.5.unwrap(),
353 labels: self._fields.6,
354 verification: self._fields.7,
355 viewer: self._fields.8,
356 extra_data: Some(extra_data),
357 }
358 }
359}
360
361fn lexicon_doc_chat_bsky_actor_defs() -> LexiconDoc<'static> {
362 #[allow(unused_imports)]
363 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
364 use jacquard_lexicon::lexicon::*;
365 use alloc::collections::BTreeMap;
366 LexiconDoc {
367 lexicon: Lexicon::Lexicon1,
368 id: CowStr::new_static("chat.bsky.actor.defs"),
369 defs: {
370 let mut map = BTreeMap::new();
371 map.insert(
372 SmolStr::new_static("profileViewBasic"),
373 LexUserType::Object(LexObject {
374 required: Some(
375 vec![SmolStr::new_static("did"), SmolStr::new_static("handle")],
376 ),
377 properties: {
378 #[allow(unused_mut)]
379 let mut map = BTreeMap::new();
380 map.insert(
381 SmolStr::new_static("associated"),
382 LexObjectProperty::Ref(LexRef {
383 r#ref: CowStr::new_static(
384 "app.bsky.actor.defs#profileAssociated",
385 ),
386 ..Default::default()
387 }),
388 );
389 map.insert(
390 SmolStr::new_static("avatar"),
391 LexObjectProperty::String(LexString {
392 format: Some(LexStringFormat::Uri),
393 ..Default::default()
394 }),
395 );
396 map.insert(
397 SmolStr::new_static("chatDisabled"),
398 LexObjectProperty::Boolean(LexBoolean {
399 ..Default::default()
400 }),
401 );
402 map.insert(
403 SmolStr::new_static("did"),
404 LexObjectProperty::String(LexString {
405 format: Some(LexStringFormat::Did),
406 ..Default::default()
407 }),
408 );
409 map.insert(
410 SmolStr::new_static("displayName"),
411 LexObjectProperty::String(LexString {
412 max_length: Some(640usize),
413 max_graphemes: Some(64usize),
414 ..Default::default()
415 }),
416 );
417 map.insert(
418 SmolStr::new_static("handle"),
419 LexObjectProperty::String(LexString {
420 format: Some(LexStringFormat::Handle),
421 ..Default::default()
422 }),
423 );
424 map.insert(
425 SmolStr::new_static("labels"),
426 LexObjectProperty::Array(LexArray {
427 items: LexArrayItem::Ref(LexRef {
428 r#ref: CowStr::new_static("com.atproto.label.defs#label"),
429 ..Default::default()
430 }),
431 ..Default::default()
432 }),
433 );
434 map.insert(
435 SmolStr::new_static("verification"),
436 LexObjectProperty::Ref(LexRef {
437 r#ref: CowStr::new_static(
438 "app.bsky.actor.defs#verificationState",
439 ),
440 ..Default::default()
441 }),
442 );
443 map.insert(
444 SmolStr::new_static("viewer"),
445 LexObjectProperty::Ref(LexRef {
446 r#ref: CowStr::new_static(
447 "app.bsky.actor.defs#viewerState",
448 ),
449 ..Default::default()
450 }),
451 );
452 map
453 },
454 ..Default::default()
455 }),
456 );
457 map
458 },
459 ..Default::default()
460 }
461}