jacquard_api/sh_weaver/notebook/
get_notebook_chapters.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::AtUri;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17use crate::sh_weaver::notebook::ChapterView;
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct GetNotebookChapters<'a> {
22 #[serde(skip_serializing_if = "Option::is_none")]
23 #[serde(borrow)]
24 pub cursor: Option<CowStr<'a>>,
25 #[serde(default = "_default_limit")]
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub limit: Option<i64>,
29 #[serde(borrow)]
30 pub notebook: AtUri<'a>,
31}
32
33
34#[lexicon]
35#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
36#[serde(rename_all = "camelCase")]
37pub struct GetNotebookChaptersOutput<'a> {
38 #[serde(borrow)]
39 pub chapters: Vec<ChapterView<'a>>,
40 #[serde(skip_serializing_if = "Option::is_none")]
41 #[serde(borrow)]
42 pub cursor: Option<CowStr<'a>>,
43}
44
45pub struct GetNotebookChaptersResponse;
47impl jacquard_common::xrpc::XrpcResp for GetNotebookChaptersResponse {
48 const NSID: &'static str = "sh.weaver.notebook.getNotebookChapters";
49 const ENCODING: &'static str = "application/json";
50 type Output<'de> = GetNotebookChaptersOutput<'de>;
51 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
52}
53
54impl<'a> jacquard_common::xrpc::XrpcRequest for GetNotebookChapters<'a> {
55 const NSID: &'static str = "sh.weaver.notebook.getNotebookChapters";
56 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
57 type Response = GetNotebookChaptersResponse;
58}
59
60pub struct GetNotebookChaptersRequest;
62impl jacquard_common::xrpc::XrpcEndpoint for GetNotebookChaptersRequest {
63 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getNotebookChapters";
64 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
65 type Request<'de> = GetNotebookChapters<'de>;
66 type Response = GetNotebookChaptersResponse;
67}
68
69fn _default_limit() -> Option<i64> {
70 Some(50i64)
71}
72
73pub mod get_notebook_chapters_state {
74
75 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
76 #[allow(unused)]
77 use ::core::marker::PhantomData;
78 mod sealed {
79 pub trait Sealed {}
80 }
81 pub trait State: sealed::Sealed {
83 type Notebook;
84 }
85 pub struct Empty(());
87 impl sealed::Sealed for Empty {}
88 impl State for Empty {
89 type Notebook = Unset;
90 }
91 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
93 impl<S: State> sealed::Sealed for SetNotebook<S> {}
94 impl<S: State> State for SetNotebook<S> {
95 type Notebook = Set<members::notebook>;
96 }
97 #[allow(non_camel_case_types)]
99 pub mod members {
100 pub struct notebook(());
102 }
103}
104
105pub struct GetNotebookChaptersBuilder<'a, S: get_notebook_chapters_state::State> {
107 _state: PhantomData<fn() -> S>,
108 _fields: (Option<CowStr<'a>>, Option<i64>, Option<AtUri<'a>>),
109 _lifetime: PhantomData<&'a ()>,
110}
111
112impl<'a> GetNotebookChapters<'a> {
113 pub fn new() -> GetNotebookChaptersBuilder<'a, get_notebook_chapters_state::Empty> {
115 GetNotebookChaptersBuilder::new()
116 }
117}
118
119impl<'a> GetNotebookChaptersBuilder<'a, get_notebook_chapters_state::Empty> {
120 pub fn new() -> Self {
122 GetNotebookChaptersBuilder {
123 _state: PhantomData,
124 _fields: (None, None, None),
125 _lifetime: PhantomData,
126 }
127 }
128}
129
130impl<'a, S: get_notebook_chapters_state::State> GetNotebookChaptersBuilder<'a, S> {
131 pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
133 self._fields.0 = value.into();
134 self
135 }
136 pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
138 self._fields.0 = value;
139 self
140 }
141}
142
143impl<'a, S: get_notebook_chapters_state::State> GetNotebookChaptersBuilder<'a, S> {
144 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
146 self._fields.1 = value.into();
147 self
148 }
149 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
151 self._fields.1 = value;
152 self
153 }
154}
155
156impl<'a, S> GetNotebookChaptersBuilder<'a, S>
157where
158 S: get_notebook_chapters_state::State,
159 S::Notebook: get_notebook_chapters_state::IsUnset,
160{
161 pub fn notebook(
163 mut self,
164 value: impl Into<AtUri<'a>>,
165 ) -> GetNotebookChaptersBuilder<'a, get_notebook_chapters_state::SetNotebook<S>> {
166 self._fields.2 = Option::Some(value.into());
167 GetNotebookChaptersBuilder {
168 _state: PhantomData,
169 _fields: self._fields,
170 _lifetime: PhantomData,
171 }
172 }
173}
174
175impl<'a, S> GetNotebookChaptersBuilder<'a, S>
176where
177 S: get_notebook_chapters_state::State,
178 S::Notebook: get_notebook_chapters_state::IsSet,
179{
180 pub fn build(self) -> GetNotebookChapters<'a> {
182 GetNotebookChapters {
183 cursor: self._fields.0,
184 limit: self._fields.1,
185 notebook: self._fields.2.unwrap(),
186 }
187 }
188}