Skip to main content

jacquard_api/sh_weaver/notebook/
get_notebook_chapters.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.getNotebookChapters
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 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    ///Defaults to `50`. Min: 1. Max: 100.
26    #[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
45/// Response type for sh.weaver.notebook.getNotebookChapters
46pub 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
60/// Endpoint type for sh.weaver.notebook.getNotebookChapters
61pub 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    /// State trait tracking which required fields have been set
82    pub trait State: sealed::Sealed {
83        type Notebook;
84    }
85    /// Empty state - all required fields are unset
86    pub struct Empty(());
87    impl sealed::Sealed for Empty {}
88    impl State for Empty {
89        type Notebook = Unset;
90    }
91    ///State transition - sets the `notebook` field to Set
92    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    /// Marker types for field names
98    #[allow(non_camel_case_types)]
99    pub mod members {
100        ///Marker type for the `notebook` field
101        pub struct notebook(());
102    }
103}
104
105/// Builder for constructing an instance of this type
106pub 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    /// Create a new builder for this type
114    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    /// Create a new builder with all fields unset
121    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    /// Set the `cursor` field (optional)
132    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
133        self._fields.0 = value.into();
134        self
135    }
136    /// Set the `cursor` field to an Option value (optional)
137    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    /// Set the `limit` field (optional)
145    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
146        self._fields.1 = value.into();
147        self
148    }
149    /// Set the `limit` field to an Option value (optional)
150    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    /// Set the `notebook` field (required)
162    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    /// Build the final struct
181    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}