atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.getNotebookByTitle
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 GetNotebookByTitle<'a> {
19 #[serde(borrow)]
20 pub actor: jacquard_common::types::ident::AtIdentifier<'a>,
21 #[serde(borrow)]
22 pub title: jacquard_common::CowStr<'a>,
23}
24
25pub mod get_notebook_by_title_state {
26
27 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
28 #[allow(unused)]
29 use ::core::marker::PhantomData;
30 mod sealed {
31 pub trait Sealed {}
32 }
33 /// State trait tracking which required fields have been set
34 pub trait State: sealed::Sealed {
35 type Title;
36 type Actor;
37 }
38 /// Empty state - all required fields are unset
39 pub struct Empty(());
40 impl sealed::Sealed for Empty {}
41 impl State for Empty {
42 type Title = Unset;
43 type Actor = Unset;
44 }
45 ///State transition - sets the `title` field to Set
46 pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
47 impl<S: State> sealed::Sealed for SetTitle<S> {}
48 impl<S: State> State for SetTitle<S> {
49 type Title = Set<members::title>;
50 type Actor = S::Actor;
51 }
52 ///State transition - sets the `actor` field to Set
53 pub struct SetActor<S: State = Empty>(PhantomData<fn() -> S>);
54 impl<S: State> sealed::Sealed for SetActor<S> {}
55 impl<S: State> State for SetActor<S> {
56 type Title = S::Title;
57 type Actor = Set<members::actor>;
58 }
59 /// Marker types for field names
60 #[allow(non_camel_case_types)]
61 pub mod members {
62 ///Marker type for the `title` field
63 pub struct title(());
64 ///Marker type for the `actor` field
65 pub struct actor(());
66 }
67}
68
69/// Builder for constructing an instance of this type
70pub struct GetNotebookByTitleBuilder<'a, S: get_notebook_by_title_state::State> {
71 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
72 __unsafe_private_named: (
73 ::core::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>,
74 ::core::option::Option<jacquard_common::CowStr<'a>>,
75 ),
76 _phantom: ::core::marker::PhantomData<&'a ()>,
77}
78
79impl<'a> GetNotebookByTitle<'a> {
80 /// Create a new builder for this type
81 pub fn new() -> GetNotebookByTitleBuilder<'a, get_notebook_by_title_state::Empty> {
82 GetNotebookByTitleBuilder::new()
83 }
84}
85
86impl<'a> GetNotebookByTitleBuilder<'a, get_notebook_by_title_state::Empty> {
87 /// Create a new builder with all fields unset
88 pub fn new() -> Self {
89 GetNotebookByTitleBuilder {
90 _phantom_state: ::core::marker::PhantomData,
91 __unsafe_private_named: (None, None),
92 _phantom: ::core::marker::PhantomData,
93 }
94 }
95}
96
97impl<'a, S> GetNotebookByTitleBuilder<'a, S>
98where
99 S: get_notebook_by_title_state::State,
100 S::Actor: get_notebook_by_title_state::IsUnset,
101{
102 /// Set the `actor` field (required)
103 pub fn actor(
104 mut self,
105 value: impl Into<jacquard_common::types::ident::AtIdentifier<'a>>,
106 ) -> GetNotebookByTitleBuilder<'a, get_notebook_by_title_state::SetActor<S>> {
107 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
108 GetNotebookByTitleBuilder {
109 _phantom_state: ::core::marker::PhantomData,
110 __unsafe_private_named: self.__unsafe_private_named,
111 _phantom: ::core::marker::PhantomData,
112 }
113 }
114}
115
116impl<'a, S> GetNotebookByTitleBuilder<'a, S>
117where
118 S: get_notebook_by_title_state::State,
119 S::Title: get_notebook_by_title_state::IsUnset,
120{
121 /// Set the `title` field (required)
122 pub fn title(
123 mut self,
124 value: impl Into<jacquard_common::CowStr<'a>>,
125 ) -> GetNotebookByTitleBuilder<'a, get_notebook_by_title_state::SetTitle<S>> {
126 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
127 GetNotebookByTitleBuilder {
128 _phantom_state: ::core::marker::PhantomData,
129 __unsafe_private_named: self.__unsafe_private_named,
130 _phantom: ::core::marker::PhantomData,
131 }
132 }
133}
134
135impl<'a, S> GetNotebookByTitleBuilder<'a, S>
136where
137 S: get_notebook_by_title_state::State,
138 S::Title: get_notebook_by_title_state::IsSet,
139 S::Actor: get_notebook_by_title_state::IsSet,
140{
141 /// Build the final struct
142 pub fn build(self) -> GetNotebookByTitle<'a> {
143 GetNotebookByTitle {
144 actor: self.__unsafe_private_named.0.unwrap(),
145 title: self.__unsafe_private_named.1.unwrap(),
146 }
147 }
148}
149
150#[jacquard_derive::lexicon]
151#[derive(
152 serde::Serialize,
153 serde::Deserialize,
154 Debug,
155 Clone,
156 PartialEq,
157 Eq,
158 jacquard_derive::IntoStatic
159)]
160#[serde(rename_all = "camelCase")]
161pub struct GetNotebookByTitleOutput<'a> {
162 #[serde(borrow)]
163 pub entries: Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
164 #[serde(borrow)]
165 pub notebook: crate::sh_weaver::notebook::NotebookView<'a>,
166}
167
168#[jacquard_derive::open_union]
169#[derive(
170 serde::Serialize,
171 serde::Deserialize,
172 Debug,
173 Clone,
174 PartialEq,
175 Eq,
176 thiserror::Error,
177 miette::Diagnostic,
178 jacquard_derive::IntoStatic
179)]
180#[serde(tag = "error", content = "message")]
181#[serde(bound(deserialize = "'de: 'a"))]
182pub enum GetNotebookByTitleError<'a> {
183 #[serde(rename = "NotebookNotFound")]
184 NotebookNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
185}
186
187impl core::fmt::Display for GetNotebookByTitleError<'_> {
188 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
189 match self {
190 Self::NotebookNotFound(msg) => {
191 write!(f, "NotebookNotFound")?;
192 if let Some(msg) = msg {
193 write!(f, ": {}", msg)?;
194 }
195 Ok(())
196 }
197 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
198 }
199 }
200}
201
202/// Response type for
203///sh.weaver.notebook.getNotebookByTitle
204pub struct GetNotebookByTitleResponse;
205impl jacquard_common::xrpc::XrpcResp for GetNotebookByTitleResponse {
206 const NSID: &'static str = "sh.weaver.notebook.getNotebookByTitle";
207 const ENCODING: &'static str = "application/json";
208 type Output<'de> = GetNotebookByTitleOutput<'de>;
209 type Err<'de> = GetNotebookByTitleError<'de>;
210}
211
212impl<'a> jacquard_common::xrpc::XrpcRequest for GetNotebookByTitle<'a> {
213 const NSID: &'static str = "sh.weaver.notebook.getNotebookByTitle";
214 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
215 type Response = GetNotebookByTitleResponse;
216}
217
218/// Endpoint type for
219///sh.weaver.notebook.getNotebookByTitle
220pub struct GetNotebookByTitleRequest;
221impl jacquard_common::xrpc::XrpcEndpoint for GetNotebookByTitleRequest {
222 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getNotebookByTitle";
223 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
224 type Request<'de> = GetNotebookByTitle<'de>;
225 type Response = GetNotebookByTitleResponse;
226}