atproto blogging
at main 1629 lines 60 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: tools.ozone.safelink.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_rule; 9pub mod query_events; 10pub mod query_rules; 11pub mod remove_rule; 12pub mod update_rule; 13 14#[derive(Debug, Clone, PartialEq, Eq, Hash)] 15pub enum ActionType<'a> { 16 Block, 17 Warn, 18 Whitelist, 19 Other(jacquard_common::CowStr<'a>), 20} 21 22impl<'a> ActionType<'a> { 23 pub fn as_str(&self) -> &str { 24 match self { 25 Self::Block => "block", 26 Self::Warn => "warn", 27 Self::Whitelist => "whitelist", 28 Self::Other(s) => s.as_ref(), 29 } 30 } 31} 32 33impl<'a> From<&'a str> for ActionType<'a> { 34 fn from(s: &'a str) -> Self { 35 match s { 36 "block" => Self::Block, 37 "warn" => Self::Warn, 38 "whitelist" => Self::Whitelist, 39 _ => Self::Other(jacquard_common::CowStr::from(s)), 40 } 41 } 42} 43 44impl<'a> From<String> for ActionType<'a> { 45 fn from(s: String) -> Self { 46 match s.as_str() { 47 "block" => Self::Block, 48 "warn" => Self::Warn, 49 "whitelist" => Self::Whitelist, 50 _ => Self::Other(jacquard_common::CowStr::from(s)), 51 } 52 } 53} 54 55impl<'a> AsRef<str> for ActionType<'a> { 56 fn as_ref(&self) -> &str { 57 self.as_str() 58 } 59} 60 61impl<'a> core::fmt::Display for ActionType<'a> { 62 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 63 write!(f, "{}", self.as_str()) 64 } 65} 66 67impl<'a> serde::Serialize for ActionType<'a> { 68 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 69 where 70 S: serde::Serializer, 71 { 72 serializer.serialize_str(self.as_str()) 73 } 74} 75 76impl<'de, 'a> serde::Deserialize<'de> for ActionType<'a> 77where 78 'de: 'a, 79{ 80 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 81 where 82 D: serde::Deserializer<'de>, 83 { 84 let s = <&'de str>::deserialize(deserializer)?; 85 Ok(Self::from(s)) 86 } 87} 88 89impl jacquard_common::IntoStatic for ActionType<'_> { 90 type Output = ActionType<'static>; 91 fn into_static(self) -> Self::Output { 92 match self { 93 ActionType::Block => ActionType::Block, 94 ActionType::Warn => ActionType::Warn, 95 ActionType::Whitelist => ActionType::Whitelist, 96 ActionType::Other(v) => ActionType::Other(v.into_static()), 97 } 98 } 99} 100 101/// An event for URL safety decisions 102#[jacquard_derive::lexicon] 103#[derive( 104 serde::Serialize, 105 serde::Deserialize, 106 Debug, 107 Clone, 108 PartialEq, 109 Eq, 110 jacquard_derive::IntoStatic 111)] 112#[serde(rename_all = "camelCase")] 113pub struct Event<'a> { 114 #[serde(borrow)] 115 pub action: crate::tools_ozone::safelink::ActionType<'a>, 116 /// Optional comment about the decision 117 #[serde(skip_serializing_if = "std::option::Option::is_none")] 118 #[serde(borrow)] 119 pub comment: std::option::Option<jacquard_common::CowStr<'a>>, 120 pub created_at: jacquard_common::types::string::Datetime, 121 /// DID of the user who created this rule 122 #[serde(borrow)] 123 pub created_by: jacquard_common::types::string::Did<'a>, 124 #[serde(borrow)] 125 pub event_type: crate::tools_ozone::safelink::EventType<'a>, 126 /// Auto-incrementing row ID 127 pub id: i64, 128 #[serde(borrow)] 129 pub pattern: crate::tools_ozone::safelink::PatternType<'a>, 130 #[serde(borrow)] 131 pub reason: crate::tools_ozone::safelink::ReasonType<'a>, 132 /// The URL that this rule applies to 133 #[serde(borrow)] 134 pub url: jacquard_common::CowStr<'a>, 135} 136 137pub mod event_state { 138 139 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 140 #[allow(unused)] 141 use ::core::marker::PhantomData; 142 mod sealed { 143 pub trait Sealed {} 144 } 145 /// State trait tracking which required fields have been set 146 pub trait State: sealed::Sealed { 147 type Action; 148 type Id; 149 type Url; 150 type Reason; 151 type Pattern; 152 type CreatedAt; 153 type EventType; 154 type CreatedBy; 155 } 156 /// Empty state - all required fields are unset 157 pub struct Empty(()); 158 impl sealed::Sealed for Empty {} 159 impl State for Empty { 160 type Action = Unset; 161 type Id = Unset; 162 type Url = Unset; 163 type Reason = Unset; 164 type Pattern = Unset; 165 type CreatedAt = Unset; 166 type EventType = Unset; 167 type CreatedBy = Unset; 168 } 169 ///State transition - sets the `action` field to Set 170 pub struct SetAction<S: State = Empty>(PhantomData<fn() -> S>); 171 impl<S: State> sealed::Sealed for SetAction<S> {} 172 impl<S: State> State for SetAction<S> { 173 type Action = Set<members::action>; 174 type Id = S::Id; 175 type Url = S::Url; 176 type Reason = S::Reason; 177 type Pattern = S::Pattern; 178 type CreatedAt = S::CreatedAt; 179 type EventType = S::EventType; 180 type CreatedBy = S::CreatedBy; 181 } 182 ///State transition - sets the `id` field to Set 183 pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>); 184 impl<S: State> sealed::Sealed for SetId<S> {} 185 impl<S: State> State for SetId<S> { 186 type Action = S::Action; 187 type Id = Set<members::id>; 188 type Url = S::Url; 189 type Reason = S::Reason; 190 type Pattern = S::Pattern; 191 type CreatedAt = S::CreatedAt; 192 type EventType = S::EventType; 193 type CreatedBy = S::CreatedBy; 194 } 195 ///State transition - sets the `url` field to Set 196 pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>); 197 impl<S: State> sealed::Sealed for SetUrl<S> {} 198 impl<S: State> State for SetUrl<S> { 199 type Action = S::Action; 200 type Id = S::Id; 201 type Url = Set<members::url>; 202 type Reason = S::Reason; 203 type Pattern = S::Pattern; 204 type CreatedAt = S::CreatedAt; 205 type EventType = S::EventType; 206 type CreatedBy = S::CreatedBy; 207 } 208 ///State transition - sets the `reason` field to Set 209 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>); 210 impl<S: State> sealed::Sealed for SetReason<S> {} 211 impl<S: State> State for SetReason<S> { 212 type Action = S::Action; 213 type Id = S::Id; 214 type Url = S::Url; 215 type Reason = Set<members::reason>; 216 type Pattern = S::Pattern; 217 type CreatedAt = S::CreatedAt; 218 type EventType = S::EventType; 219 type CreatedBy = S::CreatedBy; 220 } 221 ///State transition - sets the `pattern` field to Set 222 pub struct SetPattern<S: State = Empty>(PhantomData<fn() -> S>); 223 impl<S: State> sealed::Sealed for SetPattern<S> {} 224 impl<S: State> State for SetPattern<S> { 225 type Action = S::Action; 226 type Id = S::Id; 227 type Url = S::Url; 228 type Reason = S::Reason; 229 type Pattern = Set<members::pattern>; 230 type CreatedAt = S::CreatedAt; 231 type EventType = S::EventType; 232 type CreatedBy = S::CreatedBy; 233 } 234 ///State transition - sets the `created_at` field to Set 235 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 236 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 237 impl<S: State> State for SetCreatedAt<S> { 238 type Action = S::Action; 239 type Id = S::Id; 240 type Url = S::Url; 241 type Reason = S::Reason; 242 type Pattern = S::Pattern; 243 type CreatedAt = Set<members::created_at>; 244 type EventType = S::EventType; 245 type CreatedBy = S::CreatedBy; 246 } 247 ///State transition - sets the `event_type` field to Set 248 pub struct SetEventType<S: State = Empty>(PhantomData<fn() -> S>); 249 impl<S: State> sealed::Sealed for SetEventType<S> {} 250 impl<S: State> State for SetEventType<S> { 251 type Action = S::Action; 252 type Id = S::Id; 253 type Url = S::Url; 254 type Reason = S::Reason; 255 type Pattern = S::Pattern; 256 type CreatedAt = S::CreatedAt; 257 type EventType = Set<members::event_type>; 258 type CreatedBy = S::CreatedBy; 259 } 260 ///State transition - sets the `created_by` field to Set 261 pub struct SetCreatedBy<S: State = Empty>(PhantomData<fn() -> S>); 262 impl<S: State> sealed::Sealed for SetCreatedBy<S> {} 263 impl<S: State> State for SetCreatedBy<S> { 264 type Action = S::Action; 265 type Id = S::Id; 266 type Url = S::Url; 267 type Reason = S::Reason; 268 type Pattern = S::Pattern; 269 type CreatedAt = S::CreatedAt; 270 type EventType = S::EventType; 271 type CreatedBy = Set<members::created_by>; 272 } 273 /// Marker types for field names 274 #[allow(non_camel_case_types)] 275 pub mod members { 276 ///Marker type for the `action` field 277 pub struct action(()); 278 ///Marker type for the `id` field 279 pub struct id(()); 280 ///Marker type for the `url` field 281 pub struct url(()); 282 ///Marker type for the `reason` field 283 pub struct reason(()); 284 ///Marker type for the `pattern` field 285 pub struct pattern(()); 286 ///Marker type for the `created_at` field 287 pub struct created_at(()); 288 ///Marker type for the `event_type` field 289 pub struct event_type(()); 290 ///Marker type for the `created_by` field 291 pub struct created_by(()); 292 } 293} 294 295/// Builder for constructing an instance of this type 296pub struct EventBuilder<'a, S: event_state::State> { 297 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 298 __unsafe_private_named: ( 299 ::core::option::Option<crate::tools_ozone::safelink::ActionType<'a>>, 300 ::core::option::Option<jacquard_common::CowStr<'a>>, 301 ::core::option::Option<jacquard_common::types::string::Datetime>, 302 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 303 ::core::option::Option<crate::tools_ozone::safelink::EventType<'a>>, 304 ::core::option::Option<i64>, 305 ::core::option::Option<crate::tools_ozone::safelink::PatternType<'a>>, 306 ::core::option::Option<crate::tools_ozone::safelink::ReasonType<'a>>, 307 ::core::option::Option<jacquard_common::CowStr<'a>>, 308 ), 309 _phantom: ::core::marker::PhantomData<&'a ()>, 310} 311 312impl<'a> Event<'a> { 313 /// Create a new builder for this type 314 pub fn new() -> EventBuilder<'a, event_state::Empty> { 315 EventBuilder::new() 316 } 317} 318 319impl<'a> EventBuilder<'a, event_state::Empty> { 320 /// Create a new builder with all fields unset 321 pub fn new() -> Self { 322 EventBuilder { 323 _phantom_state: ::core::marker::PhantomData, 324 __unsafe_private_named: ( 325 None, 326 None, 327 None, 328 None, 329 None, 330 None, 331 None, 332 None, 333 None, 334 ), 335 _phantom: ::core::marker::PhantomData, 336 } 337 } 338} 339 340impl<'a, S> EventBuilder<'a, S> 341where 342 S: event_state::State, 343 S::Action: event_state::IsUnset, 344{ 345 /// Set the `action` field (required) 346 pub fn action( 347 mut self, 348 value: impl Into<crate::tools_ozone::safelink::ActionType<'a>>, 349 ) -> EventBuilder<'a, event_state::SetAction<S>> { 350 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 351 EventBuilder { 352 _phantom_state: ::core::marker::PhantomData, 353 __unsafe_private_named: self.__unsafe_private_named, 354 _phantom: ::core::marker::PhantomData, 355 } 356 } 357} 358 359impl<'a, S: event_state::State> EventBuilder<'a, S> { 360 /// Set the `comment` field (optional) 361 pub fn comment( 362 mut self, 363 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 364 ) -> Self { 365 self.__unsafe_private_named.1 = value.into(); 366 self 367 } 368 /// Set the `comment` field to an Option value (optional) 369 pub fn maybe_comment(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 370 self.__unsafe_private_named.1 = value; 371 self 372 } 373} 374 375impl<'a, S> EventBuilder<'a, S> 376where 377 S: event_state::State, 378 S::CreatedAt: event_state::IsUnset, 379{ 380 /// Set the `createdAt` field (required) 381 pub fn created_at( 382 mut self, 383 value: impl Into<jacquard_common::types::string::Datetime>, 384 ) -> EventBuilder<'a, event_state::SetCreatedAt<S>> { 385 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 386 EventBuilder { 387 _phantom_state: ::core::marker::PhantomData, 388 __unsafe_private_named: self.__unsafe_private_named, 389 _phantom: ::core::marker::PhantomData, 390 } 391 } 392} 393 394impl<'a, S> EventBuilder<'a, S> 395where 396 S: event_state::State, 397 S::CreatedBy: event_state::IsUnset, 398{ 399 /// Set the `createdBy` field (required) 400 pub fn created_by( 401 mut self, 402 value: impl Into<jacquard_common::types::string::Did<'a>>, 403 ) -> EventBuilder<'a, event_state::SetCreatedBy<S>> { 404 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 405 EventBuilder { 406 _phantom_state: ::core::marker::PhantomData, 407 __unsafe_private_named: self.__unsafe_private_named, 408 _phantom: ::core::marker::PhantomData, 409 } 410 } 411} 412 413impl<'a, S> EventBuilder<'a, S> 414where 415 S: event_state::State, 416 S::EventType: event_state::IsUnset, 417{ 418 /// Set the `eventType` field (required) 419 pub fn event_type( 420 mut self, 421 value: impl Into<crate::tools_ozone::safelink::EventType<'a>>, 422 ) -> EventBuilder<'a, event_state::SetEventType<S>> { 423 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 424 EventBuilder { 425 _phantom_state: ::core::marker::PhantomData, 426 __unsafe_private_named: self.__unsafe_private_named, 427 _phantom: ::core::marker::PhantomData, 428 } 429 } 430} 431 432impl<'a, S> EventBuilder<'a, S> 433where 434 S: event_state::State, 435 S::Id: event_state::IsUnset, 436{ 437 /// Set the `id` field (required) 438 pub fn id( 439 mut self, 440 value: impl Into<i64>, 441 ) -> EventBuilder<'a, event_state::SetId<S>> { 442 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); 443 EventBuilder { 444 _phantom_state: ::core::marker::PhantomData, 445 __unsafe_private_named: self.__unsafe_private_named, 446 _phantom: ::core::marker::PhantomData, 447 } 448 } 449} 450 451impl<'a, S> EventBuilder<'a, S> 452where 453 S: event_state::State, 454 S::Pattern: event_state::IsUnset, 455{ 456 /// Set the `pattern` field (required) 457 pub fn pattern( 458 mut self, 459 value: impl Into<crate::tools_ozone::safelink::PatternType<'a>>, 460 ) -> EventBuilder<'a, event_state::SetPattern<S>> { 461 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into()); 462 EventBuilder { 463 _phantom_state: ::core::marker::PhantomData, 464 __unsafe_private_named: self.__unsafe_private_named, 465 _phantom: ::core::marker::PhantomData, 466 } 467 } 468} 469 470impl<'a, S> EventBuilder<'a, S> 471where 472 S: event_state::State, 473 S::Reason: event_state::IsUnset, 474{ 475 /// Set the `reason` field (required) 476 pub fn reason( 477 mut self, 478 value: impl Into<crate::tools_ozone::safelink::ReasonType<'a>>, 479 ) -> EventBuilder<'a, event_state::SetReason<S>> { 480 self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into()); 481 EventBuilder { 482 _phantom_state: ::core::marker::PhantomData, 483 __unsafe_private_named: self.__unsafe_private_named, 484 _phantom: ::core::marker::PhantomData, 485 } 486 } 487} 488 489impl<'a, S> EventBuilder<'a, S> 490where 491 S: event_state::State, 492 S::Url: event_state::IsUnset, 493{ 494 /// Set the `url` field (required) 495 pub fn url( 496 mut self, 497 value: impl Into<jacquard_common::CowStr<'a>>, 498 ) -> EventBuilder<'a, event_state::SetUrl<S>> { 499 self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into()); 500 EventBuilder { 501 _phantom_state: ::core::marker::PhantomData, 502 __unsafe_private_named: self.__unsafe_private_named, 503 _phantom: ::core::marker::PhantomData, 504 } 505 } 506} 507 508impl<'a, S> EventBuilder<'a, S> 509where 510 S: event_state::State, 511 S::Action: event_state::IsSet, 512 S::Id: event_state::IsSet, 513 S::Url: event_state::IsSet, 514 S::Reason: event_state::IsSet, 515 S::Pattern: event_state::IsSet, 516 S::CreatedAt: event_state::IsSet, 517 S::EventType: event_state::IsSet, 518 S::CreatedBy: event_state::IsSet, 519{ 520 /// Build the final struct 521 pub fn build(self) -> Event<'a> { 522 Event { 523 action: self.__unsafe_private_named.0.unwrap(), 524 comment: self.__unsafe_private_named.1, 525 created_at: self.__unsafe_private_named.2.unwrap(), 526 created_by: self.__unsafe_private_named.3.unwrap(), 527 event_type: self.__unsafe_private_named.4.unwrap(), 528 id: self.__unsafe_private_named.5.unwrap(), 529 pattern: self.__unsafe_private_named.6.unwrap(), 530 reason: self.__unsafe_private_named.7.unwrap(), 531 url: self.__unsafe_private_named.8.unwrap(), 532 extra_data: Default::default(), 533 } 534 } 535 /// Build the final struct with custom extra_data 536 pub fn build_with_data( 537 self, 538 extra_data: std::collections::BTreeMap< 539 jacquard_common::smol_str::SmolStr, 540 jacquard_common::types::value::Data<'a>, 541 >, 542 ) -> Event<'a> { 543 Event { 544 action: self.__unsafe_private_named.0.unwrap(), 545 comment: self.__unsafe_private_named.1, 546 created_at: self.__unsafe_private_named.2.unwrap(), 547 created_by: self.__unsafe_private_named.3.unwrap(), 548 event_type: self.__unsafe_private_named.4.unwrap(), 549 id: self.__unsafe_private_named.5.unwrap(), 550 pattern: self.__unsafe_private_named.6.unwrap(), 551 reason: self.__unsafe_private_named.7.unwrap(), 552 url: self.__unsafe_private_named.8.unwrap(), 553 extra_data: Some(extra_data), 554 } 555 } 556} 557 558fn lexicon_doc_tools_ozone_safelink_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 559 'static, 560> { 561 ::jacquard_lexicon::lexicon::LexiconDoc { 562 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 563 id: ::jacquard_common::CowStr::new_static("tools.ozone.safelink.defs"), 564 revision: None, 565 description: None, 566 defs: { 567 let mut map = ::alloc::collections::BTreeMap::new(); 568 map.insert( 569 ::jacquard_common::smol_str::SmolStr::new_static("actionType"), 570 ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { 571 description: None, 572 format: None, 573 default: None, 574 min_length: None, 575 max_length: None, 576 min_graphemes: None, 577 max_graphemes: None, 578 r#enum: None, 579 r#const: None, 580 known_values: None, 581 }), 582 ); 583 map.insert( 584 ::jacquard_common::smol_str::SmolStr::new_static("event"), 585 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 586 description: Some( 587 ::jacquard_common::CowStr::new_static( 588 "An event for URL safety decisions", 589 ), 590 ), 591 required: Some( 592 vec![ 593 ::jacquard_common::smol_str::SmolStr::new_static("id"), 594 ::jacquard_common::smol_str::SmolStr::new_static("eventType"), 595 ::jacquard_common::smol_str::SmolStr::new_static("url"), 596 ::jacquard_common::smol_str::SmolStr::new_static("pattern"), 597 ::jacquard_common::smol_str::SmolStr::new_static("action"), 598 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 599 ::jacquard_common::smol_str::SmolStr::new_static("createdBy"), 600 ::jacquard_common::smol_str::SmolStr::new_static("createdAt") 601 ], 602 ), 603 nullable: None, 604 properties: { 605 #[allow(unused_mut)] 606 let mut map = ::alloc::collections::BTreeMap::new(); 607 map.insert( 608 ::jacquard_common::smol_str::SmolStr::new_static("action"), 609 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 610 description: None, 611 r#ref: ::jacquard_common::CowStr::new_static("#actionType"), 612 }), 613 ); 614 map.insert( 615 ::jacquard_common::smol_str::SmolStr::new_static("comment"), 616 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 617 description: Some( 618 ::jacquard_common::CowStr::new_static( 619 "Optional comment about the decision", 620 ), 621 ), 622 format: None, 623 default: None, 624 min_length: None, 625 max_length: None, 626 min_graphemes: None, 627 max_graphemes: None, 628 r#enum: None, 629 r#const: None, 630 known_values: None, 631 }), 632 ); 633 map.insert( 634 ::jacquard_common::smol_str::SmolStr::new_static( 635 "createdAt", 636 ), 637 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 638 description: None, 639 format: Some( 640 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 641 ), 642 default: None, 643 min_length: None, 644 max_length: None, 645 min_graphemes: None, 646 max_graphemes: None, 647 r#enum: None, 648 r#const: None, 649 known_values: None, 650 }), 651 ); 652 map.insert( 653 ::jacquard_common::smol_str::SmolStr::new_static( 654 "createdBy", 655 ), 656 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 657 description: Some( 658 ::jacquard_common::CowStr::new_static( 659 "DID of the user who created this rule", 660 ), 661 ), 662 format: Some( 663 ::jacquard_lexicon::lexicon::LexStringFormat::Did, 664 ), 665 default: None, 666 min_length: None, 667 max_length: None, 668 min_graphemes: None, 669 max_graphemes: None, 670 r#enum: None, 671 r#const: None, 672 known_values: None, 673 }), 674 ); 675 map.insert( 676 ::jacquard_common::smol_str::SmolStr::new_static( 677 "eventType", 678 ), 679 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 680 description: None, 681 r#ref: ::jacquard_common::CowStr::new_static("#eventType"), 682 }), 683 ); 684 map.insert( 685 ::jacquard_common::smol_str::SmolStr::new_static("id"), 686 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 687 description: None, 688 default: None, 689 minimum: None, 690 maximum: None, 691 r#enum: None, 692 r#const: None, 693 }), 694 ); 695 map.insert( 696 ::jacquard_common::smol_str::SmolStr::new_static("pattern"), 697 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 698 description: None, 699 r#ref: ::jacquard_common::CowStr::new_static("#patternType"), 700 }), 701 ); 702 map.insert( 703 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 704 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 705 description: None, 706 r#ref: ::jacquard_common::CowStr::new_static("#reasonType"), 707 }), 708 ); 709 map.insert( 710 ::jacquard_common::smol_str::SmolStr::new_static("url"), 711 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 712 description: Some( 713 ::jacquard_common::CowStr::new_static( 714 "The URL that this rule applies to", 715 ), 716 ), 717 format: None, 718 default: None, 719 min_length: None, 720 max_length: None, 721 min_graphemes: None, 722 max_graphemes: None, 723 r#enum: None, 724 r#const: None, 725 known_values: None, 726 }), 727 ); 728 map 729 }, 730 }), 731 ); 732 map.insert( 733 ::jacquard_common::smol_str::SmolStr::new_static("eventType"), 734 ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { 735 description: None, 736 format: None, 737 default: None, 738 min_length: None, 739 max_length: None, 740 min_graphemes: None, 741 max_graphemes: None, 742 r#enum: None, 743 r#const: None, 744 known_values: None, 745 }), 746 ); 747 map.insert( 748 ::jacquard_common::smol_str::SmolStr::new_static("patternType"), 749 ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { 750 description: None, 751 format: None, 752 default: None, 753 min_length: None, 754 max_length: None, 755 min_graphemes: None, 756 max_graphemes: None, 757 r#enum: None, 758 r#const: None, 759 known_values: None, 760 }), 761 ); 762 map.insert( 763 ::jacquard_common::smol_str::SmolStr::new_static("reasonType"), 764 ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { 765 description: None, 766 format: None, 767 default: None, 768 min_length: None, 769 max_length: None, 770 min_graphemes: None, 771 max_graphemes: None, 772 r#enum: None, 773 r#const: None, 774 known_values: None, 775 }), 776 ); 777 map.insert( 778 ::jacquard_common::smol_str::SmolStr::new_static("urlRule"), 779 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 780 description: Some( 781 ::jacquard_common::CowStr::new_static( 782 "Input for creating a URL safety rule", 783 ), 784 ), 785 required: Some( 786 vec![ 787 ::jacquard_common::smol_str::SmolStr::new_static("url"), 788 ::jacquard_common::smol_str::SmolStr::new_static("pattern"), 789 ::jacquard_common::smol_str::SmolStr::new_static("action"), 790 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 791 ::jacquard_common::smol_str::SmolStr::new_static("createdBy"), 792 ::jacquard_common::smol_str::SmolStr::new_static("createdAt"), 793 ::jacquard_common::smol_str::SmolStr::new_static("updatedAt") 794 ], 795 ), 796 nullable: None, 797 properties: { 798 #[allow(unused_mut)] 799 let mut map = ::alloc::collections::BTreeMap::new(); 800 map.insert( 801 ::jacquard_common::smol_str::SmolStr::new_static("action"), 802 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 803 description: None, 804 r#ref: ::jacquard_common::CowStr::new_static("#actionType"), 805 }), 806 ); 807 map.insert( 808 ::jacquard_common::smol_str::SmolStr::new_static("comment"), 809 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 810 description: Some( 811 ::jacquard_common::CowStr::new_static( 812 "Optional comment about the decision", 813 ), 814 ), 815 format: None, 816 default: None, 817 min_length: None, 818 max_length: None, 819 min_graphemes: None, 820 max_graphemes: None, 821 r#enum: None, 822 r#const: None, 823 known_values: None, 824 }), 825 ); 826 map.insert( 827 ::jacquard_common::smol_str::SmolStr::new_static( 828 "createdAt", 829 ), 830 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 831 description: Some( 832 ::jacquard_common::CowStr::new_static( 833 "Timestamp when the rule was created", 834 ), 835 ), 836 format: Some( 837 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 838 ), 839 default: None, 840 min_length: None, 841 max_length: None, 842 min_graphemes: None, 843 max_graphemes: None, 844 r#enum: None, 845 r#const: None, 846 known_values: None, 847 }), 848 ); 849 map.insert( 850 ::jacquard_common::smol_str::SmolStr::new_static( 851 "createdBy", 852 ), 853 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 854 description: Some( 855 ::jacquard_common::CowStr::new_static( 856 "DID of the user added the rule.", 857 ), 858 ), 859 format: Some( 860 ::jacquard_lexicon::lexicon::LexStringFormat::Did, 861 ), 862 default: None, 863 min_length: None, 864 max_length: None, 865 min_graphemes: None, 866 max_graphemes: None, 867 r#enum: None, 868 r#const: None, 869 known_values: None, 870 }), 871 ); 872 map.insert( 873 ::jacquard_common::smol_str::SmolStr::new_static("pattern"), 874 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 875 description: None, 876 r#ref: ::jacquard_common::CowStr::new_static("#patternType"), 877 }), 878 ); 879 map.insert( 880 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 881 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 882 description: None, 883 r#ref: ::jacquard_common::CowStr::new_static("#reasonType"), 884 }), 885 ); 886 map.insert( 887 ::jacquard_common::smol_str::SmolStr::new_static( 888 "updatedAt", 889 ), 890 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 891 description: Some( 892 ::jacquard_common::CowStr::new_static( 893 "Timestamp when the rule was last updated", 894 ), 895 ), 896 format: Some( 897 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 898 ), 899 default: None, 900 min_length: None, 901 max_length: None, 902 min_graphemes: None, 903 max_graphemes: None, 904 r#enum: None, 905 r#const: None, 906 known_values: None, 907 }), 908 ); 909 map.insert( 910 ::jacquard_common::smol_str::SmolStr::new_static("url"), 911 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 912 description: Some( 913 ::jacquard_common::CowStr::new_static( 914 "The URL or domain to apply the rule to", 915 ), 916 ), 917 format: None, 918 default: None, 919 min_length: None, 920 max_length: None, 921 min_graphemes: None, 922 max_graphemes: None, 923 r#enum: None, 924 r#const: None, 925 known_values: None, 926 }), 927 ); 928 map 929 }, 930 }), 931 ); 932 map 933 }, 934 } 935} 936 937impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Event<'a> { 938 fn nsid() -> &'static str { 939 "tools.ozone.safelink.defs" 940 } 941 fn def_name() -> &'static str { 942 "event" 943 } 944 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 945 lexicon_doc_tools_ozone_safelink_defs() 946 } 947 fn validate( 948 &self, 949 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 950 Ok(()) 951 } 952} 953 954#[derive(Debug, Clone, PartialEq, Eq, Hash)] 955pub enum EventType<'a> { 956 AddRule, 957 UpdateRule, 958 RemoveRule, 959 Other(jacquard_common::CowStr<'a>), 960} 961 962impl<'a> EventType<'a> { 963 pub fn as_str(&self) -> &str { 964 match self { 965 Self::AddRule => "addRule", 966 Self::UpdateRule => "updateRule", 967 Self::RemoveRule => "removeRule", 968 Self::Other(s) => s.as_ref(), 969 } 970 } 971} 972 973impl<'a> From<&'a str> for EventType<'a> { 974 fn from(s: &'a str) -> Self { 975 match s { 976 "addRule" => Self::AddRule, 977 "updateRule" => Self::UpdateRule, 978 "removeRule" => Self::RemoveRule, 979 _ => Self::Other(jacquard_common::CowStr::from(s)), 980 } 981 } 982} 983 984impl<'a> From<String> for EventType<'a> { 985 fn from(s: String) -> Self { 986 match s.as_str() { 987 "addRule" => Self::AddRule, 988 "updateRule" => Self::UpdateRule, 989 "removeRule" => Self::RemoveRule, 990 _ => Self::Other(jacquard_common::CowStr::from(s)), 991 } 992 } 993} 994 995impl<'a> AsRef<str> for EventType<'a> { 996 fn as_ref(&self) -> &str { 997 self.as_str() 998 } 999} 1000 1001impl<'a> core::fmt::Display for EventType<'a> { 1002 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 1003 write!(f, "{}", self.as_str()) 1004 } 1005} 1006 1007impl<'a> serde::Serialize for EventType<'a> { 1008 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 1009 where 1010 S: serde::Serializer, 1011 { 1012 serializer.serialize_str(self.as_str()) 1013 } 1014} 1015 1016impl<'de, 'a> serde::Deserialize<'de> for EventType<'a> 1017where 1018 'de: 'a, 1019{ 1020 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 1021 where 1022 D: serde::Deserializer<'de>, 1023 { 1024 let s = <&'de str>::deserialize(deserializer)?; 1025 Ok(Self::from(s)) 1026 } 1027} 1028 1029impl jacquard_common::IntoStatic for EventType<'_> { 1030 type Output = EventType<'static>; 1031 fn into_static(self) -> Self::Output { 1032 match self { 1033 EventType::AddRule => EventType::AddRule, 1034 EventType::UpdateRule => EventType::UpdateRule, 1035 EventType::RemoveRule => EventType::RemoveRule, 1036 EventType::Other(v) => EventType::Other(v.into_static()), 1037 } 1038 } 1039} 1040 1041#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1042pub enum PatternType<'a> { 1043 Domain, 1044 Url, 1045 Other(jacquard_common::CowStr<'a>), 1046} 1047 1048impl<'a> PatternType<'a> { 1049 pub fn as_str(&self) -> &str { 1050 match self { 1051 Self::Domain => "domain", 1052 Self::Url => "url", 1053 Self::Other(s) => s.as_ref(), 1054 } 1055 } 1056} 1057 1058impl<'a> From<&'a str> for PatternType<'a> { 1059 fn from(s: &'a str) -> Self { 1060 match s { 1061 "domain" => Self::Domain, 1062 "url" => Self::Url, 1063 _ => Self::Other(jacquard_common::CowStr::from(s)), 1064 } 1065 } 1066} 1067 1068impl<'a> From<String> for PatternType<'a> { 1069 fn from(s: String) -> Self { 1070 match s.as_str() { 1071 "domain" => Self::Domain, 1072 "url" => Self::Url, 1073 _ => Self::Other(jacquard_common::CowStr::from(s)), 1074 } 1075 } 1076} 1077 1078impl<'a> AsRef<str> for PatternType<'a> { 1079 fn as_ref(&self) -> &str { 1080 self.as_str() 1081 } 1082} 1083 1084impl<'a> core::fmt::Display for PatternType<'a> { 1085 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 1086 write!(f, "{}", self.as_str()) 1087 } 1088} 1089 1090impl<'a> serde::Serialize for PatternType<'a> { 1091 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 1092 where 1093 S: serde::Serializer, 1094 { 1095 serializer.serialize_str(self.as_str()) 1096 } 1097} 1098 1099impl<'de, 'a> serde::Deserialize<'de> for PatternType<'a> 1100where 1101 'de: 'a, 1102{ 1103 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 1104 where 1105 D: serde::Deserializer<'de>, 1106 { 1107 let s = <&'de str>::deserialize(deserializer)?; 1108 Ok(Self::from(s)) 1109 } 1110} 1111 1112impl jacquard_common::IntoStatic for PatternType<'_> { 1113 type Output = PatternType<'static>; 1114 fn into_static(self) -> Self::Output { 1115 match self { 1116 PatternType::Domain => PatternType::Domain, 1117 PatternType::Url => PatternType::Url, 1118 PatternType::Other(v) => PatternType::Other(v.into_static()), 1119 } 1120 } 1121} 1122 1123#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1124pub enum ReasonType<'a> { 1125 Csam, 1126 Spam, 1127 Phishing, 1128 None, 1129 Other(jacquard_common::CowStr<'a>), 1130} 1131 1132impl<'a> ReasonType<'a> { 1133 pub fn as_str(&self) -> &str { 1134 match self { 1135 Self::Csam => "csam", 1136 Self::Spam => "spam", 1137 Self::Phishing => "phishing", 1138 Self::None => "none", 1139 Self::Other(s) => s.as_ref(), 1140 } 1141 } 1142} 1143 1144impl<'a> From<&'a str> for ReasonType<'a> { 1145 fn from(s: &'a str) -> Self { 1146 match s { 1147 "csam" => Self::Csam, 1148 "spam" => Self::Spam, 1149 "phishing" => Self::Phishing, 1150 "none" => Self::None, 1151 _ => Self::Other(jacquard_common::CowStr::from(s)), 1152 } 1153 } 1154} 1155 1156impl<'a> From<String> for ReasonType<'a> { 1157 fn from(s: String) -> Self { 1158 match s.as_str() { 1159 "csam" => Self::Csam, 1160 "spam" => Self::Spam, 1161 "phishing" => Self::Phishing, 1162 "none" => Self::None, 1163 _ => Self::Other(jacquard_common::CowStr::from(s)), 1164 } 1165 } 1166} 1167 1168impl<'a> AsRef<str> for ReasonType<'a> { 1169 fn as_ref(&self) -> &str { 1170 self.as_str() 1171 } 1172} 1173 1174impl<'a> core::fmt::Display for ReasonType<'a> { 1175 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 1176 write!(f, "{}", self.as_str()) 1177 } 1178} 1179 1180impl<'a> serde::Serialize for ReasonType<'a> { 1181 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 1182 where 1183 S: serde::Serializer, 1184 { 1185 serializer.serialize_str(self.as_str()) 1186 } 1187} 1188 1189impl<'de, 'a> serde::Deserialize<'de> for ReasonType<'a> 1190where 1191 'de: 'a, 1192{ 1193 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 1194 where 1195 D: serde::Deserializer<'de>, 1196 { 1197 let s = <&'de str>::deserialize(deserializer)?; 1198 Ok(Self::from(s)) 1199 } 1200} 1201 1202impl jacquard_common::IntoStatic for ReasonType<'_> { 1203 type Output = ReasonType<'static>; 1204 fn into_static(self) -> Self::Output { 1205 match self { 1206 ReasonType::Csam => ReasonType::Csam, 1207 ReasonType::Spam => ReasonType::Spam, 1208 ReasonType::Phishing => ReasonType::Phishing, 1209 ReasonType::None => ReasonType::None, 1210 ReasonType::Other(v) => ReasonType::Other(v.into_static()), 1211 } 1212 } 1213} 1214 1215/// Input for creating a URL safety rule 1216#[jacquard_derive::lexicon] 1217#[derive( 1218 serde::Serialize, 1219 serde::Deserialize, 1220 Debug, 1221 Clone, 1222 PartialEq, 1223 Eq, 1224 jacquard_derive::IntoStatic 1225)] 1226#[serde(rename_all = "camelCase")] 1227pub struct UrlRule<'a> { 1228 #[serde(borrow)] 1229 pub action: crate::tools_ozone::safelink::ActionType<'a>, 1230 /// Optional comment about the decision 1231 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1232 #[serde(borrow)] 1233 pub comment: std::option::Option<jacquard_common::CowStr<'a>>, 1234 /// Timestamp when the rule was created 1235 pub created_at: jacquard_common::types::string::Datetime, 1236 /// DID of the user added the rule. 1237 #[serde(borrow)] 1238 pub created_by: jacquard_common::types::string::Did<'a>, 1239 #[serde(borrow)] 1240 pub pattern: crate::tools_ozone::safelink::PatternType<'a>, 1241 #[serde(borrow)] 1242 pub reason: crate::tools_ozone::safelink::ReasonType<'a>, 1243 /// Timestamp when the rule was last updated 1244 pub updated_at: jacquard_common::types::string::Datetime, 1245 /// The URL or domain to apply the rule to 1246 #[serde(borrow)] 1247 pub url: jacquard_common::CowStr<'a>, 1248} 1249 1250pub mod url_rule_state { 1251 1252 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1253 #[allow(unused)] 1254 use ::core::marker::PhantomData; 1255 mod sealed { 1256 pub trait Sealed {} 1257 } 1258 /// State trait tracking which required fields have been set 1259 pub trait State: sealed::Sealed { 1260 type CreatedAt; 1261 type Action; 1262 type Pattern; 1263 type Url; 1264 type Reason; 1265 type CreatedBy; 1266 type UpdatedAt; 1267 } 1268 /// Empty state - all required fields are unset 1269 pub struct Empty(()); 1270 impl sealed::Sealed for Empty {} 1271 impl State for Empty { 1272 type CreatedAt = Unset; 1273 type Action = Unset; 1274 type Pattern = Unset; 1275 type Url = Unset; 1276 type Reason = Unset; 1277 type CreatedBy = Unset; 1278 type UpdatedAt = Unset; 1279 } 1280 ///State transition - sets the `created_at` field to Set 1281 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 1282 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 1283 impl<S: State> State for SetCreatedAt<S> { 1284 type CreatedAt = Set<members::created_at>; 1285 type Action = S::Action; 1286 type Pattern = S::Pattern; 1287 type Url = S::Url; 1288 type Reason = S::Reason; 1289 type CreatedBy = S::CreatedBy; 1290 type UpdatedAt = S::UpdatedAt; 1291 } 1292 ///State transition - sets the `action` field to Set 1293 pub struct SetAction<S: State = Empty>(PhantomData<fn() -> S>); 1294 impl<S: State> sealed::Sealed for SetAction<S> {} 1295 impl<S: State> State for SetAction<S> { 1296 type CreatedAt = S::CreatedAt; 1297 type Action = Set<members::action>; 1298 type Pattern = S::Pattern; 1299 type Url = S::Url; 1300 type Reason = S::Reason; 1301 type CreatedBy = S::CreatedBy; 1302 type UpdatedAt = S::UpdatedAt; 1303 } 1304 ///State transition - sets the `pattern` field to Set 1305 pub struct SetPattern<S: State = Empty>(PhantomData<fn() -> S>); 1306 impl<S: State> sealed::Sealed for SetPattern<S> {} 1307 impl<S: State> State for SetPattern<S> { 1308 type CreatedAt = S::CreatedAt; 1309 type Action = S::Action; 1310 type Pattern = Set<members::pattern>; 1311 type Url = S::Url; 1312 type Reason = S::Reason; 1313 type CreatedBy = S::CreatedBy; 1314 type UpdatedAt = S::UpdatedAt; 1315 } 1316 ///State transition - sets the `url` field to Set 1317 pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>); 1318 impl<S: State> sealed::Sealed for SetUrl<S> {} 1319 impl<S: State> State for SetUrl<S> { 1320 type CreatedAt = S::CreatedAt; 1321 type Action = S::Action; 1322 type Pattern = S::Pattern; 1323 type Url = Set<members::url>; 1324 type Reason = S::Reason; 1325 type CreatedBy = S::CreatedBy; 1326 type UpdatedAt = S::UpdatedAt; 1327 } 1328 ///State transition - sets the `reason` field to Set 1329 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>); 1330 impl<S: State> sealed::Sealed for SetReason<S> {} 1331 impl<S: State> State for SetReason<S> { 1332 type CreatedAt = S::CreatedAt; 1333 type Action = S::Action; 1334 type Pattern = S::Pattern; 1335 type Url = S::Url; 1336 type Reason = Set<members::reason>; 1337 type CreatedBy = S::CreatedBy; 1338 type UpdatedAt = S::UpdatedAt; 1339 } 1340 ///State transition - sets the `created_by` field to Set 1341 pub struct SetCreatedBy<S: State = Empty>(PhantomData<fn() -> S>); 1342 impl<S: State> sealed::Sealed for SetCreatedBy<S> {} 1343 impl<S: State> State for SetCreatedBy<S> { 1344 type CreatedAt = S::CreatedAt; 1345 type Action = S::Action; 1346 type Pattern = S::Pattern; 1347 type Url = S::Url; 1348 type Reason = S::Reason; 1349 type CreatedBy = Set<members::created_by>; 1350 type UpdatedAt = S::UpdatedAt; 1351 } 1352 ///State transition - sets the `updated_at` field to Set 1353 pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>); 1354 impl<S: State> sealed::Sealed for SetUpdatedAt<S> {} 1355 impl<S: State> State for SetUpdatedAt<S> { 1356 type CreatedAt = S::CreatedAt; 1357 type Action = S::Action; 1358 type Pattern = S::Pattern; 1359 type Url = S::Url; 1360 type Reason = S::Reason; 1361 type CreatedBy = S::CreatedBy; 1362 type UpdatedAt = Set<members::updated_at>; 1363 } 1364 /// Marker types for field names 1365 #[allow(non_camel_case_types)] 1366 pub mod members { 1367 ///Marker type for the `created_at` field 1368 pub struct created_at(()); 1369 ///Marker type for the `action` field 1370 pub struct action(()); 1371 ///Marker type for the `pattern` field 1372 pub struct pattern(()); 1373 ///Marker type for the `url` field 1374 pub struct url(()); 1375 ///Marker type for the `reason` field 1376 pub struct reason(()); 1377 ///Marker type for the `created_by` field 1378 pub struct created_by(()); 1379 ///Marker type for the `updated_at` field 1380 pub struct updated_at(()); 1381 } 1382} 1383 1384/// Builder for constructing an instance of this type 1385pub struct UrlRuleBuilder<'a, S: url_rule_state::State> { 1386 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 1387 __unsafe_private_named: ( 1388 ::core::option::Option<crate::tools_ozone::safelink::ActionType<'a>>, 1389 ::core::option::Option<jacquard_common::CowStr<'a>>, 1390 ::core::option::Option<jacquard_common::types::string::Datetime>, 1391 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 1392 ::core::option::Option<crate::tools_ozone::safelink::PatternType<'a>>, 1393 ::core::option::Option<crate::tools_ozone::safelink::ReasonType<'a>>, 1394 ::core::option::Option<jacquard_common::types::string::Datetime>, 1395 ::core::option::Option<jacquard_common::CowStr<'a>>, 1396 ), 1397 _phantom: ::core::marker::PhantomData<&'a ()>, 1398} 1399 1400impl<'a> UrlRule<'a> { 1401 /// Create a new builder for this type 1402 pub fn new() -> UrlRuleBuilder<'a, url_rule_state::Empty> { 1403 UrlRuleBuilder::new() 1404 } 1405} 1406 1407impl<'a> UrlRuleBuilder<'a, url_rule_state::Empty> { 1408 /// Create a new builder with all fields unset 1409 pub fn new() -> Self { 1410 UrlRuleBuilder { 1411 _phantom_state: ::core::marker::PhantomData, 1412 __unsafe_private_named: (None, None, None, None, None, None, None, None), 1413 _phantom: ::core::marker::PhantomData, 1414 } 1415 } 1416} 1417 1418impl<'a, S> UrlRuleBuilder<'a, S> 1419where 1420 S: url_rule_state::State, 1421 S::Action: url_rule_state::IsUnset, 1422{ 1423 /// Set the `action` field (required) 1424 pub fn action( 1425 mut self, 1426 value: impl Into<crate::tools_ozone::safelink::ActionType<'a>>, 1427 ) -> UrlRuleBuilder<'a, url_rule_state::SetAction<S>> { 1428 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 1429 UrlRuleBuilder { 1430 _phantom_state: ::core::marker::PhantomData, 1431 __unsafe_private_named: self.__unsafe_private_named, 1432 _phantom: ::core::marker::PhantomData, 1433 } 1434 } 1435} 1436 1437impl<'a, S: url_rule_state::State> UrlRuleBuilder<'a, S> { 1438 /// Set the `comment` field (optional) 1439 pub fn comment( 1440 mut self, 1441 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 1442 ) -> Self { 1443 self.__unsafe_private_named.1 = value.into(); 1444 self 1445 } 1446 /// Set the `comment` field to an Option value (optional) 1447 pub fn maybe_comment(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 1448 self.__unsafe_private_named.1 = value; 1449 self 1450 } 1451} 1452 1453impl<'a, S> UrlRuleBuilder<'a, S> 1454where 1455 S: url_rule_state::State, 1456 S::CreatedAt: url_rule_state::IsUnset, 1457{ 1458 /// Set the `createdAt` field (required) 1459 pub fn created_at( 1460 mut self, 1461 value: impl Into<jacquard_common::types::string::Datetime>, 1462 ) -> UrlRuleBuilder<'a, url_rule_state::SetCreatedAt<S>> { 1463 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 1464 UrlRuleBuilder { 1465 _phantom_state: ::core::marker::PhantomData, 1466 __unsafe_private_named: self.__unsafe_private_named, 1467 _phantom: ::core::marker::PhantomData, 1468 } 1469 } 1470} 1471 1472impl<'a, S> UrlRuleBuilder<'a, S> 1473where 1474 S: url_rule_state::State, 1475 S::CreatedBy: url_rule_state::IsUnset, 1476{ 1477 /// Set the `createdBy` field (required) 1478 pub fn created_by( 1479 mut self, 1480 value: impl Into<jacquard_common::types::string::Did<'a>>, 1481 ) -> UrlRuleBuilder<'a, url_rule_state::SetCreatedBy<S>> { 1482 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 1483 UrlRuleBuilder { 1484 _phantom_state: ::core::marker::PhantomData, 1485 __unsafe_private_named: self.__unsafe_private_named, 1486 _phantom: ::core::marker::PhantomData, 1487 } 1488 } 1489} 1490 1491impl<'a, S> UrlRuleBuilder<'a, S> 1492where 1493 S: url_rule_state::State, 1494 S::Pattern: url_rule_state::IsUnset, 1495{ 1496 /// Set the `pattern` field (required) 1497 pub fn pattern( 1498 mut self, 1499 value: impl Into<crate::tools_ozone::safelink::PatternType<'a>>, 1500 ) -> UrlRuleBuilder<'a, url_rule_state::SetPattern<S>> { 1501 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 1502 UrlRuleBuilder { 1503 _phantom_state: ::core::marker::PhantomData, 1504 __unsafe_private_named: self.__unsafe_private_named, 1505 _phantom: ::core::marker::PhantomData, 1506 } 1507 } 1508} 1509 1510impl<'a, S> UrlRuleBuilder<'a, S> 1511where 1512 S: url_rule_state::State, 1513 S::Reason: url_rule_state::IsUnset, 1514{ 1515 /// Set the `reason` field (required) 1516 pub fn reason( 1517 mut self, 1518 value: impl Into<crate::tools_ozone::safelink::ReasonType<'a>>, 1519 ) -> UrlRuleBuilder<'a, url_rule_state::SetReason<S>> { 1520 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); 1521 UrlRuleBuilder { 1522 _phantom_state: ::core::marker::PhantomData, 1523 __unsafe_private_named: self.__unsafe_private_named, 1524 _phantom: ::core::marker::PhantomData, 1525 } 1526 } 1527} 1528 1529impl<'a, S> UrlRuleBuilder<'a, S> 1530where 1531 S: url_rule_state::State, 1532 S::UpdatedAt: url_rule_state::IsUnset, 1533{ 1534 /// Set the `updatedAt` field (required) 1535 pub fn updated_at( 1536 mut self, 1537 value: impl Into<jacquard_common::types::string::Datetime>, 1538 ) -> UrlRuleBuilder<'a, url_rule_state::SetUpdatedAt<S>> { 1539 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into()); 1540 UrlRuleBuilder { 1541 _phantom_state: ::core::marker::PhantomData, 1542 __unsafe_private_named: self.__unsafe_private_named, 1543 _phantom: ::core::marker::PhantomData, 1544 } 1545 } 1546} 1547 1548impl<'a, S> UrlRuleBuilder<'a, S> 1549where 1550 S: url_rule_state::State, 1551 S::Url: url_rule_state::IsUnset, 1552{ 1553 /// Set the `url` field (required) 1554 pub fn url( 1555 mut self, 1556 value: impl Into<jacquard_common::CowStr<'a>>, 1557 ) -> UrlRuleBuilder<'a, url_rule_state::SetUrl<S>> { 1558 self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into()); 1559 UrlRuleBuilder { 1560 _phantom_state: ::core::marker::PhantomData, 1561 __unsafe_private_named: self.__unsafe_private_named, 1562 _phantom: ::core::marker::PhantomData, 1563 } 1564 } 1565} 1566 1567impl<'a, S> UrlRuleBuilder<'a, S> 1568where 1569 S: url_rule_state::State, 1570 S::CreatedAt: url_rule_state::IsSet, 1571 S::Action: url_rule_state::IsSet, 1572 S::Pattern: url_rule_state::IsSet, 1573 S::Url: url_rule_state::IsSet, 1574 S::Reason: url_rule_state::IsSet, 1575 S::CreatedBy: url_rule_state::IsSet, 1576 S::UpdatedAt: url_rule_state::IsSet, 1577{ 1578 /// Build the final struct 1579 pub fn build(self) -> UrlRule<'a> { 1580 UrlRule { 1581 action: self.__unsafe_private_named.0.unwrap(), 1582 comment: self.__unsafe_private_named.1, 1583 created_at: self.__unsafe_private_named.2.unwrap(), 1584 created_by: self.__unsafe_private_named.3.unwrap(), 1585 pattern: self.__unsafe_private_named.4.unwrap(), 1586 reason: self.__unsafe_private_named.5.unwrap(), 1587 updated_at: self.__unsafe_private_named.6.unwrap(), 1588 url: self.__unsafe_private_named.7.unwrap(), 1589 extra_data: Default::default(), 1590 } 1591 } 1592 /// Build the final struct with custom extra_data 1593 pub fn build_with_data( 1594 self, 1595 extra_data: std::collections::BTreeMap< 1596 jacquard_common::smol_str::SmolStr, 1597 jacquard_common::types::value::Data<'a>, 1598 >, 1599 ) -> UrlRule<'a> { 1600 UrlRule { 1601 action: self.__unsafe_private_named.0.unwrap(), 1602 comment: self.__unsafe_private_named.1, 1603 created_at: self.__unsafe_private_named.2.unwrap(), 1604 created_by: self.__unsafe_private_named.3.unwrap(), 1605 pattern: self.__unsafe_private_named.4.unwrap(), 1606 reason: self.__unsafe_private_named.5.unwrap(), 1607 updated_at: self.__unsafe_private_named.6.unwrap(), 1608 url: self.__unsafe_private_named.7.unwrap(), 1609 extra_data: Some(extra_data), 1610 } 1611 } 1612} 1613 1614impl<'a> ::jacquard_lexicon::schema::LexiconSchema for UrlRule<'a> { 1615 fn nsid() -> &'static str { 1616 "tools.ozone.safelink.defs" 1617 } 1618 fn def_name() -> &'static str { 1619 "urlRule" 1620 } 1621 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1622 lexicon_doc_tools_ozone_safelink_defs() 1623 } 1624 fn validate( 1625 &self, 1626 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1627 Ok(()) 1628 } 1629}