atproto blogging
at main 317 lines 11 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.deckbelcher.social.like 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// Record declaring a 'like' of a piece of content (decklist, reply, etc). 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 Like<'a> { 21 /// Timestamp when the like was created. 22 pub created_at: jacquard_common::types::string::Datetime, 23 /// Reference to the content being liked. 24 #[serde(borrow)] 25 pub subject: crate::com_atproto::repo::strong_ref::StrongRef<'a>, 26} 27 28pub mod like_state { 29 30 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 31 #[allow(unused)] 32 use ::core::marker::PhantomData; 33 mod sealed { 34 pub trait Sealed {} 35 } 36 /// State trait tracking which required fields have been set 37 pub trait State: sealed::Sealed { 38 type Subject; 39 type CreatedAt; 40 } 41 /// Empty state - all required fields are unset 42 pub struct Empty(()); 43 impl sealed::Sealed for Empty {} 44 impl State for Empty { 45 type Subject = Unset; 46 type CreatedAt = Unset; 47 } 48 ///State transition - sets the `subject` field to Set 49 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>); 50 impl<S: State> sealed::Sealed for SetSubject<S> {} 51 impl<S: State> State for SetSubject<S> { 52 type Subject = Set<members::subject>; 53 type CreatedAt = S::CreatedAt; 54 } 55 ///State transition - sets the `created_at` field to Set 56 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 57 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 58 impl<S: State> State for SetCreatedAt<S> { 59 type Subject = S::Subject; 60 type CreatedAt = Set<members::created_at>; 61 } 62 /// Marker types for field names 63 #[allow(non_camel_case_types)] 64 pub mod members { 65 ///Marker type for the `subject` field 66 pub struct subject(()); 67 ///Marker type for the `created_at` field 68 pub struct created_at(()); 69 } 70} 71 72/// Builder for constructing an instance of this type 73pub struct LikeBuilder<'a, S: like_state::State> { 74 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 75 __unsafe_private_named: ( 76 ::core::option::Option<jacquard_common::types::string::Datetime>, 77 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 78 ), 79 _phantom: ::core::marker::PhantomData<&'a ()>, 80} 81 82impl<'a> Like<'a> { 83 /// Create a new builder for this type 84 pub fn new() -> LikeBuilder<'a, like_state::Empty> { 85 LikeBuilder::new() 86 } 87} 88 89impl<'a> LikeBuilder<'a, like_state::Empty> { 90 /// Create a new builder with all fields unset 91 pub fn new() -> Self { 92 LikeBuilder { 93 _phantom_state: ::core::marker::PhantomData, 94 __unsafe_private_named: (None, None), 95 _phantom: ::core::marker::PhantomData, 96 } 97 } 98} 99 100impl<'a, S> LikeBuilder<'a, S> 101where 102 S: like_state::State, 103 S::CreatedAt: like_state::IsUnset, 104{ 105 /// Set the `createdAt` field (required) 106 pub fn created_at( 107 mut self, 108 value: impl Into<jacquard_common::types::string::Datetime>, 109 ) -> LikeBuilder<'a, like_state::SetCreatedAt<S>> { 110 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 111 LikeBuilder { 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> LikeBuilder<'a, S> 120where 121 S: like_state::State, 122 S::Subject: like_state::IsUnset, 123{ 124 /// Set the `subject` field (required) 125 pub fn subject( 126 mut self, 127 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 128 ) -> LikeBuilder<'a, like_state::SetSubject<S>> { 129 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 130 LikeBuilder { 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> LikeBuilder<'a, S> 139where 140 S: like_state::State, 141 S::Subject: like_state::IsSet, 142 S::CreatedAt: like_state::IsSet, 143{ 144 /// Build the final struct 145 pub fn build(self) -> Like<'a> { 146 Like { 147 created_at: self.__unsafe_private_named.0.unwrap(), 148 subject: 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 ) -> Like<'a> { 160 Like { 161 created_at: self.__unsafe_private_named.0.unwrap(), 162 subject: self.__unsafe_private_named.1.unwrap(), 163 extra_data: Some(extra_data), 164 } 165 } 166} 167 168impl<'a> Like<'a> { 169 pub fn uri( 170 uri: impl Into<jacquard_common::CowStr<'a>>, 171 ) -> Result< 172 jacquard_common::types::uri::RecordUri<'a, LikeRecord>, 173 jacquard_common::types::uri::UriError, 174 > { 175 jacquard_common::types::uri::RecordUri::try_from_uri( 176 jacquard_common::types::string::AtUri::new_cow(uri.into())?, 177 ) 178 } 179} 180 181/// Typed wrapper for GetRecord response with this collection's record type. 182#[derive( 183 serde::Serialize, 184 serde::Deserialize, 185 Debug, 186 Clone, 187 PartialEq, 188 Eq, 189 jacquard_derive::IntoStatic 190)] 191#[serde(rename_all = "camelCase")] 192pub struct LikeGetRecordOutput<'a> { 193 #[serde(skip_serializing_if = "std::option::Option::is_none")] 194 #[serde(borrow)] 195 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>, 196 #[serde(borrow)] 197 pub uri: jacquard_common::types::string::AtUri<'a>, 198 #[serde(borrow)] 199 pub value: Like<'a>, 200} 201 202impl From<LikeGetRecordOutput<'_>> for Like<'_> { 203 fn from(output: LikeGetRecordOutput<'_>) -> Self { 204 use jacquard_common::IntoStatic; 205 output.value.into_static() 206 } 207} 208 209impl jacquard_common::types::collection::Collection for Like<'_> { 210 const NSID: &'static str = "com.deckbelcher.social.like"; 211 type Record = LikeRecord; 212} 213 214/// Marker type for deserializing records from this collection. 215#[derive(Debug, serde::Serialize, serde::Deserialize)] 216pub struct LikeRecord; 217impl jacquard_common::xrpc::XrpcResp for LikeRecord { 218 const NSID: &'static str = "com.deckbelcher.social.like"; 219 const ENCODING: &'static str = "application/json"; 220 type Output<'de> = LikeGetRecordOutput<'de>; 221 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 222} 223 224impl jacquard_common::types::collection::Collection for LikeRecord { 225 const NSID: &'static str = "com.deckbelcher.social.like"; 226 type Record = LikeRecord; 227} 228 229impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Like<'a> { 230 fn nsid() -> &'static str { 231 "com.deckbelcher.social.like" 232 } 233 fn def_name() -> &'static str { 234 "main" 235 } 236 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 237 lexicon_doc_com_deckbelcher_social_like() 238 } 239 fn validate( 240 &self, 241 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 242 Ok(()) 243 } 244} 245 246fn lexicon_doc_com_deckbelcher_social_like() -> ::jacquard_lexicon::lexicon::LexiconDoc< 247 'static, 248> { 249 ::jacquard_lexicon::lexicon::LexiconDoc { 250 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 251 id: ::jacquard_common::CowStr::new_static("com.deckbelcher.social.like"), 252 revision: None, 253 description: None, 254 defs: { 255 let mut map = ::alloc::collections::BTreeMap::new(); 256 map.insert( 257 ::jacquard_common::smol_str::SmolStr::new_static("main"), 258 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { 259 description: Some( 260 ::jacquard_common::CowStr::new_static( 261 "Record declaring a 'like' of a piece of content (decklist, reply, etc).", 262 ), 263 ), 264 key: Some(::jacquard_common::CowStr::new_static("tid")), 265 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { 266 description: None, 267 required: Some( 268 vec![ 269 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 270 ::jacquard_common::smol_str::SmolStr::new_static("createdAt") 271 ], 272 ), 273 nullable: None, 274 properties: { 275 #[allow(unused_mut)] 276 let mut map = ::alloc::collections::BTreeMap::new(); 277 map.insert( 278 ::jacquard_common::smol_str::SmolStr::new_static( 279 "createdAt", 280 ), 281 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 282 description: Some( 283 ::jacquard_common::CowStr::new_static( 284 "Timestamp when the like was created.", 285 ), 286 ), 287 format: Some( 288 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 289 ), 290 default: None, 291 min_length: None, 292 max_length: None, 293 min_graphemes: None, 294 max_graphemes: None, 295 r#enum: None, 296 r#const: None, 297 known_values: None, 298 }), 299 ); 300 map.insert( 301 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 302 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 303 description: None, 304 r#ref: ::jacquard_common::CowStr::new_static( 305 "com.atproto.repo.strongRef", 306 ), 307 }), 308 ); 309 map 310 }, 311 }), 312 }), 313 ); 314 map 315 }, 316 } 317}