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