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