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