Skip to main content

jacquard_api/place_stream/
moderation.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.moderation.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 create_block;
9pub mod create_gate;
10pub mod delete_block;
11pub mod delete_gate;
12pub mod permission;
13pub mod update_livestream;
14
15
16#[allow(unused_imports)]
17use alloc::collections::BTreeMap;
18
19#[allow(unused_imports)]
20use core::marker::PhantomData;
21
22#[allow(unused_imports)]
23use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
24use jacquard_common::types::string::{AtUri, Cid};
25use jacquard_common::types::value::Data;
26use jacquard_derive::{IntoStatic, lexicon};
27use jacquard_lexicon::lexicon::LexiconDoc;
28use jacquard_lexicon::schema::LexiconSchema;
29
30#[allow(unused_imports)]
31use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
32use serde::{Serialize, Deserialize};
33use crate::app_bsky::actor::ProfileViewBasic;
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase")]
38pub struct PermissionView<'a> {
39    ///The streamer who granted these permissions
40    #[serde(borrow)]
41    pub author: ProfileViewBasic<'a>,
42    ///Content identifier of the permission record
43    #[serde(borrow)]
44    pub cid: Cid<'a>,
45    ///The permission record itself
46    #[serde(borrow)]
47    pub record: Data<'a>,
48    ///AT-URI of the permission record
49    #[serde(borrow)]
50    pub uri: AtUri<'a>,
51}
52
53impl<'a> LexiconSchema for PermissionView<'a> {
54    fn nsid() -> &'static str {
55        "place.stream.moderation.defs"
56    }
57    fn def_name() -> &'static str {
58        "permissionView"
59    }
60    fn lexicon_doc() -> LexiconDoc<'static> {
61        lexicon_doc_place_stream_moderation_defs()
62    }
63    fn validate(&self) -> Result<(), ConstraintError> {
64        Ok(())
65    }
66}
67
68pub mod permission_view_state {
69
70    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
71    #[allow(unused)]
72    use ::core::marker::PhantomData;
73    mod sealed {
74        pub trait Sealed {}
75    }
76    /// State trait tracking which required fields have been set
77    pub trait State: sealed::Sealed {
78        type Author;
79        type Cid;
80        type Record;
81        type Uri;
82    }
83    /// Empty state - all required fields are unset
84    pub struct Empty(());
85    impl sealed::Sealed for Empty {}
86    impl State for Empty {
87        type Author = Unset;
88        type Cid = Unset;
89        type Record = Unset;
90        type Uri = Unset;
91    }
92    ///State transition - sets the `author` field to Set
93    pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
94    impl<S: State> sealed::Sealed for SetAuthor<S> {}
95    impl<S: State> State for SetAuthor<S> {
96        type Author = Set<members::author>;
97        type Cid = S::Cid;
98        type Record = S::Record;
99        type Uri = S::Uri;
100    }
101    ///State transition - sets the `cid` field to Set
102    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
103    impl<S: State> sealed::Sealed for SetCid<S> {}
104    impl<S: State> State for SetCid<S> {
105        type Author = S::Author;
106        type Cid = Set<members::cid>;
107        type Record = S::Record;
108        type Uri = S::Uri;
109    }
110    ///State transition - sets the `record` field to Set
111    pub struct SetRecord<S: State = Empty>(PhantomData<fn() -> S>);
112    impl<S: State> sealed::Sealed for SetRecord<S> {}
113    impl<S: State> State for SetRecord<S> {
114        type Author = S::Author;
115        type Cid = S::Cid;
116        type Record = Set<members::record>;
117        type Uri = S::Uri;
118    }
119    ///State transition - sets the `uri` field to Set
120    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
121    impl<S: State> sealed::Sealed for SetUri<S> {}
122    impl<S: State> State for SetUri<S> {
123        type Author = S::Author;
124        type Cid = S::Cid;
125        type Record = S::Record;
126        type Uri = Set<members::uri>;
127    }
128    /// Marker types for field names
129    #[allow(non_camel_case_types)]
130    pub mod members {
131        ///Marker type for the `author` field
132        pub struct author(());
133        ///Marker type for the `cid` field
134        pub struct cid(());
135        ///Marker type for the `record` field
136        pub struct record(());
137        ///Marker type for the `uri` field
138        pub struct uri(());
139    }
140}
141
142/// Builder for constructing an instance of this type
143pub struct PermissionViewBuilder<'a, S: permission_view_state::State> {
144    _state: PhantomData<fn() -> S>,
145    _fields: (
146        Option<ProfileViewBasic<'a>>,
147        Option<Cid<'a>>,
148        Option<Data<'a>>,
149        Option<AtUri<'a>>,
150    ),
151    _lifetime: PhantomData<&'a ()>,
152}
153
154impl<'a> PermissionView<'a> {
155    /// Create a new builder for this type
156    pub fn new() -> PermissionViewBuilder<'a, permission_view_state::Empty> {
157        PermissionViewBuilder::new()
158    }
159}
160
161impl<'a> PermissionViewBuilder<'a, permission_view_state::Empty> {
162    /// Create a new builder with all fields unset
163    pub fn new() -> Self {
164        PermissionViewBuilder {
165            _state: PhantomData,
166            _fields: (None, None, None, None),
167            _lifetime: PhantomData,
168        }
169    }
170}
171
172impl<'a, S> PermissionViewBuilder<'a, S>
173where
174    S: permission_view_state::State,
175    S::Author: permission_view_state::IsUnset,
176{
177    /// Set the `author` field (required)
178    pub fn author(
179        mut self,
180        value: impl Into<ProfileViewBasic<'a>>,
181    ) -> PermissionViewBuilder<'a, permission_view_state::SetAuthor<S>> {
182        self._fields.0 = Option::Some(value.into());
183        PermissionViewBuilder {
184            _state: PhantomData,
185            _fields: self._fields,
186            _lifetime: PhantomData,
187        }
188    }
189}
190
191impl<'a, S> PermissionViewBuilder<'a, S>
192where
193    S: permission_view_state::State,
194    S::Cid: permission_view_state::IsUnset,
195{
196    /// Set the `cid` field (required)
197    pub fn cid(
198        mut self,
199        value: impl Into<Cid<'a>>,
200    ) -> PermissionViewBuilder<'a, permission_view_state::SetCid<S>> {
201        self._fields.1 = Option::Some(value.into());
202        PermissionViewBuilder {
203            _state: PhantomData,
204            _fields: self._fields,
205            _lifetime: PhantomData,
206        }
207    }
208}
209
210impl<'a, S> PermissionViewBuilder<'a, S>
211where
212    S: permission_view_state::State,
213    S::Record: permission_view_state::IsUnset,
214{
215    /// Set the `record` field (required)
216    pub fn record(
217        mut self,
218        value: impl Into<Data<'a>>,
219    ) -> PermissionViewBuilder<'a, permission_view_state::SetRecord<S>> {
220        self._fields.2 = Option::Some(value.into());
221        PermissionViewBuilder {
222            _state: PhantomData,
223            _fields: self._fields,
224            _lifetime: PhantomData,
225        }
226    }
227}
228
229impl<'a, S> PermissionViewBuilder<'a, S>
230where
231    S: permission_view_state::State,
232    S::Uri: permission_view_state::IsUnset,
233{
234    /// Set the `uri` field (required)
235    pub fn uri(
236        mut self,
237        value: impl Into<AtUri<'a>>,
238    ) -> PermissionViewBuilder<'a, permission_view_state::SetUri<S>> {
239        self._fields.3 = Option::Some(value.into());
240        PermissionViewBuilder {
241            _state: PhantomData,
242            _fields: self._fields,
243            _lifetime: PhantomData,
244        }
245    }
246}
247
248impl<'a, S> PermissionViewBuilder<'a, S>
249where
250    S: permission_view_state::State,
251    S::Author: permission_view_state::IsSet,
252    S::Cid: permission_view_state::IsSet,
253    S::Record: permission_view_state::IsSet,
254    S::Uri: permission_view_state::IsSet,
255{
256    /// Build the final struct
257    pub fn build(self) -> PermissionView<'a> {
258        PermissionView {
259            author: self._fields.0.unwrap(),
260            cid: self._fields.1.unwrap(),
261            record: self._fields.2.unwrap(),
262            uri: self._fields.3.unwrap(),
263            extra_data: Default::default(),
264        }
265    }
266    /// Build the final struct with custom extra_data
267    pub fn build_with_data(
268        self,
269        extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
270    ) -> PermissionView<'a> {
271        PermissionView {
272            author: self._fields.0.unwrap(),
273            cid: self._fields.1.unwrap(),
274            record: self._fields.2.unwrap(),
275            uri: self._fields.3.unwrap(),
276            extra_data: Some(extra_data),
277        }
278    }
279}
280
281fn lexicon_doc_place_stream_moderation_defs() -> LexiconDoc<'static> {
282    #[allow(unused_imports)]
283    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
284    use jacquard_lexicon::lexicon::*;
285    use alloc::collections::BTreeMap;
286    LexiconDoc {
287        lexicon: Lexicon::Lexicon1,
288        id: CowStr::new_static("place.stream.moderation.defs"),
289        defs: {
290            let mut map = BTreeMap::new();
291            map.insert(
292                SmolStr::new_static("permissionView"),
293                LexUserType::Object(LexObject {
294                    required: Some(
295                        vec![
296                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
297                            SmolStr::new_static("author"), SmolStr::new_static("record")
298                        ],
299                    ),
300                    properties: {
301                        #[allow(unused_mut)]
302                        let mut map = BTreeMap::new();
303                        map.insert(
304                            SmolStr::new_static("author"),
305                            LexObjectProperty::Ref(LexRef {
306                                r#ref: CowStr::new_static(
307                                    "app.bsky.actor.defs#profileViewBasic",
308                                ),
309                                ..Default::default()
310                            }),
311                        );
312                        map.insert(
313                            SmolStr::new_static("cid"),
314                            LexObjectProperty::String(LexString {
315                                description: Some(
316                                    CowStr::new_static(
317                                        "Content identifier of the permission record",
318                                    ),
319                                ),
320                                format: Some(LexStringFormat::Cid),
321                                ..Default::default()
322                            }),
323                        );
324                        map.insert(
325                            SmolStr::new_static("record"),
326                            LexObjectProperty::Unknown(LexUnknown {
327                                ..Default::default()
328                            }),
329                        );
330                        map.insert(
331                            SmolStr::new_static("uri"),
332                            LexObjectProperty::String(LexString {
333                                description: Some(
334                                    CowStr::new_static("AT-URI of the permission record"),
335                                ),
336                                format: Some(LexStringFormat::AtUri),
337                                ..Default::default()
338                            }),
339                        );
340                        map
341                    },
342                    ..Default::default()
343                }),
344            );
345            map
346        },
347        ..Default::default()
348    }
349}