// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.domain.generateDocument // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct GenerateDocument<'a> { #[serde(borrow)] pub entry: jacquard_common::types::string::AtUri<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub entry_record: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub path: std::option::Option>, #[serde(borrow)] pub publication: jacquard_common::types::string::AtUri<'a>, } pub mod generate_document_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Entry; type Publication; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Entry = Unset; type Publication = Unset; } ///State transition - sets the `entry` field to Set pub struct SetEntry(PhantomData S>); impl sealed::Sealed for SetEntry {} impl State for SetEntry { type Entry = Set; type Publication = S::Publication; } ///State transition - sets the `publication` field to Set pub struct SetPublication(PhantomData S>); impl sealed::Sealed for SetPublication {} impl State for SetPublication { type Entry = S::Entry; type Publication = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `entry` field pub struct entry(()); ///Marker type for the `publication` field pub struct publication(()); } } /// Builder for constructing an instance of this type pub struct GenerateDocumentBuilder<'a, S: generate_document_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> GenerateDocument<'a> { /// Create a new builder for this type pub fn new() -> GenerateDocumentBuilder<'a, generate_document_state::Empty> { GenerateDocumentBuilder::new() } } impl<'a> GenerateDocumentBuilder<'a, generate_document_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { GenerateDocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> GenerateDocumentBuilder<'a, S> where S: generate_document_state::State, S::Entry: generate_document_state::IsUnset, { /// Set the `entry` field (required) pub fn entry( mut self, value: impl Into>, ) -> GenerateDocumentBuilder<'a, generate_document_state::SetEntry> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); GenerateDocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: generate_document_state::State> GenerateDocumentBuilder<'a, S> { /// Set the `entryRecord` field (optional) pub fn entry_record( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `entryRecord` field to an Option value (optional) pub fn maybe_entry_record( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: generate_document_state::State> GenerateDocumentBuilder<'a, S> { /// Set the `path` field (optional) pub fn path( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `path` field to an Option value (optional) pub fn maybe_path(mut self, value: Option>) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> GenerateDocumentBuilder<'a, S> where S: generate_document_state::State, S::Publication: generate_document_state::IsUnset, { /// Set the `publication` field (required) pub fn publication( mut self, value: impl Into>, ) -> GenerateDocumentBuilder<'a, generate_document_state::SetPublication> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); GenerateDocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> GenerateDocumentBuilder<'a, S> where S: generate_document_state::State, S::Entry: generate_document_state::IsSet, S::Publication: generate_document_state::IsSet, { /// Build the final struct pub fn build(self) -> GenerateDocument<'a> { GenerateDocument { entry: self.__unsafe_private_named.0.unwrap(), entry_record: self.__unsafe_private_named.1, path: self.__unsafe_private_named.2, publication: self.__unsafe_private_named.3.unwrap(), } } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct GenerateDocumentOutput<'a> { #[serde(borrow)] pub record: crate::site_standard::document::Document<'a>, } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic, jacquard_derive::IntoStatic )] #[serde(tag = "error", content = "message")] #[serde(bound(deserialize = "'de: 'a"))] pub enum GenerateDocumentError<'a> { #[serde(rename = "PublicationNotFound")] PublicationNotFound(std::option::Option>), #[serde(rename = "EntryNotFound")] EntryNotFound(std::option::Option>), #[serde(rename = "NotebookNotLinked")] NotebookNotLinked(std::option::Option>), } impl core::fmt::Display for GenerateDocumentError<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::PublicationNotFound(msg) => { write!(f, "PublicationNotFound")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::EntryNotFound(msg) => { write!(f, "EntryNotFound")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::NotebookNotLinked(msg) => { write!(f, "NotebookNotLinked")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } /// Response type for ///sh.weaver.domain.generateDocument pub struct GenerateDocumentResponse; impl jacquard_common::xrpc::XrpcResp for GenerateDocumentResponse { const NSID: &'static str = "sh.weaver.domain.generateDocument"; const ENCODING: &'static str = "application/json"; type Output<'de> = GenerateDocumentOutput<'de>; type Err<'de> = GenerateDocumentError<'de>; } impl<'a> jacquard_common::xrpc::XrpcRequest for GenerateDocument<'a> { const NSID: &'static str = "sh.weaver.domain.generateDocument"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Response = GenerateDocumentResponse; } /// Endpoint type for ///sh.weaver.domain.generateDocument pub struct GenerateDocumentRequest; impl jacquard_common::xrpc::XrpcEndpoint for GenerateDocumentRequest { const PATH: &'static str = "/xrpc/sh.weaver.domain.generateDocument"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Request<'de> = GenerateDocument<'de>; type Response = GenerateDocumentResponse; }