jacquard_api/com_atproto/moderation/
create_report.rs

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