atproto blogging
at main 303 lines 10 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.edit.root 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// The starting point for edit history on a notebook. 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 Root<'a> { 21 #[serde(borrow)] 22 pub doc: crate::sh_weaver::edit::DocRef<'a>, 23 #[serde(borrow)] 24 pub snapshot: jacquard_common::types::blob::BlobRef<'a>, 25} 26 27pub mod root_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 Doc; 38 type Snapshot; 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 Doc = Unset; 45 type Snapshot = Unset; 46 } 47 ///State transition - sets the `doc` field to Set 48 pub struct SetDoc<S: State = Empty>(PhantomData<fn() -> S>); 49 impl<S: State> sealed::Sealed for SetDoc<S> {} 50 impl<S: State> State for SetDoc<S> { 51 type Doc = Set<members::doc>; 52 type Snapshot = S::Snapshot; 53 } 54 ///State transition - sets the `snapshot` field to Set 55 pub struct SetSnapshot<S: State = Empty>(PhantomData<fn() -> S>); 56 impl<S: State> sealed::Sealed for SetSnapshot<S> {} 57 impl<S: State> State for SetSnapshot<S> { 58 type Doc = S::Doc; 59 type Snapshot = Set<members::snapshot>; 60 } 61 /// Marker types for field names 62 #[allow(non_camel_case_types)] 63 pub mod members { 64 ///Marker type for the `doc` field 65 pub struct doc(()); 66 ///Marker type for the `snapshot` field 67 pub struct snapshot(()); 68 } 69} 70 71/// Builder for constructing an instance of this type 72pub struct RootBuilder<'a, S: root_state::State> { 73 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 74 __unsafe_private_named: ( 75 ::core::option::Option<crate::sh_weaver::edit::DocRef<'a>>, 76 ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>, 77 ), 78 _phantom: ::core::marker::PhantomData<&'a ()>, 79} 80 81impl<'a> Root<'a> { 82 /// Create a new builder for this type 83 pub fn new() -> RootBuilder<'a, root_state::Empty> { 84 RootBuilder::new() 85 } 86} 87 88impl<'a> RootBuilder<'a, root_state::Empty> { 89 /// Create a new builder with all fields unset 90 pub fn new() -> Self { 91 RootBuilder { 92 _phantom_state: ::core::marker::PhantomData, 93 __unsafe_private_named: (None, None), 94 _phantom: ::core::marker::PhantomData, 95 } 96 } 97} 98 99impl<'a, S> RootBuilder<'a, S> 100where 101 S: root_state::State, 102 S::Doc: root_state::IsUnset, 103{ 104 /// Set the `doc` field (required) 105 pub fn doc( 106 mut self, 107 value: impl Into<crate::sh_weaver::edit::DocRef<'a>>, 108 ) -> RootBuilder<'a, root_state::SetDoc<S>> { 109 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 110 RootBuilder { 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> RootBuilder<'a, S> 119where 120 S: root_state::State, 121 S::Snapshot: root_state::IsUnset, 122{ 123 /// Set the `snapshot` field (required) 124 pub fn snapshot( 125 mut self, 126 value: impl Into<jacquard_common::types::blob::BlobRef<'a>>, 127 ) -> RootBuilder<'a, root_state::SetSnapshot<S>> { 128 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 129 RootBuilder { 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> RootBuilder<'a, S> 138where 139 S: root_state::State, 140 S::Doc: root_state::IsSet, 141 S::Snapshot: root_state::IsSet, 142{ 143 /// Build the final struct 144 pub fn build(self) -> Root<'a> { 145 Root { 146 doc: self.__unsafe_private_named.0.unwrap(), 147 snapshot: 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 ) -> Root<'a> { 159 Root { 160 doc: self.__unsafe_private_named.0.unwrap(), 161 snapshot: self.__unsafe_private_named.1.unwrap(), 162 extra_data: Some(extra_data), 163 } 164 } 165} 166 167impl<'a> Root<'a> { 168 pub fn uri( 169 uri: impl Into<jacquard_common::CowStr<'a>>, 170 ) -> Result< 171 jacquard_common::types::uri::RecordUri<'a, RootRecord>, 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 RootGetRecordOutput<'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: Root<'a>, 199} 200 201impl From<RootGetRecordOutput<'_>> for Root<'_> { 202 fn from(output: RootGetRecordOutput<'_>) -> Self { 203 use jacquard_common::IntoStatic; 204 output.value.into_static() 205 } 206} 207 208impl jacquard_common::types::collection::Collection for Root<'_> { 209 const NSID: &'static str = "sh.weaver.edit.root"; 210 type Record = RootRecord; 211} 212 213/// Marker type for deserializing records from this collection. 214#[derive(Debug, serde::Serialize, serde::Deserialize)] 215pub struct RootRecord; 216impl jacquard_common::xrpc::XrpcResp for RootRecord { 217 const NSID: &'static str = "sh.weaver.edit.root"; 218 const ENCODING: &'static str = "application/json"; 219 type Output<'de> = RootGetRecordOutput<'de>; 220 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 221} 222 223impl jacquard_common::types::collection::Collection for RootRecord { 224 const NSID: &'static str = "sh.weaver.edit.root"; 225 type Record = RootRecord; 226} 227 228impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Root<'a> { 229 fn nsid() -> &'static str { 230 "sh.weaver.edit.root" 231 } 232 fn def_name() -> &'static str { 233 "main" 234 } 235 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 236 lexicon_doc_sh_weaver_edit_root() 237 } 238 fn validate( 239 &self, 240 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 241 Ok(()) 242 } 243} 244 245fn lexicon_doc_sh_weaver_edit_root() -> ::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.edit.root"), 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 "The starting point for edit history on a notebook.", 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("doc"), 269 ::jacquard_common::smol_str::SmolStr::new_static("snapshot") 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("doc"), 278 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 279 description: None, 280 r#ref: ::jacquard_common::CowStr::new_static( 281 "sh.weaver.edit.defs#docRef", 282 ), 283 }), 284 ); 285 map.insert( 286 ::jacquard_common::smol_str::SmolStr::new_static( 287 "snapshot", 288 ), 289 ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { 290 description: None, 291 accept: None, 292 max_size: None, 293 }), 294 ); 295 map 296 }, 297 }), 298 }), 299 ); 300 map 301 }, 302 } 303}