atproto blogging
at main 266 lines 9.2 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: app.bsky.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; 11pub mod record_with_media; 12pub mod video; 13 14/// width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. 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 AspectRatio<'a> { 27 pub height: i64, 28 pub width: i64, 29} 30 31pub mod aspect_ratio_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 Height; 42 type Width; 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 Height = Unset; 49 type Width = Unset; 50 } 51 ///State transition - sets the `height` field to Set 52 pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>); 53 impl<S: State> sealed::Sealed for SetHeight<S> {} 54 impl<S: State> State for SetHeight<S> { 55 type Height = Set<members::height>; 56 type Width = S::Width; 57 } 58 ///State transition - sets the `width` field to Set 59 pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>); 60 impl<S: State> sealed::Sealed for SetWidth<S> {} 61 impl<S: State> State for SetWidth<S> { 62 type Height = S::Height; 63 type Width = Set<members::width>; 64 } 65 /// Marker types for field names 66 #[allow(non_camel_case_types)] 67 pub mod members { 68 ///Marker type for the `height` field 69 pub struct height(()); 70 ///Marker type for the `width` field 71 pub struct width(()); 72 } 73} 74 75/// Builder for constructing an instance of this type 76pub struct AspectRatioBuilder<'a, S: aspect_ratio_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> AspectRatio<'a> { 83 /// Create a new builder for this type 84 pub fn new() -> AspectRatioBuilder<'a, aspect_ratio_state::Empty> { 85 AspectRatioBuilder::new() 86 } 87} 88 89impl<'a> AspectRatioBuilder<'a, aspect_ratio_state::Empty> { 90 /// Create a new builder with all fields unset 91 pub fn new() -> Self { 92 AspectRatioBuilder { 93 _phantom_state: ::core::marker::PhantomData, 94 __unsafe_private_named: (None, None), 95 _phantom: ::core::marker::PhantomData, 96 } 97 } 98} 99 100impl<'a, S> AspectRatioBuilder<'a, S> 101where 102 S: aspect_ratio_state::State, 103 S::Height: aspect_ratio_state::IsUnset, 104{ 105 /// Set the `height` field (required) 106 pub fn height( 107 mut self, 108 value: impl Into<i64>, 109 ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetHeight<S>> { 110 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 111 AspectRatioBuilder { 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> AspectRatioBuilder<'a, S> 120where 121 S: aspect_ratio_state::State, 122 S::Width: aspect_ratio_state::IsUnset, 123{ 124 /// Set the `width` field (required) 125 pub fn width( 126 mut self, 127 value: impl Into<i64>, 128 ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetWidth<S>> { 129 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 130 AspectRatioBuilder { 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> AspectRatioBuilder<'a, S> 139where 140 S: aspect_ratio_state::State, 141 S::Height: aspect_ratio_state::IsSet, 142 S::Width: aspect_ratio_state::IsSet, 143{ 144 /// Build the final struct 145 pub fn build(self) -> AspectRatio<'a> { 146 AspectRatio { 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 ) -> AspectRatio<'a> { 160 AspectRatio { 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_app_bsky_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("app.bsky.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("aspectRatio"), 180 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 181 description: Some( 182 ::jacquard_common::CowStr::new_static( 183 "width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.", 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: Some(1i64), 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: Some(1i64), 213 maximum: None, 214 r#enum: None, 215 r#const: None, 216 }), 217 ); 218 map 219 }, 220 }), 221 ); 222 map 223 }, 224 } 225} 226 227impl<'a> ::jacquard_lexicon::schema::LexiconSchema for AspectRatio<'a> { 228 fn nsid() -> &'static str { 229 "app.bsky.embed.defs" 230 } 231 fn def_name() -> &'static str { 232 "aspectRatio" 233 } 234 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 235 lexicon_doc_app_bsky_embed_defs() 236 } 237 fn validate( 238 &self, 239 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 240 { 241 let value = &self.height; 242 if *value < 1i64 { 243 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 244 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 245 "height", 246 ), 247 min: 1i64, 248 actual: *value, 249 }); 250 } 251 } 252 { 253 let value = &self.width; 254 if *value < 1i64 { 255 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 256 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 257 "width", 258 ), 259 min: 1i64, 260 actual: *value, 261 }); 262 } 263 } 264 Ok(()) 265 } 266}