atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.labeler.service
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// A declaration of the existence of labeler service.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Service<'a> {
21 pub created_at: jacquard_common::types::string::Datetime,
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 #[serde(borrow)]
24 pub labels: std::option::Option<crate::com_atproto::label::SelfLabels<'a>>,
25 #[serde(borrow)]
26 pub policies: crate::app_bsky::labeler::LabelerPolicies<'a>,
27 /// The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.
28 #[serde(skip_serializing_if = "std::option::Option::is_none")]
29 #[serde(borrow)]
30 pub reason_types: std::option::Option<
31 Vec<crate::com_atproto::moderation::ReasonType<'a>>,
32 >,
33 /// Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.
34 #[serde(skip_serializing_if = "std::option::Option::is_none")]
35 #[serde(borrow)]
36 pub subject_collections: std::option::Option<
37 Vec<jacquard_common::types::string::Nsid<'a>>,
38 >,
39 /// The set of subject types (account, record, etc) this service accepts reports on.
40 #[serde(skip_serializing_if = "std::option::Option::is_none")]
41 #[serde(borrow)]
42 pub subject_types: std::option::Option<
43 Vec<crate::com_atproto::moderation::SubjectType<'a>>,
44 >,
45}
46
47pub mod service_state {
48
49 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
50 #[allow(unused)]
51 use ::core::marker::PhantomData;
52 mod sealed {
53 pub trait Sealed {}
54 }
55 /// State trait tracking which required fields have been set
56 pub trait State: sealed::Sealed {
57 type CreatedAt;
58 type Policies;
59 }
60 /// Empty state - all required fields are unset
61 pub struct Empty(());
62 impl sealed::Sealed for Empty {}
63 impl State for Empty {
64 type CreatedAt = Unset;
65 type Policies = Unset;
66 }
67 ///State transition - sets the `created_at` field to Set
68 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
69 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
70 impl<S: State> State for SetCreatedAt<S> {
71 type CreatedAt = Set<members::created_at>;
72 type Policies = S::Policies;
73 }
74 ///State transition - sets the `policies` field to Set
75 pub struct SetPolicies<S: State = Empty>(PhantomData<fn() -> S>);
76 impl<S: State> sealed::Sealed for SetPolicies<S> {}
77 impl<S: State> State for SetPolicies<S> {
78 type CreatedAt = S::CreatedAt;
79 type Policies = Set<members::policies>;
80 }
81 /// Marker types for field names
82 #[allow(non_camel_case_types)]
83 pub mod members {
84 ///Marker type for the `created_at` field
85 pub struct created_at(());
86 ///Marker type for the `policies` field
87 pub struct policies(());
88 }
89}
90
91/// Builder for constructing an instance of this type
92pub struct ServiceBuilder<'a, S: service_state::State> {
93 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
94 __unsafe_private_named: (
95 ::core::option::Option<jacquard_common::types::string::Datetime>,
96 ::core::option::Option<crate::com_atproto::label::SelfLabels<'a>>,
97 ::core::option::Option<crate::app_bsky::labeler::LabelerPolicies<'a>>,
98 ::core::option::Option<Vec<crate::com_atproto::moderation::ReasonType<'a>>>,
99 ::core::option::Option<Vec<jacquard_common::types::string::Nsid<'a>>>,
100 ::core::option::Option<Vec<crate::com_atproto::moderation::SubjectType<'a>>>,
101 ),
102 _phantom: ::core::marker::PhantomData<&'a ()>,
103}
104
105impl<'a> Service<'a> {
106 /// Create a new builder for this type
107 pub fn new() -> ServiceBuilder<'a, service_state::Empty> {
108 ServiceBuilder::new()
109 }
110}
111
112impl<'a> ServiceBuilder<'a, service_state::Empty> {
113 /// Create a new builder with all fields unset
114 pub fn new() -> Self {
115 ServiceBuilder {
116 _phantom_state: ::core::marker::PhantomData,
117 __unsafe_private_named: (None, None, None, None, None, None),
118 _phantom: ::core::marker::PhantomData,
119 }
120 }
121}
122
123impl<'a, S> ServiceBuilder<'a, S>
124where
125 S: service_state::State,
126 S::CreatedAt: service_state::IsUnset,
127{
128 /// Set the `createdAt` field (required)
129 pub fn created_at(
130 mut self,
131 value: impl Into<jacquard_common::types::string::Datetime>,
132 ) -> ServiceBuilder<'a, service_state::SetCreatedAt<S>> {
133 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
134 ServiceBuilder {
135 _phantom_state: ::core::marker::PhantomData,
136 __unsafe_private_named: self.__unsafe_private_named,
137 _phantom: ::core::marker::PhantomData,
138 }
139 }
140}
141
142impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
143 /// Set the `labels` field (optional)
144 pub fn labels(
145 mut self,
146 value: impl Into<Option<crate::com_atproto::label::SelfLabels<'a>>>,
147 ) -> Self {
148 self.__unsafe_private_named.1 = value.into();
149 self
150 }
151 /// Set the `labels` field to an Option value (optional)
152 pub fn maybe_labels(
153 mut self,
154 value: Option<crate::com_atproto::label::SelfLabels<'a>>,
155 ) -> Self {
156 self.__unsafe_private_named.1 = value;
157 self
158 }
159}
160
161impl<'a, S> ServiceBuilder<'a, S>
162where
163 S: service_state::State,
164 S::Policies: service_state::IsUnset,
165{
166 /// Set the `policies` field (required)
167 pub fn policies(
168 mut self,
169 value: impl Into<crate::app_bsky::labeler::LabelerPolicies<'a>>,
170 ) -> ServiceBuilder<'a, service_state::SetPolicies<S>> {
171 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
172 ServiceBuilder {
173 _phantom_state: ::core::marker::PhantomData,
174 __unsafe_private_named: self.__unsafe_private_named,
175 _phantom: ::core::marker::PhantomData,
176 }
177 }
178}
179
180impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
181 /// Set the `reasonTypes` field (optional)
182 pub fn reason_types(
183 mut self,
184 value: impl Into<Option<Vec<crate::com_atproto::moderation::ReasonType<'a>>>>,
185 ) -> Self {
186 self.__unsafe_private_named.3 = value.into();
187 self
188 }
189 /// Set the `reasonTypes` field to an Option value (optional)
190 pub fn maybe_reason_types(
191 mut self,
192 value: Option<Vec<crate::com_atproto::moderation::ReasonType<'a>>>,
193 ) -> Self {
194 self.__unsafe_private_named.3 = value;
195 self
196 }
197}
198
199impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
200 /// Set the `subjectCollections` field (optional)
201 pub fn subject_collections(
202 mut self,
203 value: impl Into<Option<Vec<jacquard_common::types::string::Nsid<'a>>>>,
204 ) -> Self {
205 self.__unsafe_private_named.4 = value.into();
206 self
207 }
208 /// Set the `subjectCollections` field to an Option value (optional)
209 pub fn maybe_subject_collections(
210 mut self,
211 value: Option<Vec<jacquard_common::types::string::Nsid<'a>>>,
212 ) -> Self {
213 self.__unsafe_private_named.4 = value;
214 self
215 }
216}
217
218impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
219 /// Set the `subjectTypes` field (optional)
220 pub fn subject_types(
221 mut self,
222 value: impl Into<Option<Vec<crate::com_atproto::moderation::SubjectType<'a>>>>,
223 ) -> Self {
224 self.__unsafe_private_named.5 = value.into();
225 self
226 }
227 /// Set the `subjectTypes` field to an Option value (optional)
228 pub fn maybe_subject_types(
229 mut self,
230 value: Option<Vec<crate::com_atproto::moderation::SubjectType<'a>>>,
231 ) -> Self {
232 self.__unsafe_private_named.5 = value;
233 self
234 }
235}
236
237impl<'a, S> ServiceBuilder<'a, S>
238where
239 S: service_state::State,
240 S::CreatedAt: service_state::IsSet,
241 S::Policies: service_state::IsSet,
242{
243 /// Build the final struct
244 pub fn build(self) -> Service<'a> {
245 Service {
246 created_at: self.__unsafe_private_named.0.unwrap(),
247 labels: self.__unsafe_private_named.1,
248 policies: self.__unsafe_private_named.2.unwrap(),
249 reason_types: self.__unsafe_private_named.3,
250 subject_collections: self.__unsafe_private_named.4,
251 subject_types: self.__unsafe_private_named.5,
252 extra_data: Default::default(),
253 }
254 }
255 /// Build the final struct with custom extra_data
256 pub fn build_with_data(
257 self,
258 extra_data: std::collections::BTreeMap<
259 jacquard_common::smol_str::SmolStr,
260 jacquard_common::types::value::Data<'a>,
261 >,
262 ) -> Service<'a> {
263 Service {
264 created_at: self.__unsafe_private_named.0.unwrap(),
265 labels: self.__unsafe_private_named.1,
266 policies: self.__unsafe_private_named.2.unwrap(),
267 reason_types: self.__unsafe_private_named.3,
268 subject_collections: self.__unsafe_private_named.4,
269 subject_types: self.__unsafe_private_named.5,
270 extra_data: Some(extra_data),
271 }
272 }
273}
274
275impl<'a> Service<'a> {
276 pub fn uri(
277 uri: impl Into<jacquard_common::CowStr<'a>>,
278 ) -> Result<
279 jacquard_common::types::uri::RecordUri<'a, ServiceRecord>,
280 jacquard_common::types::uri::UriError,
281 > {
282 jacquard_common::types::uri::RecordUri::try_from_uri(
283 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
284 )
285 }
286}
287
288/// Typed wrapper for GetRecord response with this collection's record type.
289#[derive(
290 serde::Serialize,
291 serde::Deserialize,
292 Debug,
293 Clone,
294 PartialEq,
295 Eq,
296 jacquard_derive::IntoStatic
297)]
298#[serde(rename_all = "camelCase")]
299pub struct ServiceGetRecordOutput<'a> {
300 #[serde(skip_serializing_if = "std::option::Option::is_none")]
301 #[serde(borrow)]
302 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
303 #[serde(borrow)]
304 pub uri: jacquard_common::types::string::AtUri<'a>,
305 #[serde(borrow)]
306 pub value: Service<'a>,
307}
308
309impl From<ServiceGetRecordOutput<'_>> for Service<'_> {
310 fn from(output: ServiceGetRecordOutput<'_>) -> Self {
311 use jacquard_common::IntoStatic;
312 output.value.into_static()
313 }
314}
315
316impl jacquard_common::types::collection::Collection for Service<'_> {
317 const NSID: &'static str = "app.bsky.labeler.service";
318 type Record = ServiceRecord;
319}
320
321/// Marker type for deserializing records from this collection.
322#[derive(Debug, serde::Serialize, serde::Deserialize)]
323pub struct ServiceRecord;
324impl jacquard_common::xrpc::XrpcResp for ServiceRecord {
325 const NSID: &'static str = "app.bsky.labeler.service";
326 const ENCODING: &'static str = "application/json";
327 type Output<'de> = ServiceGetRecordOutput<'de>;
328 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
329}
330
331impl jacquard_common::types::collection::Collection for ServiceRecord {
332 const NSID: &'static str = "app.bsky.labeler.service";
333 type Record = ServiceRecord;
334}
335
336impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Service<'a> {
337 fn nsid() -> &'static str {
338 "app.bsky.labeler.service"
339 }
340 fn def_name() -> &'static str {
341 "main"
342 }
343 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
344 lexicon_doc_app_bsky_labeler_service()
345 }
346 fn validate(
347 &self,
348 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
349 Ok(())
350 }
351}
352
353fn lexicon_doc_app_bsky_labeler_service() -> ::jacquard_lexicon::lexicon::LexiconDoc<
354 'static,
355> {
356 ::jacquard_lexicon::lexicon::LexiconDoc {
357 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
358 id: ::jacquard_common::CowStr::new_static("app.bsky.labeler.service"),
359 revision: None,
360 description: None,
361 defs: {
362 let mut map = ::alloc::collections::BTreeMap::new();
363 map.insert(
364 ::jacquard_common::smol_str::SmolStr::new_static("main"),
365 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
366 description: Some(
367 ::jacquard_common::CowStr::new_static(
368 "A declaration of the existence of labeler service.",
369 ),
370 ),
371 key: Some(::jacquard_common::CowStr::new_static("literal:self")),
372 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
373 description: None,
374 required: Some(
375 vec![
376 ::jacquard_common::smol_str::SmolStr::new_static("policies"),
377 ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
378 ],
379 ),
380 nullable: None,
381 properties: {
382 #[allow(unused_mut)]
383 let mut map = ::alloc::collections::BTreeMap::new();
384 map.insert(
385 ::jacquard_common::smol_str::SmolStr::new_static(
386 "createdAt",
387 ),
388 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
389 description: None,
390 format: Some(
391 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
392 ),
393 default: None,
394 min_length: None,
395 max_length: None,
396 min_graphemes: None,
397 max_graphemes: None,
398 r#enum: None,
399 r#const: None,
400 known_values: None,
401 }),
402 );
403 map.insert(
404 ::jacquard_common::smol_str::SmolStr::new_static("labels"),
405 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
406 description: None,
407 refs: vec![
408 ::jacquard_common::CowStr::new_static("com.atproto.label.defs#selfLabels")
409 ],
410 closed: None,
411 }),
412 );
413 map.insert(
414 ::jacquard_common::smol_str::SmolStr::new_static(
415 "policies",
416 ),
417 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
418 description: None,
419 r#ref: ::jacquard_common::CowStr::new_static(
420 "app.bsky.labeler.defs#labelerPolicies",
421 ),
422 }),
423 );
424 map.insert(
425 ::jacquard_common::smol_str::SmolStr::new_static(
426 "reasonTypes",
427 ),
428 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
429 description: Some(
430 ::jacquard_common::CowStr::new_static(
431 "The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.",
432 ),
433 ),
434 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
435 description: None,
436 r#ref: ::jacquard_common::CowStr::new_static(
437 "com.atproto.moderation.defs#reasonType",
438 ),
439 }),
440 min_length: None,
441 max_length: None,
442 }),
443 );
444 map.insert(
445 ::jacquard_common::smol_str::SmolStr::new_static(
446 "subjectCollections",
447 ),
448 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
449 description: Some(
450 ::jacquard_common::CowStr::new_static(
451 "Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.",
452 ),
453 ),
454 items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
455 description: None,
456 format: Some(
457 ::jacquard_lexicon::lexicon::LexStringFormat::Nsid,
458 ),
459 default: None,
460 min_length: None,
461 max_length: None,
462 min_graphemes: None,
463 max_graphemes: None,
464 r#enum: None,
465 r#const: None,
466 known_values: None,
467 }),
468 min_length: None,
469 max_length: None,
470 }),
471 );
472 map.insert(
473 ::jacquard_common::smol_str::SmolStr::new_static(
474 "subjectTypes",
475 ),
476 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
477 description: Some(
478 ::jacquard_common::CowStr::new_static(
479 "The set of subject types (account, record, etc) this service accepts reports on.",
480 ),
481 ),
482 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
483 description: None,
484 r#ref: ::jacquard_common::CowStr::new_static(
485 "com.atproto.moderation.defs#subjectType",
486 ),
487 }),
488 min_length: None,
489 max_length: None,
490 }),
491 );
492 map
493 },
494 }),
495 }),
496 );
497 map
498 },
499 }
500}