atproto blogging
at main 376 lines 14 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.collab.accept 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// Acceptance of a collaboration invite. Completes the two-way agreement. 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 Accept<'a> { 21 pub created_at: jacquard_common::types::string::Datetime, 22 /// Reference to the invite record being accepted. 23 #[serde(borrow)] 24 pub invite: crate::com_atproto::repo::strong_ref::StrongRef<'a>, 25 /// URI of the resource (denormalized for easier querying). 26 #[serde(borrow)] 27 pub resource: jacquard_common::types::string::AtUri<'a>, 28} 29 30pub mod accept_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 Resource; 41 type CreatedAt; 42 type Invite; 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 Resource = Unset; 49 type CreatedAt = Unset; 50 type Invite = Unset; 51 } 52 ///State transition - sets the `resource` field to Set 53 pub struct SetResource<S: State = Empty>(PhantomData<fn() -> S>); 54 impl<S: State> sealed::Sealed for SetResource<S> {} 55 impl<S: State> State for SetResource<S> { 56 type Resource = Set<members::resource>; 57 type CreatedAt = S::CreatedAt; 58 type Invite = S::Invite; 59 } 60 ///State transition - sets the `created_at` field to Set 61 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 62 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 63 impl<S: State> State for SetCreatedAt<S> { 64 type Resource = S::Resource; 65 type CreatedAt = Set<members::created_at>; 66 type Invite = S::Invite; 67 } 68 ///State transition - sets the `invite` field to Set 69 pub struct SetInvite<S: State = Empty>(PhantomData<fn() -> S>); 70 impl<S: State> sealed::Sealed for SetInvite<S> {} 71 impl<S: State> State for SetInvite<S> { 72 type Resource = S::Resource; 73 type CreatedAt = S::CreatedAt; 74 type Invite = Set<members::invite>; 75 } 76 /// Marker types for field names 77 #[allow(non_camel_case_types)] 78 pub mod members { 79 ///Marker type for the `resource` field 80 pub struct resource(()); 81 ///Marker type for the `created_at` field 82 pub struct created_at(()); 83 ///Marker type for the `invite` field 84 pub struct invite(()); 85 } 86} 87 88/// Builder for constructing an instance of this type 89pub struct AcceptBuilder<'a, S: accept_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<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 94 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 95 ), 96 _phantom: ::core::marker::PhantomData<&'a ()>, 97} 98 99impl<'a> Accept<'a> { 100 /// Create a new builder for this type 101 pub fn new() -> AcceptBuilder<'a, accept_state::Empty> { 102 AcceptBuilder::new() 103 } 104} 105 106impl<'a> AcceptBuilder<'a, accept_state::Empty> { 107 /// Create a new builder with all fields unset 108 pub fn new() -> Self { 109 AcceptBuilder { 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> AcceptBuilder<'a, S> 118where 119 S: accept_state::State, 120 S::CreatedAt: accept_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 ) -> AcceptBuilder<'a, accept_state::SetCreatedAt<S>> { 127 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 128 AcceptBuilder { 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> AcceptBuilder<'a, S> 137where 138 S: accept_state::State, 139 S::Invite: accept_state::IsUnset, 140{ 141 /// Set the `invite` field (required) 142 pub fn invite( 143 mut self, 144 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 145 ) -> AcceptBuilder<'a, accept_state::SetInvite<S>> { 146 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 147 AcceptBuilder { 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> AcceptBuilder<'a, S> 156where 157 S: accept_state::State, 158 S::Resource: accept_state::IsUnset, 159{ 160 /// Set the `resource` field (required) 161 pub fn resource( 162 mut self, 163 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 164 ) -> AcceptBuilder<'a, accept_state::SetResource<S>> { 165 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 166 AcceptBuilder { 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> AcceptBuilder<'a, S> 175where 176 S: accept_state::State, 177 S::Resource: accept_state::IsSet, 178 S::CreatedAt: accept_state::IsSet, 179 S::Invite: accept_state::IsSet, 180{ 181 /// Build the final struct 182 pub fn build(self) -> Accept<'a> { 183 Accept { 184 created_at: self.__unsafe_private_named.0.unwrap(), 185 invite: self.__unsafe_private_named.1.unwrap(), 186 resource: 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 ) -> Accept<'a> { 198 Accept { 199 created_at: self.__unsafe_private_named.0.unwrap(), 200 invite: self.__unsafe_private_named.1.unwrap(), 201 resource: self.__unsafe_private_named.2.unwrap(), 202 extra_data: Some(extra_data), 203 } 204 } 205} 206 207impl<'a> Accept<'a> { 208 pub fn uri( 209 uri: impl Into<jacquard_common::CowStr<'a>>, 210 ) -> Result< 211 jacquard_common::types::uri::RecordUri<'a, AcceptRecord>, 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 AcceptGetRecordOutput<'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: Accept<'a>, 239} 240 241impl From<AcceptGetRecordOutput<'_>> for Accept<'_> { 242 fn from(output: AcceptGetRecordOutput<'_>) -> Self { 243 use jacquard_common::IntoStatic; 244 output.value.into_static() 245 } 246} 247 248impl jacquard_common::types::collection::Collection for Accept<'_> { 249 const NSID: &'static str = "sh.weaver.collab.accept"; 250 type Record = AcceptRecord; 251} 252 253/// Marker type for deserializing records from this collection. 254#[derive(Debug, serde::Serialize, serde::Deserialize)] 255pub struct AcceptRecord; 256impl jacquard_common::xrpc::XrpcResp for AcceptRecord { 257 const NSID: &'static str = "sh.weaver.collab.accept"; 258 const ENCODING: &'static str = "application/json"; 259 type Output<'de> = AcceptGetRecordOutput<'de>; 260 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 261} 262 263impl jacquard_common::types::collection::Collection for AcceptRecord { 264 const NSID: &'static str = "sh.weaver.collab.accept"; 265 type Record = AcceptRecord; 266} 267 268impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Accept<'a> { 269 fn nsid() -> &'static str { 270 "sh.weaver.collab.accept" 271 } 272 fn def_name() -> &'static str { 273 "main" 274 } 275 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 276 lexicon_doc_sh_weaver_collab_accept() 277 } 278 fn validate( 279 &self, 280 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 281 Ok(()) 282 } 283} 284 285fn lexicon_doc_sh_weaver_collab_accept() -> ::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("sh.weaver.collab.accept"), 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 "Acceptance of a collaboration invite. Completes the two-way agreement.", 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("invite"), 309 ::jacquard_common::smol_str::SmolStr::new_static("resource"), 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("invite"), 338 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 339 description: None, 340 r#ref: ::jacquard_common::CowStr::new_static( 341 "com.atproto.repo.strongRef", 342 ), 343 }), 344 ); 345 map.insert( 346 ::jacquard_common::smol_str::SmolStr::new_static( 347 "resource", 348 ), 349 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 350 description: Some( 351 ::jacquard_common::CowStr::new_static( 352 "URI of the resource (denormalized for easier querying).", 353 ), 354 ), 355 format: Some( 356 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 357 ), 358 default: None, 359 min_length: None, 360 max_length: None, 361 min_graphemes: None, 362 max_graphemes: None, 363 r#enum: None, 364 r#const: None, 365 known_values: None, 366 }), 367 ); 368 map 369 }, 370 }), 371 }), 372 ); 373 map 374 }, 375 } 376}