atproto blogging
at main 287 lines 9.6 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.domain.generateDocument 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[derive( 9 serde::Serialize, 10 serde::Deserialize, 11 Debug, 12 Clone, 13 PartialEq, 14 Eq, 15 jacquard_derive::IntoStatic 16)] 17#[serde(rename_all = "camelCase")] 18pub struct GenerateDocument<'a> { 19 #[serde(borrow)] 20 pub entry: jacquard_common::types::string::AtUri<'a>, 21 #[serde(skip_serializing_if = "std::option::Option::is_none")] 22 #[serde(borrow)] 23 pub entry_record: std::option::Option<jacquard_common::types::value::Data<'a>>, 24 #[serde(skip_serializing_if = "std::option::Option::is_none")] 25 #[serde(borrow)] 26 pub path: std::option::Option<jacquard_common::CowStr<'a>>, 27 #[serde(borrow)] 28 pub publication: jacquard_common::types::string::AtUri<'a>, 29} 30 31pub mod generate_document_state { 32 33 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 34 #[allow(unused)] 35 use ::core::marker::PhantomData; 36 mod sealed { 37 pub trait Sealed {} 38 } 39 /// State trait tracking which required fields have been set 40 pub trait State: sealed::Sealed { 41 type Entry; 42 type Publication; 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 Entry = Unset; 49 type Publication = Unset; 50 } 51 ///State transition - sets the `entry` field to Set 52 pub struct SetEntry<S: State = Empty>(PhantomData<fn() -> S>); 53 impl<S: State> sealed::Sealed for SetEntry<S> {} 54 impl<S: State> State for SetEntry<S> { 55 type Entry = Set<members::entry>; 56 type Publication = S::Publication; 57 } 58 ///State transition - sets the `publication` field to Set 59 pub struct SetPublication<S: State = Empty>(PhantomData<fn() -> S>); 60 impl<S: State> sealed::Sealed for SetPublication<S> {} 61 impl<S: State> State for SetPublication<S> { 62 type Entry = S::Entry; 63 type Publication = Set<members::publication>; 64 } 65 /// Marker types for field names 66 #[allow(non_camel_case_types)] 67 pub mod members { 68 ///Marker type for the `entry` field 69 pub struct entry(()); 70 ///Marker type for the `publication` field 71 pub struct publication(()); 72 } 73} 74 75/// Builder for constructing an instance of this type 76pub struct GenerateDocumentBuilder<'a, S: generate_document_state::State> { 77 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 78 __unsafe_private_named: ( 79 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 80 ::core::option::Option<jacquard_common::types::value::Data<'a>>, 81 ::core::option::Option<jacquard_common::CowStr<'a>>, 82 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 83 ), 84 _phantom: ::core::marker::PhantomData<&'a ()>, 85} 86 87impl<'a> GenerateDocument<'a> { 88 /// Create a new builder for this type 89 pub fn new() -> GenerateDocumentBuilder<'a, generate_document_state::Empty> { 90 GenerateDocumentBuilder::new() 91 } 92} 93 94impl<'a> GenerateDocumentBuilder<'a, generate_document_state::Empty> { 95 /// Create a new builder with all fields unset 96 pub fn new() -> Self { 97 GenerateDocumentBuilder { 98 _phantom_state: ::core::marker::PhantomData, 99 __unsafe_private_named: (None, None, None, None), 100 _phantom: ::core::marker::PhantomData, 101 } 102 } 103} 104 105impl<'a, S> GenerateDocumentBuilder<'a, S> 106where 107 S: generate_document_state::State, 108 S::Entry: generate_document_state::IsUnset, 109{ 110 /// Set the `entry` field (required) 111 pub fn entry( 112 mut self, 113 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 114 ) -> GenerateDocumentBuilder<'a, generate_document_state::SetEntry<S>> { 115 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 116 GenerateDocumentBuilder { 117 _phantom_state: ::core::marker::PhantomData, 118 __unsafe_private_named: self.__unsafe_private_named, 119 _phantom: ::core::marker::PhantomData, 120 } 121 } 122} 123 124impl<'a, S: generate_document_state::State> GenerateDocumentBuilder<'a, S> { 125 /// Set the `entryRecord` field (optional) 126 pub fn entry_record( 127 mut self, 128 value: impl Into<Option<jacquard_common::types::value::Data<'a>>>, 129 ) -> Self { 130 self.__unsafe_private_named.1 = value.into(); 131 self 132 } 133 /// Set the `entryRecord` field to an Option value (optional) 134 pub fn maybe_entry_record( 135 mut self, 136 value: Option<jacquard_common::types::value::Data<'a>>, 137 ) -> Self { 138 self.__unsafe_private_named.1 = value; 139 self 140 } 141} 142 143impl<'a, S: generate_document_state::State> GenerateDocumentBuilder<'a, S> { 144 /// Set the `path` field (optional) 145 pub fn path( 146 mut self, 147 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 148 ) -> Self { 149 self.__unsafe_private_named.2 = value.into(); 150 self 151 } 152 /// Set the `path` field to an Option value (optional) 153 pub fn maybe_path(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 154 self.__unsafe_private_named.2 = value; 155 self 156 } 157} 158 159impl<'a, S> GenerateDocumentBuilder<'a, S> 160where 161 S: generate_document_state::State, 162 S::Publication: generate_document_state::IsUnset, 163{ 164 /// Set the `publication` field (required) 165 pub fn publication( 166 mut self, 167 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 168 ) -> GenerateDocumentBuilder<'a, generate_document_state::SetPublication<S>> { 169 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 170 GenerateDocumentBuilder { 171 _phantom_state: ::core::marker::PhantomData, 172 __unsafe_private_named: self.__unsafe_private_named, 173 _phantom: ::core::marker::PhantomData, 174 } 175 } 176} 177 178impl<'a, S> GenerateDocumentBuilder<'a, S> 179where 180 S: generate_document_state::State, 181 S::Entry: generate_document_state::IsSet, 182 S::Publication: generate_document_state::IsSet, 183{ 184 /// Build the final struct 185 pub fn build(self) -> GenerateDocument<'a> { 186 GenerateDocument { 187 entry: self.__unsafe_private_named.0.unwrap(), 188 entry_record: self.__unsafe_private_named.1, 189 path: self.__unsafe_private_named.2, 190 publication: self.__unsafe_private_named.3.unwrap(), 191 } 192 } 193} 194 195#[jacquard_derive::lexicon] 196#[derive( 197 serde::Serialize, 198 serde::Deserialize, 199 Debug, 200 Clone, 201 PartialEq, 202 Eq, 203 jacquard_derive::IntoStatic 204)] 205#[serde(rename_all = "camelCase")] 206pub struct GenerateDocumentOutput<'a> { 207 #[serde(borrow)] 208 pub record: crate::site_standard::document::Document<'a>, 209} 210 211#[jacquard_derive::open_union] 212#[derive( 213 serde::Serialize, 214 serde::Deserialize, 215 Debug, 216 Clone, 217 PartialEq, 218 Eq, 219 thiserror::Error, 220 miette::Diagnostic, 221 jacquard_derive::IntoStatic 222)] 223#[serde(tag = "error", content = "message")] 224#[serde(bound(deserialize = "'de: 'a"))] 225pub enum GenerateDocumentError<'a> { 226 #[serde(rename = "PublicationNotFound")] 227 PublicationNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 228 #[serde(rename = "EntryNotFound")] 229 EntryNotFound(std::option::Option<jacquard_common::CowStr<'a>>), 230 #[serde(rename = "NotebookNotLinked")] 231 NotebookNotLinked(std::option::Option<jacquard_common::CowStr<'a>>), 232} 233 234impl core::fmt::Display for GenerateDocumentError<'_> { 235 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 236 match self { 237 Self::PublicationNotFound(msg) => { 238 write!(f, "PublicationNotFound")?; 239 if let Some(msg) = msg { 240 write!(f, ": {}", msg)?; 241 } 242 Ok(()) 243 } 244 Self::EntryNotFound(msg) => { 245 write!(f, "EntryNotFound")?; 246 if let Some(msg) = msg { 247 write!(f, ": {}", msg)?; 248 } 249 Ok(()) 250 } 251 Self::NotebookNotLinked(msg) => { 252 write!(f, "NotebookNotLinked")?; 253 if let Some(msg) = msg { 254 write!(f, ": {}", msg)?; 255 } 256 Ok(()) 257 } 258 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 259 } 260 } 261} 262 263/// Response type for 264///sh.weaver.domain.generateDocument 265pub struct GenerateDocumentResponse; 266impl jacquard_common::xrpc::XrpcResp for GenerateDocumentResponse { 267 const NSID: &'static str = "sh.weaver.domain.generateDocument"; 268 const ENCODING: &'static str = "application/json"; 269 type Output<'de> = GenerateDocumentOutput<'de>; 270 type Err<'de> = GenerateDocumentError<'de>; 271} 272 273impl<'a> jacquard_common::xrpc::XrpcRequest for GenerateDocument<'a> { 274 const NSID: &'static str = "sh.weaver.domain.generateDocument"; 275 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 276 type Response = GenerateDocumentResponse; 277} 278 279/// Endpoint type for 280///sh.weaver.domain.generateDocument 281pub struct GenerateDocumentRequest; 282impl jacquard_common::xrpc::XrpcEndpoint for GenerateDocumentRequest { 283 const PATH: &'static str = "/xrpc/sh.weaver.domain.generateDocument"; 284 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 285 type Request<'de> = GenerateDocument<'de>; 286 type Response = GenerateDocumentResponse; 287}