jacquard_api/sh_weaver/notebook/
get_notebook.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::types::string::AtUri;
14use jacquard_derive::{IntoStatic, lexicon};
15use serde::{Serialize, Deserialize};
16use crate::com_atproto::repo::strong_ref::StrongRef;
17use crate::sh_weaver::notebook::NotebookView;
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct GetNotebook<'a> {
22 #[serde(borrow)]
23 pub notebook: AtUri<'a>,
24}
25
26
27#[lexicon]
28#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
29#[serde(rename_all = "camelCase")]
30pub struct GetNotebookOutput<'a> {
31 #[serde(borrow)]
32 pub entries: Vec<StrongRef<'a>>,
33 #[serde(borrow)]
34 pub notebook: NotebookView<'a>,
35}
36
37pub struct GetNotebookResponse;
39impl jacquard_common::xrpc::XrpcResp for GetNotebookResponse {
40 const NSID: &'static str = "sh.weaver.notebook.getNotebook";
41 const ENCODING: &'static str = "application/json";
42 type Output<'de> = GetNotebookOutput<'de>;
43 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
44}
45
46impl<'a> jacquard_common::xrpc::XrpcRequest for GetNotebook<'a> {
47 const NSID: &'static str = "sh.weaver.notebook.getNotebook";
48 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
49 type Response = GetNotebookResponse;
50}
51
52pub struct GetNotebookRequest;
54impl jacquard_common::xrpc::XrpcEndpoint for GetNotebookRequest {
55 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getNotebook";
56 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
57 type Request<'de> = GetNotebook<'de>;
58 type Response = GetNotebookResponse;
59}
60
61pub mod get_notebook_state {
62
63 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
64 #[allow(unused)]
65 use ::core::marker::PhantomData;
66 mod sealed {
67 pub trait Sealed {}
68 }
69 pub trait State: sealed::Sealed {
71 type Notebook;
72 }
73 pub struct Empty(());
75 impl sealed::Sealed for Empty {}
76 impl State for Empty {
77 type Notebook = Unset;
78 }
79 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
81 impl<S: State> sealed::Sealed for SetNotebook<S> {}
82 impl<S: State> State for SetNotebook<S> {
83 type Notebook = Set<members::notebook>;
84 }
85 #[allow(non_camel_case_types)]
87 pub mod members {
88 pub struct notebook(());
90 }
91}
92
93pub struct GetNotebookBuilder<'a, S: get_notebook_state::State> {
95 _state: PhantomData<fn() -> S>,
96 _fields: (Option<AtUri<'a>>,),
97 _lifetime: PhantomData<&'a ()>,
98}
99
100impl<'a> GetNotebook<'a> {
101 pub fn new() -> GetNotebookBuilder<'a, get_notebook_state::Empty> {
103 GetNotebookBuilder::new()
104 }
105}
106
107impl<'a> GetNotebookBuilder<'a, get_notebook_state::Empty> {
108 pub fn new() -> Self {
110 GetNotebookBuilder {
111 _state: PhantomData,
112 _fields: (None,),
113 _lifetime: PhantomData,
114 }
115 }
116}
117
118impl<'a, S> GetNotebookBuilder<'a, S>
119where
120 S: get_notebook_state::State,
121 S::Notebook: get_notebook_state::IsUnset,
122{
123 pub fn notebook(
125 mut self,
126 value: impl Into<AtUri<'a>>,
127 ) -> GetNotebookBuilder<'a, get_notebook_state::SetNotebook<S>> {
128 self._fields.0 = Option::Some(value.into());
129 GetNotebookBuilder {
130 _state: PhantomData,
131 _fields: self._fields,
132 _lifetime: PhantomData,
133 }
134 }
135}
136
137impl<'a, S> GetNotebookBuilder<'a, S>
138where
139 S: get_notebook_state::State,
140 S::Notebook: get_notebook_state::IsSet,
141{
142 pub fn build(self) -> GetNotebook<'a> {
144 GetNotebook {
145 notebook: self._fields.0.unwrap(),
146 }
147 }
148}