atproto blogging
at main 457 lines 16 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.embed.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 external; 9pub mod images; 10pub mod record_with_media; 11pub mod records; 12pub mod video; 13 14/// Proportional size of the embed relative to the viewport in larger windows. The dimensions are percentage out of 100. Could we use more granularity? Maybe, but come on. 15#[jacquard_derive::lexicon] 16#[derive( 17 serde::Serialize, 18 serde::Deserialize, 19 Debug, 20 Clone, 21 PartialEq, 22 Eq, 23 jacquard_derive::IntoStatic 24)] 25#[serde(rename_all = "camelCase")] 26pub struct PercentSize<'a> { 27 pub height: i64, 28 pub width: i64, 29} 30 31pub mod percent_size_state { 32 33 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 34 #[allow(unused)] 35 use ::core::marker::PhantomData; 36 mod sealed { 37 pub trait Sealed {} 38 } 39 /// State trait tracking which required fields have been set 40 pub trait State: sealed::Sealed { 41 type Width; 42 type Height; 43 } 44 /// Empty state - all required fields are unset 45 pub struct Empty(()); 46 impl sealed::Sealed for Empty {} 47 impl State for Empty { 48 type Width = Unset; 49 type Height = Unset; 50 } 51 ///State transition - sets the `width` field to Set 52 pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>); 53 impl<S: State> sealed::Sealed for SetWidth<S> {} 54 impl<S: State> State for SetWidth<S> { 55 type Width = Set<members::width>; 56 type Height = S::Height; 57 } 58 ///State transition - sets the `height` field to Set 59 pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>); 60 impl<S: State> sealed::Sealed for SetHeight<S> {} 61 impl<S: State> State for SetHeight<S> { 62 type Width = S::Width; 63 type Height = Set<members::height>; 64 } 65 /// Marker types for field names 66 #[allow(non_camel_case_types)] 67 pub mod members { 68 ///Marker type for the `width` field 69 pub struct width(()); 70 ///Marker type for the `height` field 71 pub struct height(()); 72 } 73} 74 75/// Builder for constructing an instance of this type 76pub struct PercentSizeBuilder<'a, S: percent_size_state::State> { 77 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 78 __unsafe_private_named: (::core::option::Option<i64>, ::core::option::Option<i64>), 79 _phantom: ::core::marker::PhantomData<&'a ()>, 80} 81 82impl<'a> PercentSize<'a> { 83 /// Create a new builder for this type 84 pub fn new() -> PercentSizeBuilder<'a, percent_size_state::Empty> { 85 PercentSizeBuilder::new() 86 } 87} 88 89impl<'a> PercentSizeBuilder<'a, percent_size_state::Empty> { 90 /// Create a new builder with all fields unset 91 pub fn new() -> Self { 92 PercentSizeBuilder { 93 _phantom_state: ::core::marker::PhantomData, 94 __unsafe_private_named: (None, None), 95 _phantom: ::core::marker::PhantomData, 96 } 97 } 98} 99 100impl<'a, S> PercentSizeBuilder<'a, S> 101where 102 S: percent_size_state::State, 103 S::Height: percent_size_state::IsUnset, 104{ 105 /// Set the `height` field (required) 106 pub fn height( 107 mut self, 108 value: impl Into<i64>, 109 ) -> PercentSizeBuilder<'a, percent_size_state::SetHeight<S>> { 110 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 111 PercentSizeBuilder { 112 _phantom_state: ::core::marker::PhantomData, 113 __unsafe_private_named: self.__unsafe_private_named, 114 _phantom: ::core::marker::PhantomData, 115 } 116 } 117} 118 119impl<'a, S> PercentSizeBuilder<'a, S> 120where 121 S: percent_size_state::State, 122 S::Width: percent_size_state::IsUnset, 123{ 124 /// Set the `width` field (required) 125 pub fn width( 126 mut self, 127 value: impl Into<i64>, 128 ) -> PercentSizeBuilder<'a, percent_size_state::SetWidth<S>> { 129 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 130 PercentSizeBuilder { 131 _phantom_state: ::core::marker::PhantomData, 132 __unsafe_private_named: self.__unsafe_private_named, 133 _phantom: ::core::marker::PhantomData, 134 } 135 } 136} 137 138impl<'a, S> PercentSizeBuilder<'a, S> 139where 140 S: percent_size_state::State, 141 S::Width: percent_size_state::IsSet, 142 S::Height: percent_size_state::IsSet, 143{ 144 /// Build the final struct 145 pub fn build(self) -> PercentSize<'a> { 146 PercentSize { 147 height: self.__unsafe_private_named.0.unwrap(), 148 width: self.__unsafe_private_named.1.unwrap(), 149 extra_data: Default::default(), 150 } 151 } 152 /// Build the final struct with custom extra_data 153 pub fn build_with_data( 154 self, 155 extra_data: std::collections::BTreeMap< 156 jacquard_common::smol_str::SmolStr, 157 jacquard_common::types::value::Data<'a>, 158 >, 159 ) -> PercentSize<'a> { 160 PercentSize { 161 height: self.__unsafe_private_named.0.unwrap(), 162 width: self.__unsafe_private_named.1.unwrap(), 163 extra_data: Some(extra_data), 164 } 165 } 166} 167 168fn lexicon_doc_sh_weaver_embed_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 169 'static, 170> { 171 ::jacquard_lexicon::lexicon::LexiconDoc { 172 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 173 id: ::jacquard_common::CowStr::new_static("sh.weaver.embed.defs"), 174 revision: None, 175 description: None, 176 defs: { 177 let mut map = ::alloc::collections::BTreeMap::new(); 178 map.insert( 179 ::jacquard_common::smol_str::SmolStr::new_static("percentSize"), 180 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 181 description: Some( 182 ::jacquard_common::CowStr::new_static( 183 "Proportional size of the embed relative to the viewport in larger windows. The dimensions are percentage out of 100. Could we use more granularity? Maybe, but come on.", 184 ), 185 ), 186 required: Some( 187 vec![ 188 ::jacquard_common::smol_str::SmolStr::new_static("width"), 189 ::jacquard_common::smol_str::SmolStr::new_static("height") 190 ], 191 ), 192 nullable: None, 193 properties: { 194 #[allow(unused_mut)] 195 let mut map = ::alloc::collections::BTreeMap::new(); 196 map.insert( 197 ::jacquard_common::smol_str::SmolStr::new_static("height"), 198 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 199 description: None, 200 default: None, 201 minimum: None, 202 maximum: None, 203 r#enum: None, 204 r#const: None, 205 }), 206 ); 207 map.insert( 208 ::jacquard_common::smol_str::SmolStr::new_static("width"), 209 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 210 description: None, 211 default: None, 212 minimum: None, 213 maximum: None, 214 r#enum: None, 215 r#const: None, 216 }), 217 ); 218 map 219 }, 220 }), 221 ); 222 map.insert( 223 ::jacquard_common::smol_str::SmolStr::new_static("pixelSize"), 224 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 225 description: Some( 226 ::jacquard_common::CowStr::new_static( 227 "Pixel-exact embed size. The dimensions are logical pixels, subject to scaling, so 200px at X2 scale is 400px.", 228 ), 229 ), 230 required: Some( 231 vec![ 232 ::jacquard_common::smol_str::SmolStr::new_static("width"), 233 ::jacquard_common::smol_str::SmolStr::new_static("height") 234 ], 235 ), 236 nullable: None, 237 properties: { 238 #[allow(unused_mut)] 239 let mut map = ::alloc::collections::BTreeMap::new(); 240 map.insert( 241 ::jacquard_common::smol_str::SmolStr::new_static("height"), 242 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 243 description: None, 244 default: None, 245 minimum: None, 246 maximum: None, 247 r#enum: None, 248 r#const: None, 249 }), 250 ); 251 map.insert( 252 ::jacquard_common::smol_str::SmolStr::new_static("width"), 253 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 254 description: None, 255 default: None, 256 minimum: None, 257 maximum: None, 258 r#enum: None, 259 r#const: None, 260 }), 261 ); 262 map 263 }, 264 }), 265 ); 266 map 267 }, 268 } 269} 270 271impl<'a> ::jacquard_lexicon::schema::LexiconSchema for PercentSize<'a> { 272 fn nsid() -> &'static str { 273 "sh.weaver.embed.defs" 274 } 275 fn def_name() -> &'static str { 276 "percentSize" 277 } 278 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 279 lexicon_doc_sh_weaver_embed_defs() 280 } 281 fn validate( 282 &self, 283 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 284 Ok(()) 285 } 286} 287 288/// Pixel-exact embed size. The dimensions are logical pixels, subject to scaling, so 200px at X2 scale is 400px. 289#[jacquard_derive::lexicon] 290#[derive( 291 serde::Serialize, 292 serde::Deserialize, 293 Debug, 294 Clone, 295 PartialEq, 296 Eq, 297 jacquard_derive::IntoStatic 298)] 299#[serde(rename_all = "camelCase")] 300pub struct PixelSize<'a> { 301 pub height: i64, 302 pub width: i64, 303} 304 305pub mod pixel_size_state { 306 307 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 308 #[allow(unused)] 309 use ::core::marker::PhantomData; 310 mod sealed { 311 pub trait Sealed {} 312 } 313 /// State trait tracking which required fields have been set 314 pub trait State: sealed::Sealed { 315 type Width; 316 type Height; 317 } 318 /// Empty state - all required fields are unset 319 pub struct Empty(()); 320 impl sealed::Sealed for Empty {} 321 impl State for Empty { 322 type Width = Unset; 323 type Height = Unset; 324 } 325 ///State transition - sets the `width` field to Set 326 pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>); 327 impl<S: State> sealed::Sealed for SetWidth<S> {} 328 impl<S: State> State for SetWidth<S> { 329 type Width = Set<members::width>; 330 type Height = S::Height; 331 } 332 ///State transition - sets the `height` field to Set 333 pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>); 334 impl<S: State> sealed::Sealed for SetHeight<S> {} 335 impl<S: State> State for SetHeight<S> { 336 type Width = S::Width; 337 type Height = Set<members::height>; 338 } 339 /// Marker types for field names 340 #[allow(non_camel_case_types)] 341 pub mod members { 342 ///Marker type for the `width` field 343 pub struct width(()); 344 ///Marker type for the `height` field 345 pub struct height(()); 346 } 347} 348 349/// Builder for constructing an instance of this type 350pub struct PixelSizeBuilder<'a, S: pixel_size_state::State> { 351 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 352 __unsafe_private_named: (::core::option::Option<i64>, ::core::option::Option<i64>), 353 _phantom: ::core::marker::PhantomData<&'a ()>, 354} 355 356impl<'a> PixelSize<'a> { 357 /// Create a new builder for this type 358 pub fn new() -> PixelSizeBuilder<'a, pixel_size_state::Empty> { 359 PixelSizeBuilder::new() 360 } 361} 362 363impl<'a> PixelSizeBuilder<'a, pixel_size_state::Empty> { 364 /// Create a new builder with all fields unset 365 pub fn new() -> Self { 366 PixelSizeBuilder { 367 _phantom_state: ::core::marker::PhantomData, 368 __unsafe_private_named: (None, None), 369 _phantom: ::core::marker::PhantomData, 370 } 371 } 372} 373 374impl<'a, S> PixelSizeBuilder<'a, S> 375where 376 S: pixel_size_state::State, 377 S::Height: pixel_size_state::IsUnset, 378{ 379 /// Set the `height` field (required) 380 pub fn height( 381 mut self, 382 value: impl Into<i64>, 383 ) -> PixelSizeBuilder<'a, pixel_size_state::SetHeight<S>> { 384 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 385 PixelSizeBuilder { 386 _phantom_state: ::core::marker::PhantomData, 387 __unsafe_private_named: self.__unsafe_private_named, 388 _phantom: ::core::marker::PhantomData, 389 } 390 } 391} 392 393impl<'a, S> PixelSizeBuilder<'a, S> 394where 395 S: pixel_size_state::State, 396 S::Width: pixel_size_state::IsUnset, 397{ 398 /// Set the `width` field (required) 399 pub fn width( 400 mut self, 401 value: impl Into<i64>, 402 ) -> PixelSizeBuilder<'a, pixel_size_state::SetWidth<S>> { 403 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 404 PixelSizeBuilder { 405 _phantom_state: ::core::marker::PhantomData, 406 __unsafe_private_named: self.__unsafe_private_named, 407 _phantom: ::core::marker::PhantomData, 408 } 409 } 410} 411 412impl<'a, S> PixelSizeBuilder<'a, S> 413where 414 S: pixel_size_state::State, 415 S::Width: pixel_size_state::IsSet, 416 S::Height: pixel_size_state::IsSet, 417{ 418 /// Build the final struct 419 pub fn build(self) -> PixelSize<'a> { 420 PixelSize { 421 height: self.__unsafe_private_named.0.unwrap(), 422 width: self.__unsafe_private_named.1.unwrap(), 423 extra_data: Default::default(), 424 } 425 } 426 /// Build the final struct with custom extra_data 427 pub fn build_with_data( 428 self, 429 extra_data: std::collections::BTreeMap< 430 jacquard_common::smol_str::SmolStr, 431 jacquard_common::types::value::Data<'a>, 432 >, 433 ) -> PixelSize<'a> { 434 PixelSize { 435 height: self.__unsafe_private_named.0.unwrap(), 436 width: self.__unsafe_private_named.1.unwrap(), 437 extra_data: Some(extra_data), 438 } 439 } 440} 441 442impl<'a> ::jacquard_lexicon::schema::LexiconSchema for PixelSize<'a> { 443 fn nsid() -> &'static str { 444 "sh.weaver.embed.defs" 445 } 446 fn def_name() -> &'static str { 447 "pixelSize" 448 } 449 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 450 lexicon_doc_sh_weaver_embed_defs() 451 } 452 fn validate( 453 &self, 454 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 455 Ok(()) 456 } 457}