Skip to main content

jacquard_api/chat_bsky/embed/
join_link.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: chat.bsky.embed.joinLink
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::deps::smol_str::SmolStr;
18use jacquard_common::types::value::Data;
19use jacquard_derive::{IntoStatic, open_union};
20use jacquard_lexicon::lexicon::LexiconDoc;
21use jacquard_lexicon::schema::LexiconSchema;
22
23use crate::chat_bsky::group::DisabledJoinLinkPreviewView;
24use crate::chat_bsky::group::InvalidJoinLinkPreviewView;
25use crate::chat_bsky::group::JoinLinkPreviewView;
26#[allow(unused_imports)]
27use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
28use serde::{Deserialize, Serialize};
29
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
31#[serde(
32    rename_all = "camelCase",
33    bound(deserialize = "S: Deserialize<'de> + BosStr")
34)]
35pub struct JoinLink<S: BosStr = DefaultStr> {
36    ///The join link code.
37    pub code: S,
38    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
39    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
40}
41
42#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
43#[serde(
44    rename_all = "camelCase",
45    bound(deserialize = "S: Deserialize<'de> + BosStr")
46)]
47pub struct View<S: BosStr = DefaultStr> {
48    pub join_link_preview: ViewJoinLinkPreview<S>,
49    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
50    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
51}
52
53#[open_union]
54#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
55#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
56pub enum ViewJoinLinkPreview<S: BosStr = DefaultStr> {
57    #[serde(rename = "chat.bsky.group.defs#joinLinkPreviewView")]
58    JoinLinkPreviewView(Box<JoinLinkPreviewView<S>>),
59    #[serde(rename = "chat.bsky.group.defs#disabledJoinLinkPreviewView")]
60    DisabledJoinLinkPreviewView(Box<DisabledJoinLinkPreviewView<S>>),
61    #[serde(rename = "chat.bsky.group.defs#invalidJoinLinkPreviewView")]
62    InvalidJoinLinkPreviewView(Box<InvalidJoinLinkPreviewView<S>>),
63}
64
65impl<S: BosStr> LexiconSchema for JoinLink<S> {
66    fn nsid() -> &'static str {
67        "chat.bsky.embed.joinLink"
68    }
69    fn def_name() -> &'static str {
70        "main"
71    }
72    fn lexicon_doc() -> LexiconDoc<'static> {
73        lexicon_doc_chat_bsky_embed_joinLink()
74    }
75    fn validate(&self) -> Result<(), ConstraintError> {
76        Ok(())
77    }
78}
79
80impl<S: BosStr> LexiconSchema for View<S> {
81    fn nsid() -> &'static str {
82        "chat.bsky.embed.joinLink"
83    }
84    fn def_name() -> &'static str {
85        "view"
86    }
87    fn lexicon_doc() -> LexiconDoc<'static> {
88        lexicon_doc_chat_bsky_embed_joinLink()
89    }
90    fn validate(&self) -> Result<(), ConstraintError> {
91        Ok(())
92    }
93}
94
95fn lexicon_doc_chat_bsky_embed_joinLink() -> LexiconDoc<'static> {
96    use alloc::collections::BTreeMap;
97    #[allow(unused_imports)]
98    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
99    use jacquard_lexicon::lexicon::*;
100    LexiconDoc {
101        lexicon: Lexicon::Lexicon1,
102        id: CowStr::new_static("chat.bsky.embed.joinLink"),
103        defs: {
104            let mut map = BTreeMap::new();
105            map.insert(
106                SmolStr::new_static("main"),
107                LexUserType::Object(LexObject {
108                    required: Some(vec![SmolStr::new_static("code")]),
109                    properties: {
110                        #[allow(unused_mut)]
111                        let mut map = BTreeMap::new();
112                        map.insert(
113                            SmolStr::new_static("code"),
114                            LexObjectProperty::String(LexString {
115                                description: Some(CowStr::new_static("The join link code.")),
116                                ..Default::default()
117                            }),
118                        );
119                        map
120                    },
121                    ..Default::default()
122                }),
123            );
124            map.insert(
125                SmolStr::new_static("view"),
126                LexUserType::Object(LexObject {
127                    required: Some(vec![SmolStr::new_static("joinLinkPreview")]),
128                    properties: {
129                        #[allow(unused_mut)]
130                        let mut map = BTreeMap::new();
131                        map.insert(
132                            SmolStr::new_static("joinLinkPreview"),
133                            LexObjectProperty::Union(LexRefUnion {
134                                refs: vec![
135                                    CowStr::new_static("chat.bsky.group.defs#joinLinkPreviewView"),
136                                    CowStr::new_static(
137                                        "chat.bsky.group.defs#disabledJoinLinkPreviewView",
138                                    ),
139                                    CowStr::new_static(
140                                        "chat.bsky.group.defs#invalidJoinLinkPreviewView",
141                                    ),
142                                ],
143                                ..Default::default()
144                            }),
145                        );
146                        map
147                    },
148                    ..Default::default()
149                }),
150            );
151            map
152        },
153        ..Default::default()
154    }
155}
156
157pub mod view_state {
158
159    pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
160    #[allow(unused)]
161    use ::core::marker::PhantomData;
162    mod sealed {
163        pub trait Sealed {}
164    }
165    /// State trait tracking which required fields have been set
166    pub trait State: sealed::Sealed {
167        type JoinLinkPreview;
168    }
169    /// Empty state - all required fields are unset
170    pub struct Empty(());
171    impl sealed::Sealed for Empty {}
172    impl State for Empty {
173        type JoinLinkPreview = Unset;
174    }
175    ///State transition - sets the `join_link_preview` field to Set
176    pub struct SetJoinLinkPreview<St: State = Empty>(PhantomData<fn() -> St>);
177    impl<St: State> sealed::Sealed for SetJoinLinkPreview<St> {}
178    impl<St: State> State for SetJoinLinkPreview<St> {
179        type JoinLinkPreview = Set<members::join_link_preview>;
180    }
181    /// Marker types for field names
182    #[allow(non_camel_case_types)]
183    pub mod members {
184        ///Marker type for the `join_link_preview` field
185        pub struct join_link_preview(());
186    }
187}
188
189/// Builder for constructing an instance of this type.
190pub struct ViewBuilder<St: view_state::State, S: BosStr = DefaultStr> {
191    _state: PhantomData<fn() -> St>,
192    _fields: (Option<ViewJoinLinkPreview<S>>,),
193    _type: PhantomData<fn() -> S>,
194}
195
196impl View<DefaultStr> {
197    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
198    pub fn new() -> ViewBuilder<view_state::Empty, DefaultStr> {
199        ViewBuilder::new()
200    }
201}
202
203impl<S: BosStr> View<S> {
204    /// Create a new builder for this type
205    pub fn builder() -> ViewBuilder<view_state::Empty, S> {
206        ViewBuilder::builder()
207    }
208}
209
210impl ViewBuilder<view_state::Empty, DefaultStr> {
211    /// Create a new builder with all fields unset, using the default string type, if needed
212    pub fn new() -> Self {
213        ViewBuilder {
214            _state: PhantomData,
215            _fields: (None,),
216            _type: PhantomData,
217        }
218    }
219}
220
221impl<S: BosStr> ViewBuilder<view_state::Empty, S> {
222    /// Create a new builder with all fields unset
223    pub fn builder() -> Self {
224        ViewBuilder {
225            _state: PhantomData,
226            _fields: (None,),
227            _type: PhantomData,
228        }
229    }
230}
231
232impl<St, S: BosStr> ViewBuilder<St, S>
233where
234    St: view_state::State,
235    St::JoinLinkPreview: view_state::IsUnset,
236{
237    /// Set the `joinLinkPreview` field (required)
238    pub fn join_link_preview(
239        mut self,
240        value: impl Into<ViewJoinLinkPreview<S>>,
241    ) -> ViewBuilder<view_state::SetJoinLinkPreview<St>, S> {
242        self._fields.0 = Option::Some(value.into());
243        ViewBuilder {
244            _state: PhantomData,
245            _fields: self._fields,
246            _type: PhantomData,
247        }
248    }
249}
250
251impl<St, S: BosStr> ViewBuilder<St, S>
252where
253    St: view_state::State,
254    St::JoinLinkPreview: view_state::IsSet,
255{
256    /// Build the final struct.
257    pub fn build(self) -> View<S> {
258        View {
259            join_link_preview: self._fields.0.unwrap(),
260            extra_data: Default::default(),
261        }
262    }
263    /// Build the final struct with custom extra_data.
264    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> View<S> {
265        View {
266            join_link_preview: self._fields.0.unwrap(),
267            extra_data: Some(extra_data),
268        }
269    }
270}