1pub mod external;
9pub mod images;
10pub mod record;
11pub mod record_with_media;
12pub mod video;
13
14
15#[allow(unused_imports)]
16use alloc::collections::BTreeMap;
17
18#[allow(unused_imports)]
19use core::marker::PhantomData;
20
21#[allow(unused_imports)]
22use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
23use jacquard_derive::{IntoStatic, lexicon};
24use jacquard_lexicon::lexicon::LexiconDoc;
25use jacquard_lexicon::schema::LexiconSchema;
26
27#[allow(unused_imports)]
28use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
29use serde::{Serialize, Deserialize};
30#[lexicon]
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
34#[serde(rename_all = "camelCase")]
35pub struct AspectRatio<'a> {
36 pub height: i64,
37 pub width: i64,
38}
39
40impl<'a> LexiconSchema for AspectRatio<'a> {
41 fn nsid() -> &'static str {
42 "app.bsky.embed.defs"
43 }
44 fn def_name() -> &'static str {
45 "aspectRatio"
46 }
47 fn lexicon_doc() -> LexiconDoc<'static> {
48 lexicon_doc_app_bsky_embed_defs()
49 }
50 fn validate(&self) -> Result<(), ConstraintError> {
51 {
52 let value = &self.height;
53 if *value < 1i64 {
54 return Err(ConstraintError::Minimum {
55 path: ValidationPath::from_field("height"),
56 min: 1i64,
57 actual: *value,
58 });
59 }
60 }
61 {
62 let value = &self.width;
63 if *value < 1i64 {
64 return Err(ConstraintError::Minimum {
65 path: ValidationPath::from_field("width"),
66 min: 1i64,
67 actual: *value,
68 });
69 }
70 }
71 Ok(())
72 }
73}
74
75pub mod aspect_ratio_state {
76
77 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
78 #[allow(unused)]
79 use ::core::marker::PhantomData;
80 mod sealed {
81 pub trait Sealed {}
82 }
83 pub trait State: sealed::Sealed {
85 type Height;
86 type Width;
87 }
88 pub struct Empty(());
90 impl sealed::Sealed for Empty {}
91 impl State for Empty {
92 type Height = Unset;
93 type Width = Unset;
94 }
95 pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
97 impl<S: State> sealed::Sealed for SetHeight<S> {}
98 impl<S: State> State for SetHeight<S> {
99 type Height = Set<members::height>;
100 type Width = S::Width;
101 }
102 pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
104 impl<S: State> sealed::Sealed for SetWidth<S> {}
105 impl<S: State> State for SetWidth<S> {
106 type Height = S::Height;
107 type Width = Set<members::width>;
108 }
109 #[allow(non_camel_case_types)]
111 pub mod members {
112 pub struct height(());
114 pub struct width(());
116 }
117}
118
119pub struct AspectRatioBuilder<'a, S: aspect_ratio_state::State> {
121 _state: PhantomData<fn() -> S>,
122 _fields: (Option<i64>, Option<i64>),
123 _lifetime: PhantomData<&'a ()>,
124}
125
126impl<'a> AspectRatio<'a> {
127 pub fn new() -> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
129 AspectRatioBuilder::new()
130 }
131}
132
133impl<'a> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
134 pub fn new() -> Self {
136 AspectRatioBuilder {
137 _state: PhantomData,
138 _fields: (None, None),
139 _lifetime: PhantomData,
140 }
141 }
142}
143
144impl<'a, S> AspectRatioBuilder<'a, S>
145where
146 S: aspect_ratio_state::State,
147 S::Height: aspect_ratio_state::IsUnset,
148{
149 pub fn height(
151 mut self,
152 value: impl Into<i64>,
153 ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetHeight<S>> {
154 self._fields.0 = Option::Some(value.into());
155 AspectRatioBuilder {
156 _state: PhantomData,
157 _fields: self._fields,
158 _lifetime: PhantomData,
159 }
160 }
161}
162
163impl<'a, S> AspectRatioBuilder<'a, S>
164where
165 S: aspect_ratio_state::State,
166 S::Width: aspect_ratio_state::IsUnset,
167{
168 pub fn width(
170 mut self,
171 value: impl Into<i64>,
172 ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetWidth<S>> {
173 self._fields.1 = Option::Some(value.into());
174 AspectRatioBuilder {
175 _state: PhantomData,
176 _fields: self._fields,
177 _lifetime: PhantomData,
178 }
179 }
180}
181
182impl<'a, S> AspectRatioBuilder<'a, S>
183where
184 S: aspect_ratio_state::State,
185 S::Height: aspect_ratio_state::IsSet,
186 S::Width: aspect_ratio_state::IsSet,
187{
188 pub fn build(self) -> AspectRatio<'a> {
190 AspectRatio {
191 height: self._fields.0.unwrap(),
192 width: self._fields.1.unwrap(),
193 extra_data: Default::default(),
194 }
195 }
196 pub fn build_with_data(
198 self,
199 extra_data: BTreeMap<
200 jacquard_common::deps::smol_str::SmolStr,
201 jacquard_common::types::value::Data<'a>,
202 >,
203 ) -> AspectRatio<'a> {
204 AspectRatio {
205 height: self._fields.0.unwrap(),
206 width: self._fields.1.unwrap(),
207 extra_data: Some(extra_data),
208 }
209 }
210}
211
212fn lexicon_doc_app_bsky_embed_defs() -> LexiconDoc<'static> {
213 #[allow(unused_imports)]
214 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
215 use jacquard_lexicon::lexicon::*;
216 use alloc::collections::BTreeMap;
217 LexiconDoc {
218 lexicon: Lexicon::Lexicon1,
219 id: CowStr::new_static("app.bsky.embed.defs"),
220 defs: {
221 let mut map = BTreeMap::new();
222 map.insert(
223 SmolStr::new_static("aspectRatio"),
224 LexUserType::Object(LexObject {
225 description: Some(
226 CowStr::new_static(
227 "width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.",
228 ),
229 ),
230 required: Some(
231 vec![SmolStr::new_static("width"), SmolStr::new_static("height")],
232 ),
233 properties: {
234 #[allow(unused_mut)]
235 let mut map = BTreeMap::new();
236 map.insert(
237 SmolStr::new_static("height"),
238 LexObjectProperty::Integer(LexInteger {
239 minimum: Some(1i64),
240 ..Default::default()
241 }),
242 );
243 map.insert(
244 SmolStr::new_static("width"),
245 LexObjectProperty::Integer(LexInteger {
246 minimum: Some(1i64),
247 ..Default::default()
248 }),
249 );
250 map
251 },
252 ..Default::default()
253 }),
254 );
255 map
256 },
257 ..Default::default()
258 }
259}