atproto blogging
at main 386 lines 15 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: app.bsky.graph.listitem 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// Record representing an account's inclusion on a specific list. The AppView will ignore duplicate listitem records. 9#[jacquard_derive::lexicon] 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic 18)] 19#[serde(rename_all = "camelCase")] 20pub struct Listitem<'a> { 21 pub created_at: jacquard_common::types::string::Datetime, 22 /// Reference (AT-URI) to the list record (app.bsky.graph.list). 23 #[serde(borrow)] 24 pub list: jacquard_common::types::string::AtUri<'a>, 25 /// The account which is included on the list. 26 #[serde(borrow)] 27 pub subject: jacquard_common::types::string::Did<'a>, 28} 29 30pub mod listitem_state { 31 32 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 33 #[allow(unused)] 34 use ::core::marker::PhantomData; 35 mod sealed { 36 pub trait Sealed {} 37 } 38 /// State trait tracking which required fields have been set 39 pub trait State: sealed::Sealed { 40 type Subject; 41 type List; 42 type CreatedAt; 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 Subject = Unset; 49 type List = Unset; 50 type CreatedAt = Unset; 51 } 52 ///State transition - sets the `subject` field to Set 53 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>); 54 impl<S: State> sealed::Sealed for SetSubject<S> {} 55 impl<S: State> State for SetSubject<S> { 56 type Subject = Set<members::subject>; 57 type List = S::List; 58 type CreatedAt = S::CreatedAt; 59 } 60 ///State transition - sets the `list` field to Set 61 pub struct SetList<S: State = Empty>(PhantomData<fn() -> S>); 62 impl<S: State> sealed::Sealed for SetList<S> {} 63 impl<S: State> State for SetList<S> { 64 type Subject = S::Subject; 65 type List = Set<members::list>; 66 type CreatedAt = S::CreatedAt; 67 } 68 ///State transition - sets the `created_at` field to Set 69 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 70 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 71 impl<S: State> State for SetCreatedAt<S> { 72 type Subject = S::Subject; 73 type List = S::List; 74 type CreatedAt = Set<members::created_at>; 75 } 76 /// Marker types for field names 77 #[allow(non_camel_case_types)] 78 pub mod members { 79 ///Marker type for the `subject` field 80 pub struct subject(()); 81 ///Marker type for the `list` field 82 pub struct list(()); 83 ///Marker type for the `created_at` field 84 pub struct created_at(()); 85 } 86} 87 88/// Builder for constructing an instance of this type 89pub struct ListitemBuilder<'a, S: listitem_state::State> { 90 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 91 __unsafe_private_named: ( 92 ::core::option::Option<jacquard_common::types::string::Datetime>, 93 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 94 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 95 ), 96 _phantom: ::core::marker::PhantomData<&'a ()>, 97} 98 99impl<'a> Listitem<'a> { 100 /// Create a new builder for this type 101 pub fn new() -> ListitemBuilder<'a, listitem_state::Empty> { 102 ListitemBuilder::new() 103 } 104} 105 106impl<'a> ListitemBuilder<'a, listitem_state::Empty> { 107 /// Create a new builder with all fields unset 108 pub fn new() -> Self { 109 ListitemBuilder { 110 _phantom_state: ::core::marker::PhantomData, 111 __unsafe_private_named: (None, None, None), 112 _phantom: ::core::marker::PhantomData, 113 } 114 } 115} 116 117impl<'a, S> ListitemBuilder<'a, S> 118where 119 S: listitem_state::State, 120 S::CreatedAt: listitem_state::IsUnset, 121{ 122 /// Set the `createdAt` field (required) 123 pub fn created_at( 124 mut self, 125 value: impl Into<jacquard_common::types::string::Datetime>, 126 ) -> ListitemBuilder<'a, listitem_state::SetCreatedAt<S>> { 127 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 128 ListitemBuilder { 129 _phantom_state: ::core::marker::PhantomData, 130 __unsafe_private_named: self.__unsafe_private_named, 131 _phantom: ::core::marker::PhantomData, 132 } 133 } 134} 135 136impl<'a, S> ListitemBuilder<'a, S> 137where 138 S: listitem_state::State, 139 S::List: listitem_state::IsUnset, 140{ 141 /// Set the `list` field (required) 142 pub fn list( 143 mut self, 144 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 145 ) -> ListitemBuilder<'a, listitem_state::SetList<S>> { 146 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 147 ListitemBuilder { 148 _phantom_state: ::core::marker::PhantomData, 149 __unsafe_private_named: self.__unsafe_private_named, 150 _phantom: ::core::marker::PhantomData, 151 } 152 } 153} 154 155impl<'a, S> ListitemBuilder<'a, S> 156where 157 S: listitem_state::State, 158 S::Subject: listitem_state::IsUnset, 159{ 160 /// Set the `subject` field (required) 161 pub fn subject( 162 mut self, 163 value: impl Into<jacquard_common::types::string::Did<'a>>, 164 ) -> ListitemBuilder<'a, listitem_state::SetSubject<S>> { 165 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 166 ListitemBuilder { 167 _phantom_state: ::core::marker::PhantomData, 168 __unsafe_private_named: self.__unsafe_private_named, 169 _phantom: ::core::marker::PhantomData, 170 } 171 } 172} 173 174impl<'a, S> ListitemBuilder<'a, S> 175where 176 S: listitem_state::State, 177 S::Subject: listitem_state::IsSet, 178 S::List: listitem_state::IsSet, 179 S::CreatedAt: listitem_state::IsSet, 180{ 181 /// Build the final struct 182 pub fn build(self) -> Listitem<'a> { 183 Listitem { 184 created_at: self.__unsafe_private_named.0.unwrap(), 185 list: self.__unsafe_private_named.1.unwrap(), 186 subject: self.__unsafe_private_named.2.unwrap(), 187 extra_data: Default::default(), 188 } 189 } 190 /// Build the final struct with custom extra_data 191 pub fn build_with_data( 192 self, 193 extra_data: std::collections::BTreeMap< 194 jacquard_common::smol_str::SmolStr, 195 jacquard_common::types::value::Data<'a>, 196 >, 197 ) -> Listitem<'a> { 198 Listitem { 199 created_at: self.__unsafe_private_named.0.unwrap(), 200 list: self.__unsafe_private_named.1.unwrap(), 201 subject: self.__unsafe_private_named.2.unwrap(), 202 extra_data: Some(extra_data), 203 } 204 } 205} 206 207impl<'a> Listitem<'a> { 208 pub fn uri( 209 uri: impl Into<jacquard_common::CowStr<'a>>, 210 ) -> Result< 211 jacquard_common::types::uri::RecordUri<'a, ListitemRecord>, 212 jacquard_common::types::uri::UriError, 213 > { 214 jacquard_common::types::uri::RecordUri::try_from_uri( 215 jacquard_common::types::string::AtUri::new_cow(uri.into())?, 216 ) 217 } 218} 219 220/// Typed wrapper for GetRecord response with this collection's record type. 221#[derive( 222 serde::Serialize, 223 serde::Deserialize, 224 Debug, 225 Clone, 226 PartialEq, 227 Eq, 228 jacquard_derive::IntoStatic 229)] 230#[serde(rename_all = "camelCase")] 231pub struct ListitemGetRecordOutput<'a> { 232 #[serde(skip_serializing_if = "std::option::Option::is_none")] 233 #[serde(borrow)] 234 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>, 235 #[serde(borrow)] 236 pub uri: jacquard_common::types::string::AtUri<'a>, 237 #[serde(borrow)] 238 pub value: Listitem<'a>, 239} 240 241impl From<ListitemGetRecordOutput<'_>> for Listitem<'_> { 242 fn from(output: ListitemGetRecordOutput<'_>) -> Self { 243 use jacquard_common::IntoStatic; 244 output.value.into_static() 245 } 246} 247 248impl jacquard_common::types::collection::Collection for Listitem<'_> { 249 const NSID: &'static str = "app.bsky.graph.listitem"; 250 type Record = ListitemRecord; 251} 252 253/// Marker type for deserializing records from this collection. 254#[derive(Debug, serde::Serialize, serde::Deserialize)] 255pub struct ListitemRecord; 256impl jacquard_common::xrpc::XrpcResp for ListitemRecord { 257 const NSID: &'static str = "app.bsky.graph.listitem"; 258 const ENCODING: &'static str = "application/json"; 259 type Output<'de> = ListitemGetRecordOutput<'de>; 260 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 261} 262 263impl jacquard_common::types::collection::Collection for ListitemRecord { 264 const NSID: &'static str = "app.bsky.graph.listitem"; 265 type Record = ListitemRecord; 266} 267 268impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Listitem<'a> { 269 fn nsid() -> &'static str { 270 "app.bsky.graph.listitem" 271 } 272 fn def_name() -> &'static str { 273 "main" 274 } 275 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 276 lexicon_doc_app_bsky_graph_listitem() 277 } 278 fn validate( 279 &self, 280 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 281 Ok(()) 282 } 283} 284 285fn lexicon_doc_app_bsky_graph_listitem() -> ::jacquard_lexicon::lexicon::LexiconDoc< 286 'static, 287> { 288 ::jacquard_lexicon::lexicon::LexiconDoc { 289 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 290 id: ::jacquard_common::CowStr::new_static("app.bsky.graph.listitem"), 291 revision: None, 292 description: None, 293 defs: { 294 let mut map = ::alloc::collections::BTreeMap::new(); 295 map.insert( 296 ::jacquard_common::smol_str::SmolStr::new_static("main"), 297 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { 298 description: Some( 299 ::jacquard_common::CowStr::new_static( 300 "Record representing an account's inclusion on a specific list. The AppView will ignore duplicate listitem records.", 301 ), 302 ), 303 key: Some(::jacquard_common::CowStr::new_static("tid")), 304 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { 305 description: None, 306 required: Some( 307 vec![ 308 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 309 ::jacquard_common::smol_str::SmolStr::new_static("list"), 310 ::jacquard_common::smol_str::SmolStr::new_static("createdAt") 311 ], 312 ), 313 nullable: None, 314 properties: { 315 #[allow(unused_mut)] 316 let mut map = ::alloc::collections::BTreeMap::new(); 317 map.insert( 318 ::jacquard_common::smol_str::SmolStr::new_static( 319 "createdAt", 320 ), 321 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 322 description: None, 323 format: Some( 324 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 325 ), 326 default: None, 327 min_length: None, 328 max_length: None, 329 min_graphemes: None, 330 max_graphemes: None, 331 r#enum: None, 332 r#const: None, 333 known_values: None, 334 }), 335 ); 336 map.insert( 337 ::jacquard_common::smol_str::SmolStr::new_static("list"), 338 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 339 description: Some( 340 ::jacquard_common::CowStr::new_static( 341 "Reference (AT-URI) to the list record (app.bsky.graph.list).", 342 ), 343 ), 344 format: Some( 345 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 346 ), 347 default: None, 348 min_length: None, 349 max_length: None, 350 min_graphemes: None, 351 max_graphemes: None, 352 r#enum: None, 353 r#const: None, 354 known_values: None, 355 }), 356 ); 357 map.insert( 358 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 359 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 360 description: Some( 361 ::jacquard_common::CowStr::new_static( 362 "The account which is included on the list.", 363 ), 364 ), 365 format: Some( 366 ::jacquard_lexicon::lexicon::LexStringFormat::Did, 367 ), 368 default: None, 369 min_length: None, 370 max_length: None, 371 min_graphemes: None, 372 max_graphemes: None, 373 r#enum: None, 374 r#const: None, 375 known_values: None, 376 }), 377 ); 378 map 379 }, 380 }), 381 }), 382 ); 383 map 384 }, 385 } 386}