// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.domain.resolveDocument // // 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 ResolveDocument<'a> { #[serde(borrow)] pub path: jacquard_common::CowStr<'a>, #[serde(borrow)] pub publication: jacquard_common::types::string::AtUri<'a>, } pub mod resolve_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 Publication; type Path; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Publication = Unset; type Path = Unset; } ///State transition - sets the `publication` field to Set pub struct SetPublication(PhantomData S>); impl sealed::Sealed for SetPublication {} impl State for SetPublication { type Publication = Set; type Path = S::Path; } ///State transition - sets the `path` field to Set pub struct SetPath(PhantomData S>); impl sealed::Sealed for SetPath {} impl State for SetPath { type Publication = S::Publication; type Path = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `publication` field pub struct publication(()); ///Marker type for the `path` field pub struct path(()); } } /// Builder for constructing an instance of this type pub struct ResolveDocumentBuilder<'a, S: resolve_document_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> ResolveDocument<'a> { /// Create a new builder for this type pub fn new() -> ResolveDocumentBuilder<'a, resolve_document_state::Empty> { ResolveDocumentBuilder::new() } } impl<'a> ResolveDocumentBuilder<'a, resolve_document_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ResolveDocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ResolveDocumentBuilder<'a, S> where S: resolve_document_state::State, S::Path: resolve_document_state::IsUnset, { /// Set the `path` field (required) pub fn path( mut self, value: impl Into>, ) -> ResolveDocumentBuilder<'a, resolve_document_state::SetPath> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); ResolveDocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ResolveDocumentBuilder<'a, S> where S: resolve_document_state::State, S::Publication: resolve_document_state::IsUnset, { /// Set the `publication` field (required) pub fn publication( mut self, value: impl Into>, ) -> ResolveDocumentBuilder<'a, resolve_document_state::SetPublication> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); ResolveDocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ResolveDocumentBuilder<'a, S> where S: resolve_document_state::State, S::Publication: resolve_document_state::IsSet, S::Path: resolve_document_state::IsSet, { /// Build the final struct pub fn build(self) -> ResolveDocument<'a> { ResolveDocument { path: self.__unsafe_private_named.0.unwrap(), publication: self.__unsafe_private_named.1.unwrap(), } } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct ResolveDocumentOutput<'a> { #[serde(borrow)] pub document: crate::sh_weaver::domain::DocumentView<'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 ResolveDocumentError<'a> { #[serde(rename = "PublicationNotFound")] PublicationNotFound(std::option::Option>), #[serde(rename = "DocumentNotFound")] DocumentNotFound(std::option::Option>), } impl core::fmt::Display for ResolveDocumentError<'_> { 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::DocumentNotFound(msg) => { write!(f, "DocumentNotFound")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } /// Response type for ///sh.weaver.domain.resolveDocument pub struct ResolveDocumentResponse; impl jacquard_common::xrpc::XrpcResp for ResolveDocumentResponse { const NSID: &'static str = "sh.weaver.domain.resolveDocument"; const ENCODING: &'static str = "application/json"; type Output<'de> = ResolveDocumentOutput<'de>; type Err<'de> = ResolveDocumentError<'de>; } impl<'a> jacquard_common::xrpc::XrpcRequest for ResolveDocument<'a> { const NSID: &'static str = "sh.weaver.domain.resolveDocument"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Response = ResolveDocumentResponse; } /// Endpoint type for ///sh.weaver.domain.resolveDocument pub struct ResolveDocumentRequest; impl jacquard_common::xrpc::XrpcEndpoint for ResolveDocumentRequest { const PATH: &'static str = "/xrpc/sh.weaver.domain.resolveDocument"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; type Request<'de> = ResolveDocument<'de>; type Response = ResolveDocumentResponse; }