atproto blogging
at main 305 lines 11 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: pub.leaflet.blocks.website 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 jacquard_derive::IntoStatic 17)] 18#[serde(rename_all = "camelCase")] 19pub struct Website<'a> { 20 #[serde(skip_serializing_if = "std::option::Option::is_none")] 21 #[serde(borrow)] 22 pub description: std::option::Option<jacquard_common::CowStr<'a>>, 23 #[serde(skip_serializing_if = "std::option::Option::is_none")] 24 #[serde(borrow)] 25 pub preview_image: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>, 26 #[serde(borrow)] 27 pub src: jacquard_common::types::string::Uri<'a>, 28 #[serde(skip_serializing_if = "std::option::Option::is_none")] 29 #[serde(borrow)] 30 pub title: std::option::Option<jacquard_common::CowStr<'a>>, 31} 32 33pub mod website_state { 34 35 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 36 #[allow(unused)] 37 use ::core::marker::PhantomData; 38 mod sealed { 39 pub trait Sealed {} 40 } 41 /// State trait tracking which required fields have been set 42 pub trait State: sealed::Sealed { 43 type Src; 44 } 45 /// Empty state - all required fields are unset 46 pub struct Empty(()); 47 impl sealed::Sealed for Empty {} 48 impl State for Empty { 49 type Src = Unset; 50 } 51 ///State transition - sets the `src` field to Set 52 pub struct SetSrc<S: State = Empty>(PhantomData<fn() -> S>); 53 impl<S: State> sealed::Sealed for SetSrc<S> {} 54 impl<S: State> State for SetSrc<S> { 55 type Src = Set<members::src>; 56 } 57 /// Marker types for field names 58 #[allow(non_camel_case_types)] 59 pub mod members { 60 ///Marker type for the `src` field 61 pub struct src(()); 62 } 63} 64 65/// Builder for constructing an instance of this type 66pub struct WebsiteBuilder<'a, S: website_state::State> { 67 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 68 __unsafe_private_named: ( 69 ::core::option::Option<jacquard_common::CowStr<'a>>, 70 ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>, 71 ::core::option::Option<jacquard_common::types::string::Uri<'a>>, 72 ::core::option::Option<jacquard_common::CowStr<'a>>, 73 ), 74 _phantom: ::core::marker::PhantomData<&'a ()>, 75} 76 77impl<'a> Website<'a> { 78 /// Create a new builder for this type 79 pub fn new() -> WebsiteBuilder<'a, website_state::Empty> { 80 WebsiteBuilder::new() 81 } 82} 83 84impl<'a> WebsiteBuilder<'a, website_state::Empty> { 85 /// Create a new builder with all fields unset 86 pub fn new() -> Self { 87 WebsiteBuilder { 88 _phantom_state: ::core::marker::PhantomData, 89 __unsafe_private_named: (None, None, None, None), 90 _phantom: ::core::marker::PhantomData, 91 } 92 } 93} 94 95impl<'a, S: website_state::State> WebsiteBuilder<'a, S> { 96 /// Set the `description` field (optional) 97 pub fn description( 98 mut self, 99 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 100 ) -> Self { 101 self.__unsafe_private_named.0 = value.into(); 102 self 103 } 104 /// Set the `description` field to an Option value (optional) 105 pub fn maybe_description( 106 mut self, 107 value: Option<jacquard_common::CowStr<'a>>, 108 ) -> Self { 109 self.__unsafe_private_named.0 = value; 110 self 111 } 112} 113 114impl<'a, S: website_state::State> WebsiteBuilder<'a, S> { 115 /// Set the `previewImage` field (optional) 116 pub fn preview_image( 117 mut self, 118 value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>, 119 ) -> Self { 120 self.__unsafe_private_named.1 = value.into(); 121 self 122 } 123 /// Set the `previewImage` field to an Option value (optional) 124 pub fn maybe_preview_image( 125 mut self, 126 value: Option<jacquard_common::types::blob::BlobRef<'a>>, 127 ) -> Self { 128 self.__unsafe_private_named.1 = value; 129 self 130 } 131} 132 133impl<'a, S> WebsiteBuilder<'a, S> 134where 135 S: website_state::State, 136 S::Src: website_state::IsUnset, 137{ 138 /// Set the `src` field (required) 139 pub fn src( 140 mut self, 141 value: impl Into<jacquard_common::types::string::Uri<'a>>, 142 ) -> WebsiteBuilder<'a, website_state::SetSrc<S>> { 143 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 144 WebsiteBuilder { 145 _phantom_state: ::core::marker::PhantomData, 146 __unsafe_private_named: self.__unsafe_private_named, 147 _phantom: ::core::marker::PhantomData, 148 } 149 } 150} 151 152impl<'a, S: website_state::State> WebsiteBuilder<'a, S> { 153 /// Set the `title` field (optional) 154 pub fn title( 155 mut self, 156 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 157 ) -> Self { 158 self.__unsafe_private_named.3 = value.into(); 159 self 160 } 161 /// Set the `title` field to an Option value (optional) 162 pub fn maybe_title(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 163 self.__unsafe_private_named.3 = value; 164 self 165 } 166} 167 168impl<'a, S> WebsiteBuilder<'a, S> 169where 170 S: website_state::State, 171 S::Src: website_state::IsSet, 172{ 173 /// Build the final struct 174 pub fn build(self) -> Website<'a> { 175 Website { 176 description: self.__unsafe_private_named.0, 177 preview_image: self.__unsafe_private_named.1, 178 src: self.__unsafe_private_named.2.unwrap(), 179 title: self.__unsafe_private_named.3, 180 extra_data: Default::default(), 181 } 182 } 183 /// Build the final struct with custom extra_data 184 pub fn build_with_data( 185 self, 186 extra_data: std::collections::BTreeMap< 187 jacquard_common::smol_str::SmolStr, 188 jacquard_common::types::value::Data<'a>, 189 >, 190 ) -> Website<'a> { 191 Website { 192 description: self.__unsafe_private_named.0, 193 preview_image: self.__unsafe_private_named.1, 194 src: self.__unsafe_private_named.2.unwrap(), 195 title: self.__unsafe_private_named.3, 196 extra_data: Some(extra_data), 197 } 198 } 199} 200 201fn lexicon_doc_pub_leaflet_blocks_website() -> ::jacquard_lexicon::lexicon::LexiconDoc< 202 'static, 203> { 204 ::jacquard_lexicon::lexicon::LexiconDoc { 205 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 206 id: ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.website"), 207 revision: None, 208 description: None, 209 defs: { 210 let mut map = ::alloc::collections::BTreeMap::new(); 211 map.insert( 212 ::jacquard_common::smol_str::SmolStr::new_static("main"), 213 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 214 description: None, 215 required: Some( 216 vec![::jacquard_common::smol_str::SmolStr::new_static("src")], 217 ), 218 nullable: None, 219 properties: { 220 #[allow(unused_mut)] 221 let mut map = ::alloc::collections::BTreeMap::new(); 222 map.insert( 223 ::jacquard_common::smol_str::SmolStr::new_static( 224 "description", 225 ), 226 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 227 description: None, 228 format: None, 229 default: None, 230 min_length: None, 231 max_length: None, 232 min_graphemes: None, 233 max_graphemes: None, 234 r#enum: None, 235 r#const: None, 236 known_values: None, 237 }), 238 ); 239 map.insert( 240 ::jacquard_common::smol_str::SmolStr::new_static( 241 "previewImage", 242 ), 243 ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { 244 description: None, 245 accept: None, 246 max_size: None, 247 }), 248 ); 249 map.insert( 250 ::jacquard_common::smol_str::SmolStr::new_static("src"), 251 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 252 description: None, 253 format: Some( 254 ::jacquard_lexicon::lexicon::LexStringFormat::Uri, 255 ), 256 default: None, 257 min_length: None, 258 max_length: None, 259 min_graphemes: None, 260 max_graphemes: None, 261 r#enum: None, 262 r#const: None, 263 known_values: None, 264 }), 265 ); 266 map.insert( 267 ::jacquard_common::smol_str::SmolStr::new_static("title"), 268 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 269 description: None, 270 format: None, 271 default: None, 272 min_length: None, 273 max_length: None, 274 min_graphemes: None, 275 max_graphemes: None, 276 r#enum: None, 277 r#const: None, 278 known_values: None, 279 }), 280 ); 281 map 282 }, 283 }), 284 ); 285 map 286 }, 287 } 288} 289 290impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Website<'a> { 291 fn nsid() -> &'static str { 292 "pub.leaflet.blocks.website" 293 } 294 fn def_name() -> &'static str { 295 "main" 296 } 297 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 298 lexicon_doc_pub_leaflet_blocks_website() 299 } 300 fn validate( 301 &self, 302 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 303 Ok(()) 304 } 305}