jacquard_api/sh_weaver/notebook/
get_entry_notebooks.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::string::{AtUri, Cid};
18use jacquard_derive::{IntoStatic, lexicon};
19use jacquard_lexicon::lexicon::LexiconDoc;
20use jacquard_lexicon::schema::LexiconSchema;
21
22#[allow(unused_imports)]
23use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
24use serde::{Serialize, Deserialize};
25use crate::sh_weaver::actor::ProfileViewBasic;
26use crate::sh_weaver::notebook::get_entry_notebooks;
27
28#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
29#[serde(rename_all = "camelCase")]
30pub struct GetEntryNotebooks<'a> {
31 #[serde(borrow)]
32 pub entry: AtUri<'a>,
33}
34
35
36#[lexicon]
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(rename_all = "camelCase")]
39pub struct GetEntryNotebooksOutput<'a> {
40 #[serde(borrow)]
41 pub notebooks: Vec<get_entry_notebooks::NotebookRef<'a>>,
42}
43
44#[lexicon]
47#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
48#[serde(rename_all = "camelCase")]
49pub struct NotebookRef<'a> {
50 #[serde(borrow)]
51 pub cid: Cid<'a>,
52 #[serde(skip_serializing_if = "Option::is_none")]
53 #[serde(borrow)]
54 pub owner: Option<ProfileViewBasic<'a>>,
55 #[serde(skip_serializing_if = "Option::is_none")]
56 #[serde(borrow)]
57 pub title: Option<CowStr<'a>>,
58 #[serde(borrow)]
59 pub uri: AtUri<'a>,
60}
61
62pub struct GetEntryNotebooksResponse;
64impl jacquard_common::xrpc::XrpcResp for GetEntryNotebooksResponse {
65 const NSID: &'static str = "sh.weaver.notebook.getEntryNotebooks";
66 const ENCODING: &'static str = "application/json";
67 type Output<'de> = GetEntryNotebooksOutput<'de>;
68 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
69}
70
71impl<'a> jacquard_common::xrpc::XrpcRequest for GetEntryNotebooks<'a> {
72 const NSID: &'static str = "sh.weaver.notebook.getEntryNotebooks";
73 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
74 type Response = GetEntryNotebooksResponse;
75}
76
77pub struct GetEntryNotebooksRequest;
79impl jacquard_common::xrpc::XrpcEndpoint for GetEntryNotebooksRequest {
80 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getEntryNotebooks";
81 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
82 type Request<'de> = GetEntryNotebooks<'de>;
83 type Response = GetEntryNotebooksResponse;
84}
85
86impl<'a> LexiconSchema for NotebookRef<'a> {
87 fn nsid() -> &'static str {
88 "sh.weaver.notebook.getEntryNotebooks"
89 }
90 fn def_name() -> &'static str {
91 "notebookRef"
92 }
93 fn lexicon_doc() -> LexiconDoc<'static> {
94 lexicon_doc_sh_weaver_notebook_getEntryNotebooks()
95 }
96 fn validate(&self) -> Result<(), ConstraintError> {
97 Ok(())
98 }
99}
100
101pub mod get_entry_notebooks_state {
102
103 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
104 #[allow(unused)]
105 use ::core::marker::PhantomData;
106 mod sealed {
107 pub trait Sealed {}
108 }
109 pub trait State: sealed::Sealed {
111 type Entry;
112 }
113 pub struct Empty(());
115 impl sealed::Sealed for Empty {}
116 impl State for Empty {
117 type Entry = Unset;
118 }
119 pub struct SetEntry<S: State = Empty>(PhantomData<fn() -> S>);
121 impl<S: State> sealed::Sealed for SetEntry<S> {}
122 impl<S: State> State for SetEntry<S> {
123 type Entry = Set<members::entry>;
124 }
125 #[allow(non_camel_case_types)]
127 pub mod members {
128 pub struct entry(());
130 }
131}
132
133pub struct GetEntryNotebooksBuilder<'a, S: get_entry_notebooks_state::State> {
135 _state: PhantomData<fn() -> S>,
136 _fields: (Option<AtUri<'a>>,),
137 _lifetime: PhantomData<&'a ()>,
138}
139
140impl<'a> GetEntryNotebooks<'a> {
141 pub fn new() -> GetEntryNotebooksBuilder<'a, get_entry_notebooks_state::Empty> {
143 GetEntryNotebooksBuilder::new()
144 }
145}
146
147impl<'a> GetEntryNotebooksBuilder<'a, get_entry_notebooks_state::Empty> {
148 pub fn new() -> Self {
150 GetEntryNotebooksBuilder {
151 _state: PhantomData,
152 _fields: (None,),
153 _lifetime: PhantomData,
154 }
155 }
156}
157
158impl<'a, S> GetEntryNotebooksBuilder<'a, S>
159where
160 S: get_entry_notebooks_state::State,
161 S::Entry: get_entry_notebooks_state::IsUnset,
162{
163 pub fn entry(
165 mut self,
166 value: impl Into<AtUri<'a>>,
167 ) -> GetEntryNotebooksBuilder<'a, get_entry_notebooks_state::SetEntry<S>> {
168 self._fields.0 = Option::Some(value.into());
169 GetEntryNotebooksBuilder {
170 _state: PhantomData,
171 _fields: self._fields,
172 _lifetime: PhantomData,
173 }
174 }
175}
176
177impl<'a, S> GetEntryNotebooksBuilder<'a, S>
178where
179 S: get_entry_notebooks_state::State,
180 S::Entry: get_entry_notebooks_state::IsSet,
181{
182 pub fn build(self) -> GetEntryNotebooks<'a> {
184 GetEntryNotebooks {
185 entry: self._fields.0.unwrap(),
186 }
187 }
188}
189
190pub mod notebook_ref_state {
191
192 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
193 #[allow(unused)]
194 use ::core::marker::PhantomData;
195 mod sealed {
196 pub trait Sealed {}
197 }
198 pub trait State: sealed::Sealed {
200 type Uri;
201 type Cid;
202 }
203 pub struct Empty(());
205 impl sealed::Sealed for Empty {}
206 impl State for Empty {
207 type Uri = Unset;
208 type Cid = Unset;
209 }
210 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
212 impl<S: State> sealed::Sealed for SetUri<S> {}
213 impl<S: State> State for SetUri<S> {
214 type Uri = Set<members::uri>;
215 type Cid = S::Cid;
216 }
217 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
219 impl<S: State> sealed::Sealed for SetCid<S> {}
220 impl<S: State> State for SetCid<S> {
221 type Uri = S::Uri;
222 type Cid = Set<members::cid>;
223 }
224 #[allow(non_camel_case_types)]
226 pub mod members {
227 pub struct uri(());
229 pub struct cid(());
231 }
232}
233
234pub struct NotebookRefBuilder<'a, S: notebook_ref_state::State> {
236 _state: PhantomData<fn() -> S>,
237 _fields: (
238 Option<Cid<'a>>,
239 Option<ProfileViewBasic<'a>>,
240 Option<CowStr<'a>>,
241 Option<AtUri<'a>>,
242 ),
243 _lifetime: PhantomData<&'a ()>,
244}
245
246impl<'a> NotebookRef<'a> {
247 pub fn new() -> NotebookRefBuilder<'a, notebook_ref_state::Empty> {
249 NotebookRefBuilder::new()
250 }
251}
252
253impl<'a> NotebookRefBuilder<'a, notebook_ref_state::Empty> {
254 pub fn new() -> Self {
256 NotebookRefBuilder {
257 _state: PhantomData,
258 _fields: (None, None, None, None),
259 _lifetime: PhantomData,
260 }
261 }
262}
263
264impl<'a, S> NotebookRefBuilder<'a, S>
265where
266 S: notebook_ref_state::State,
267 S::Cid: notebook_ref_state::IsUnset,
268{
269 pub fn cid(
271 mut self,
272 value: impl Into<Cid<'a>>,
273 ) -> NotebookRefBuilder<'a, notebook_ref_state::SetCid<S>> {
274 self._fields.0 = Option::Some(value.into());
275 NotebookRefBuilder {
276 _state: PhantomData,
277 _fields: self._fields,
278 _lifetime: PhantomData,
279 }
280 }
281}
282
283impl<'a, S: notebook_ref_state::State> NotebookRefBuilder<'a, S> {
284 pub fn owner(mut self, value: impl Into<Option<ProfileViewBasic<'a>>>) -> Self {
286 self._fields.1 = value.into();
287 self
288 }
289 pub fn maybe_owner(mut self, value: Option<ProfileViewBasic<'a>>) -> Self {
291 self._fields.1 = value;
292 self
293 }
294}
295
296impl<'a, S: notebook_ref_state::State> NotebookRefBuilder<'a, S> {
297 pub fn title(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
299 self._fields.2 = value.into();
300 self
301 }
302 pub fn maybe_title(mut self, value: Option<CowStr<'a>>) -> Self {
304 self._fields.2 = value;
305 self
306 }
307}
308
309impl<'a, S> NotebookRefBuilder<'a, S>
310where
311 S: notebook_ref_state::State,
312 S::Uri: notebook_ref_state::IsUnset,
313{
314 pub fn uri(
316 mut self,
317 value: impl Into<AtUri<'a>>,
318 ) -> NotebookRefBuilder<'a, notebook_ref_state::SetUri<S>> {
319 self._fields.3 = Option::Some(value.into());
320 NotebookRefBuilder {
321 _state: PhantomData,
322 _fields: self._fields,
323 _lifetime: PhantomData,
324 }
325 }
326}
327
328impl<'a, S> NotebookRefBuilder<'a, S>
329where
330 S: notebook_ref_state::State,
331 S::Uri: notebook_ref_state::IsSet,
332 S::Cid: notebook_ref_state::IsSet,
333{
334 pub fn build(self) -> NotebookRef<'a> {
336 NotebookRef {
337 cid: self._fields.0.unwrap(),
338 owner: self._fields.1,
339 title: self._fields.2,
340 uri: self._fields.3.unwrap(),
341 extra_data: Default::default(),
342 }
343 }
344 pub fn build_with_data(
346 self,
347 extra_data: BTreeMap<
348 jacquard_common::deps::smol_str::SmolStr,
349 jacquard_common::types::value::Data<'a>,
350 >,
351 ) -> NotebookRef<'a> {
352 NotebookRef {
353 cid: self._fields.0.unwrap(),
354 owner: self._fields.1,
355 title: self._fields.2,
356 uri: self._fields.3.unwrap(),
357 extra_data: Some(extra_data),
358 }
359 }
360}
361
362fn lexicon_doc_sh_weaver_notebook_getEntryNotebooks() -> LexiconDoc<'static> {
363 #[allow(unused_imports)]
364 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
365 use jacquard_lexicon::lexicon::*;
366 use alloc::collections::BTreeMap;
367 LexiconDoc {
368 lexicon: Lexicon::Lexicon1,
369 id: CowStr::new_static("sh.weaver.notebook.getEntryNotebooks"),
370 defs: {
371 let mut map = BTreeMap::new();
372 map.insert(
373 SmolStr::new_static("main"),
374 LexUserType::XrpcQuery(LexXrpcQuery {
375 parameters: Some(
376 LexXrpcQueryParameter::Params(LexXrpcParameters {
377 required: Some(vec![SmolStr::new_static("entry")]),
378 properties: {
379 #[allow(unused_mut)]
380 let mut map = BTreeMap::new();
381 map.insert(
382 SmolStr::new_static("entry"),
383 LexXrpcParametersProperty::String(LexString {
384 description: Some(
385 CowStr::new_static("AT URI of the entry"),
386 ),
387 format: Some(LexStringFormat::AtUri),
388 ..Default::default()
389 }),
390 );
391 map
392 },
393 ..Default::default()
394 }),
395 ),
396 ..Default::default()
397 }),
398 );
399 map.insert(
400 SmolStr::new_static("notebookRef"),
401 LexUserType::Object(LexObject {
402 description: Some(
403 CowStr::new_static(
404 "Reference to a notebook containing this entry.",
405 ),
406 ),
407 required: Some(
408 vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")],
409 ),
410 properties: {
411 #[allow(unused_mut)]
412 let mut map = BTreeMap::new();
413 map.insert(
414 SmolStr::new_static("cid"),
415 LexObjectProperty::String(LexString {
416 format: Some(LexStringFormat::Cid),
417 ..Default::default()
418 }),
419 );
420 map.insert(
421 SmolStr::new_static("owner"),
422 LexObjectProperty::Ref(LexRef {
423 r#ref: CowStr::new_static(
424 "sh.weaver.actor.defs#profileViewBasic",
425 ),
426 ..Default::default()
427 }),
428 );
429 map.insert(
430 SmolStr::new_static("title"),
431 LexObjectProperty::String(LexString { ..Default::default() }),
432 );
433 map.insert(
434 SmolStr::new_static("uri"),
435 LexObjectProperty::String(LexString {
436 format: Some(LexStringFormat::AtUri),
437 ..Default::default()
438 }),
439 );
440 map
441 },
442 ..Default::default()
443 }),
444 );
445 map
446 },
447 ..Default::default()
448 }
449}