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