Skip to main content

jacquard_api/sh_weaver/notebook/
get_entry.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.getEntry
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use core::marker::PhantomData;
10use jacquard_common::CowStr;
11use jacquard_common::types::string::AtUri;
12use jacquard_derive::{IntoStatic, open_union};
13use serde::{Serialize, Deserialize};
14use crate::sh_weaver::notebook::EntryView;
15
16#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
17#[serde(rename_all = "camelCase")]
18pub struct GetEntry<'a> {
19    #[serde(borrow)]
20    pub uri: AtUri<'a>,
21}
22
23
24#[jacquard_derive::lexicon]
25#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
26#[serde(rename_all = "camelCase")]
27pub struct GetEntryOutput<'a> {
28    #[serde(flatten)]
29    #[serde(borrow)]
30    pub value: EntryView<'a>,
31}
32
33
34#[open_union]
35#[derive(
36    Serialize,
37    Deserialize,
38    Debug,
39    Clone,
40    PartialEq,
41    Eq,
42    thiserror::Error,
43    miette::Diagnostic,
44    IntoStatic
45)]
46
47#[serde(tag = "error", content = "message")]
48#[serde(bound(deserialize = "'de: 'a"))]
49pub enum GetEntryError<'a> {
50    #[serde(rename = "EntryNotFound")]
51    EntryNotFound(Option<CowStr<'a>>),
52}
53
54impl core::fmt::Display for GetEntryError<'_> {
55    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56        match self {
57            Self::EntryNotFound(msg) => {
58                write!(f, "EntryNotFound")?;
59                if let Some(msg) = msg {
60                    write!(f, ": {}", msg)?;
61                }
62                Ok(())
63            }
64            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
65        }
66    }
67}
68
69/// Response type for sh.weaver.notebook.getEntry
70pub struct GetEntryResponse;
71impl jacquard_common::xrpc::XrpcResp for GetEntryResponse {
72    const NSID: &'static str = "sh.weaver.notebook.getEntry";
73    const ENCODING: &'static str = "application/json";
74    type Output<'de> = GetEntryOutput<'de>;
75    type Err<'de> = GetEntryError<'de>;
76}
77
78impl<'a> jacquard_common::xrpc::XrpcRequest for GetEntry<'a> {
79    const NSID: &'static str = "sh.weaver.notebook.getEntry";
80    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
81    type Response = GetEntryResponse;
82}
83
84/// Endpoint type for sh.weaver.notebook.getEntry
85pub struct GetEntryRequest;
86impl jacquard_common::xrpc::XrpcEndpoint for GetEntryRequest {
87    const PATH: &'static str = "/xrpc/sh.weaver.notebook.getEntry";
88    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
89    type Request<'de> = GetEntry<'de>;
90    type Response = GetEntryResponse;
91}
92
93pub mod get_entry_state {
94
95    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
96    #[allow(unused)]
97    use ::core::marker::PhantomData;
98    mod sealed {
99        pub trait Sealed {}
100    }
101    /// State trait tracking which required fields have been set
102    pub trait State: sealed::Sealed {
103        type Uri;
104    }
105    /// Empty state - all required fields are unset
106    pub struct Empty(());
107    impl sealed::Sealed for Empty {}
108    impl State for Empty {
109        type Uri = Unset;
110    }
111    ///State transition - sets the `uri` field to Set
112    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
113    impl<S: State> sealed::Sealed for SetUri<S> {}
114    impl<S: State> State for SetUri<S> {
115        type Uri = Set<members::uri>;
116    }
117    /// Marker types for field names
118    #[allow(non_camel_case_types)]
119    pub mod members {
120        ///Marker type for the `uri` field
121        pub struct uri(());
122    }
123}
124
125/// Builder for constructing an instance of this type
126pub struct GetEntryBuilder<'a, S: get_entry_state::State> {
127    _state: PhantomData<fn() -> S>,
128    _fields: (Option<AtUri<'a>>,),
129    _lifetime: PhantomData<&'a ()>,
130}
131
132impl<'a> GetEntry<'a> {
133    /// Create a new builder for this type
134    pub fn new() -> GetEntryBuilder<'a, get_entry_state::Empty> {
135        GetEntryBuilder::new()
136    }
137}
138
139impl<'a> GetEntryBuilder<'a, get_entry_state::Empty> {
140    /// Create a new builder with all fields unset
141    pub fn new() -> Self {
142        GetEntryBuilder {
143            _state: PhantomData,
144            _fields: (None,),
145            _lifetime: PhantomData,
146        }
147    }
148}
149
150impl<'a, S> GetEntryBuilder<'a, S>
151where
152    S: get_entry_state::State,
153    S::Uri: get_entry_state::IsUnset,
154{
155    /// Set the `uri` field (required)
156    pub fn uri(
157        mut self,
158        value: impl Into<AtUri<'a>>,
159    ) -> GetEntryBuilder<'a, get_entry_state::SetUri<S>> {
160        self._fields.0 = Option::Some(value.into());
161        GetEntryBuilder {
162            _state: PhantomData,
163            _fields: self._fields,
164            _lifetime: PhantomData,
165        }
166    }
167}
168
169impl<'a, S> GetEntryBuilder<'a, S>
170where
171    S: get_entry_state::State,
172    S::Uri: get_entry_state::IsSet,
173{
174    /// Build the final struct
175    pub fn build(self) -> GetEntry<'a> {
176        GetEntry {
177            uri: self._fields.0.unwrap(),
178        }
179    }
180}