atproto blogging
at main 491 lines 19 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.moderation.createReport 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 jacquard_derive::IntoStatic 17)] 18#[serde(rename_all = "camelCase")] 19pub struct CreateReport<'a> { 20 #[serde(skip_serializing_if = "std::option::Option::is_none")] 21 #[serde(borrow)] 22 pub mod_tool: std::option::Option< 23 crate::com_atproto::moderation::create_report::ModTool<'a>, 24 >, 25 /// Additional context about the content and violation. 26 #[serde(skip_serializing_if = "std::option::Option::is_none")] 27 #[serde(borrow)] 28 pub reason: std::option::Option<jacquard_common::CowStr<'a>>, 29 /// Indicates the broad category of violation the report is for. 30 #[serde(borrow)] 31 pub reason_type: crate::com_atproto::moderation::ReasonType<'a>, 32 #[serde(borrow)] 33 pub subject: CreateReportSubject<'a>, 34} 35 36pub mod create_report_state { 37 38 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 39 #[allow(unused)] 40 use ::core::marker::PhantomData; 41 mod sealed { 42 pub trait Sealed {} 43 } 44 /// State trait tracking which required fields have been set 45 pub trait State: sealed::Sealed { 46 type ReasonType; 47 type Subject; 48 } 49 /// Empty state - all required fields are unset 50 pub struct Empty(()); 51 impl sealed::Sealed for Empty {} 52 impl State for Empty { 53 type ReasonType = Unset; 54 type Subject = Unset; 55 } 56 ///State transition - sets the `reason_type` field to Set 57 pub struct SetReasonType<S: State = Empty>(PhantomData<fn() -> S>); 58 impl<S: State> sealed::Sealed for SetReasonType<S> {} 59 impl<S: State> State for SetReasonType<S> { 60 type ReasonType = Set<members::reason_type>; 61 type Subject = S::Subject; 62 } 63 ///State transition - sets the `subject` field to Set 64 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>); 65 impl<S: State> sealed::Sealed for SetSubject<S> {} 66 impl<S: State> State for SetSubject<S> { 67 type ReasonType = S::ReasonType; 68 type Subject = Set<members::subject>; 69 } 70 /// Marker types for field names 71 #[allow(non_camel_case_types)] 72 pub mod members { 73 ///Marker type for the `reason_type` field 74 pub struct reason_type(()); 75 ///Marker type for the `subject` field 76 pub struct subject(()); 77 } 78} 79 80/// Builder for constructing an instance of this type 81pub struct CreateReportBuilder<'a, S: create_report_state::State> { 82 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 83 __unsafe_private_named: ( 84 ::core::option::Option< 85 crate::com_atproto::moderation::create_report::ModTool<'a>, 86 >, 87 ::core::option::Option<jacquard_common::CowStr<'a>>, 88 ::core::option::Option<crate::com_atproto::moderation::ReasonType<'a>>, 89 ::core::option::Option<CreateReportSubject<'a>>, 90 ), 91 _phantom: ::core::marker::PhantomData<&'a ()>, 92} 93 94impl<'a> CreateReport<'a> { 95 /// Create a new builder for this type 96 pub fn new() -> CreateReportBuilder<'a, create_report_state::Empty> { 97 CreateReportBuilder::new() 98 } 99} 100 101impl<'a> CreateReportBuilder<'a, create_report_state::Empty> { 102 /// Create a new builder with all fields unset 103 pub fn new() -> Self { 104 CreateReportBuilder { 105 _phantom_state: ::core::marker::PhantomData, 106 __unsafe_private_named: (None, None, None, None), 107 _phantom: ::core::marker::PhantomData, 108 } 109 } 110} 111 112impl<'a, S: create_report_state::State> CreateReportBuilder<'a, S> { 113 /// Set the `modTool` field (optional) 114 pub fn mod_tool( 115 mut self, 116 value: impl Into< 117 Option<crate::com_atproto::moderation::create_report::ModTool<'a>>, 118 >, 119 ) -> Self { 120 self.__unsafe_private_named.0 = value.into(); 121 self 122 } 123 /// Set the `modTool` field to an Option value (optional) 124 pub fn maybe_mod_tool( 125 mut self, 126 value: Option<crate::com_atproto::moderation::create_report::ModTool<'a>>, 127 ) -> Self { 128 self.__unsafe_private_named.0 = value; 129 self 130 } 131} 132 133impl<'a, S: create_report_state::State> CreateReportBuilder<'a, S> { 134 /// Set the `reason` field (optional) 135 pub fn reason( 136 mut self, 137 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 138 ) -> Self { 139 self.__unsafe_private_named.1 = value.into(); 140 self 141 } 142 /// Set the `reason` field to an Option value (optional) 143 pub fn maybe_reason(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 144 self.__unsafe_private_named.1 = value; 145 self 146 } 147} 148 149impl<'a, S> CreateReportBuilder<'a, S> 150where 151 S: create_report_state::State, 152 S::ReasonType: create_report_state::IsUnset, 153{ 154 /// Set the `reasonType` field (required) 155 pub fn reason_type( 156 mut self, 157 value: impl Into<crate::com_atproto::moderation::ReasonType<'a>>, 158 ) -> CreateReportBuilder<'a, create_report_state::SetReasonType<S>> { 159 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 160 CreateReportBuilder { 161 _phantom_state: ::core::marker::PhantomData, 162 __unsafe_private_named: self.__unsafe_private_named, 163 _phantom: ::core::marker::PhantomData, 164 } 165 } 166} 167 168impl<'a, S> CreateReportBuilder<'a, S> 169where 170 S: create_report_state::State, 171 S::Subject: create_report_state::IsUnset, 172{ 173 /// Set the `subject` field (required) 174 pub fn subject( 175 mut self, 176 value: impl Into<CreateReportSubject<'a>>, 177 ) -> CreateReportBuilder<'a, create_report_state::SetSubject<S>> { 178 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 179 CreateReportBuilder { 180 _phantom_state: ::core::marker::PhantomData, 181 __unsafe_private_named: self.__unsafe_private_named, 182 _phantom: ::core::marker::PhantomData, 183 } 184 } 185} 186 187impl<'a, S> CreateReportBuilder<'a, S> 188where 189 S: create_report_state::State, 190 S::ReasonType: create_report_state::IsSet, 191 S::Subject: create_report_state::IsSet, 192{ 193 /// Build the final struct 194 pub fn build(self) -> CreateReport<'a> { 195 CreateReport { 196 mod_tool: self.__unsafe_private_named.0, 197 reason: self.__unsafe_private_named.1, 198 reason_type: self.__unsafe_private_named.2.unwrap(), 199 subject: self.__unsafe_private_named.3.unwrap(), 200 extra_data: Default::default(), 201 } 202 } 203 /// Build the final struct with custom extra_data 204 pub fn build_with_data( 205 self, 206 extra_data: std::collections::BTreeMap< 207 jacquard_common::smol_str::SmolStr, 208 jacquard_common::types::value::Data<'a>, 209 >, 210 ) -> CreateReport<'a> { 211 CreateReport { 212 mod_tool: self.__unsafe_private_named.0, 213 reason: self.__unsafe_private_named.1, 214 reason_type: self.__unsafe_private_named.2.unwrap(), 215 subject: self.__unsafe_private_named.3.unwrap(), 216 extra_data: Some(extra_data), 217 } 218 } 219} 220 221#[jacquard_derive::open_union] 222#[derive( 223 serde::Serialize, 224 serde::Deserialize, 225 Debug, 226 Clone, 227 PartialEq, 228 Eq, 229 jacquard_derive::IntoStatic 230)] 231#[serde(tag = "$type")] 232#[serde(bound(deserialize = "'de: 'a"))] 233pub enum CreateReportSubject<'a> { 234 #[serde(rename = "com.atproto.admin.defs#repoRef")] 235 RepoRef(Box<crate::com_atproto::admin::RepoRef<'a>>), 236 #[serde(rename = "com.atproto.repo.strongRef")] 237 StrongRef(Box<crate::com_atproto::repo::strong_ref::StrongRef<'a>>), 238} 239 240#[jacquard_derive::lexicon] 241#[derive( 242 serde::Serialize, 243 serde::Deserialize, 244 Debug, 245 Clone, 246 PartialEq, 247 Eq, 248 jacquard_derive::IntoStatic 249)] 250#[serde(rename_all = "camelCase")] 251pub struct CreateReportOutput<'a> { 252 pub created_at: jacquard_common::types::string::Datetime, 253 pub id: i64, 254 #[serde(skip_serializing_if = "std::option::Option::is_none")] 255 #[serde(borrow)] 256 pub reason: std::option::Option<jacquard_common::CowStr<'a>>, 257 #[serde(borrow)] 258 pub reason_type: crate::com_atproto::moderation::ReasonType<'a>, 259 #[serde(borrow)] 260 pub reported_by: jacquard_common::types::string::Did<'a>, 261 #[serde(borrow)] 262 pub subject: CreateReportOutputSubject<'a>, 263} 264 265#[jacquard_derive::open_union] 266#[derive( 267 serde::Serialize, 268 serde::Deserialize, 269 Debug, 270 Clone, 271 PartialEq, 272 Eq, 273 jacquard_derive::IntoStatic 274)] 275#[serde(tag = "$type")] 276#[serde(bound(deserialize = "'de: 'a"))] 277pub enum CreateReportOutputSubject<'a> { 278 #[serde(rename = "com.atproto.admin.defs#repoRef")] 279 RepoRef(Box<crate::com_atproto::admin::RepoRef<'a>>), 280 #[serde(rename = "com.atproto.repo.strongRef")] 281 StrongRef(Box<crate::com_atproto::repo::strong_ref::StrongRef<'a>>), 282} 283 284/// Response type for 285///com.atproto.moderation.createReport 286pub struct CreateReportResponse; 287impl jacquard_common::xrpc::XrpcResp for CreateReportResponse { 288 const NSID: &'static str = "com.atproto.moderation.createReport"; 289 const ENCODING: &'static str = "application/json"; 290 type Output<'de> = CreateReportOutput<'de>; 291 type Err<'de> = jacquard_common::xrpc::GenericError<'de>; 292} 293 294impl<'a> jacquard_common::xrpc::XrpcRequest for CreateReport<'a> { 295 const NSID: &'static str = "com.atproto.moderation.createReport"; 296 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 297 "application/json", 298 ); 299 type Response = CreateReportResponse; 300} 301 302/// Endpoint type for 303///com.atproto.moderation.createReport 304pub struct CreateReportRequest; 305impl jacquard_common::xrpc::XrpcEndpoint for CreateReportRequest { 306 const PATH: &'static str = "/xrpc/com.atproto.moderation.createReport"; 307 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 308 "application/json", 309 ); 310 type Request<'de> = CreateReport<'de>; 311 type Response = CreateReportResponse; 312} 313 314/// Moderation tool information for tracing the source of the action 315#[jacquard_derive::lexicon] 316#[derive( 317 serde::Serialize, 318 serde::Deserialize, 319 Debug, 320 Clone, 321 PartialEq, 322 Eq, 323 jacquard_derive::IntoStatic, 324 Default 325)] 326#[serde(rename_all = "camelCase")] 327pub struct ModTool<'a> { 328 /// Additional arbitrary metadata about the source 329 #[serde(skip_serializing_if = "std::option::Option::is_none")] 330 #[serde(borrow)] 331 pub meta: std::option::Option<jacquard_common::types::value::Data<'a>>, 332 /// Name/identifier of the source (e.g., 'bsky-app/android', 'bsky-web/chrome') 333 #[serde(borrow)] 334 pub name: jacquard_common::CowStr<'a>, 335} 336 337fn lexicon_doc_com_atproto_moderation_createReport() -> ::jacquard_lexicon::lexicon::LexiconDoc< 338 'static, 339> { 340 ::jacquard_lexicon::lexicon::LexiconDoc { 341 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 342 id: ::jacquard_common::CowStr::new_static("com.atproto.moderation.createReport"), 343 revision: None, 344 description: None, 345 defs: { 346 let mut map = ::alloc::collections::BTreeMap::new(); 347 map.insert( 348 ::jacquard_common::smol_str::SmolStr::new_static("main"), 349 ::jacquard_lexicon::lexicon::LexUserType::XrpcProcedure(::jacquard_lexicon::lexicon::LexXrpcProcedure { 350 description: None, 351 parameters: None, 352 input: Some(::jacquard_lexicon::lexicon::LexXrpcBody { 353 description: None, 354 encoding: ::jacquard_common::CowStr::new_static( 355 "application/json", 356 ), 357 schema: Some( 358 ::jacquard_lexicon::lexicon::LexXrpcBodySchema::Object(::jacquard_lexicon::lexicon::LexObject { 359 description: None, 360 required: Some( 361 vec![ 362 ::jacquard_common::smol_str::SmolStr::new_static("reasonType"), 363 ::jacquard_common::smol_str::SmolStr::new_static("subject") 364 ], 365 ), 366 nullable: None, 367 properties: { 368 #[allow(unused_mut)] 369 let mut map = ::alloc::collections::BTreeMap::new(); 370 map.insert( 371 ::jacquard_common::smol_str::SmolStr::new_static("modTool"), 372 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 373 description: None, 374 r#ref: ::jacquard_common::CowStr::new_static("#modTool"), 375 }), 376 ); 377 map.insert( 378 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 379 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 380 description: Some( 381 ::jacquard_common::CowStr::new_static( 382 "Additional context about the content and violation.", 383 ), 384 ), 385 format: None, 386 default: None, 387 min_length: None, 388 max_length: Some(20000usize), 389 min_graphemes: None, 390 max_graphemes: Some(2000usize), 391 r#enum: None, 392 r#const: None, 393 known_values: None, 394 }), 395 ); 396 map.insert( 397 ::jacquard_common::smol_str::SmolStr::new_static( 398 "reasonType", 399 ), 400 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 401 description: None, 402 r#ref: ::jacquard_common::CowStr::new_static( 403 "com.atproto.moderation.defs#reasonType", 404 ), 405 }), 406 ); 407 map.insert( 408 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 409 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 410 description: None, 411 refs: vec![ 412 ::jacquard_common::CowStr::new_static("com.atproto.admin.defs#repoRef"), 413 ::jacquard_common::CowStr::new_static("com.atproto.repo.strongRef") 414 ], 415 closed: None, 416 }), 417 ); 418 map 419 }, 420 }), 421 ), 422 }), 423 output: None, 424 errors: None, 425 }), 426 ); 427 map.insert( 428 ::jacquard_common::smol_str::SmolStr::new_static("modTool"), 429 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 430 description: Some( 431 ::jacquard_common::CowStr::new_static( 432 "Moderation tool information for tracing the source of the action", 433 ), 434 ), 435 required: Some( 436 vec![::jacquard_common::smol_str::SmolStr::new_static("name")], 437 ), 438 nullable: None, 439 properties: { 440 #[allow(unused_mut)] 441 let mut map = ::alloc::collections::BTreeMap::new(); 442 map.insert( 443 ::jacquard_common::smol_str::SmolStr::new_static("meta"), 444 ::jacquard_lexicon::lexicon::LexObjectProperty::Unknown(::jacquard_lexicon::lexicon::LexUnknown { 445 description: None, 446 }), 447 ); 448 map.insert( 449 ::jacquard_common::smol_str::SmolStr::new_static("name"), 450 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 451 description: Some( 452 ::jacquard_common::CowStr::new_static( 453 "Name/identifier of the source (e.g., 'bsky-app/android', 'bsky-web/chrome')", 454 ), 455 ), 456 format: None, 457 default: None, 458 min_length: None, 459 max_length: None, 460 min_graphemes: None, 461 max_graphemes: None, 462 r#enum: None, 463 r#const: None, 464 known_values: None, 465 }), 466 ); 467 map 468 }, 469 }), 470 ); 471 map 472 }, 473 } 474} 475 476impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ModTool<'a> { 477 fn nsid() -> &'static str { 478 "com.atproto.moderation.createReport" 479 } 480 fn def_name() -> &'static str { 481 "modTool" 482 } 483 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 484 lexicon_doc_com_atproto_moderation_createReport() 485 } 486 fn validate( 487 &self, 488 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 489 Ok(()) 490 } 491}