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