Skip to main content

jacquard_api/sh_weaver/notebook/
get_notebook.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.getNotebook
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::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
37/// Response type for sh.weaver.notebook.getNotebook
38pub 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
52/// Endpoint type for sh.weaver.notebook.getNotebook
53pub 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    /// State trait tracking which required fields have been set
70    pub trait State: sealed::Sealed {
71        type Notebook;
72    }
73    /// Empty state - all required fields are unset
74    pub struct Empty(());
75    impl sealed::Sealed for Empty {}
76    impl State for Empty {
77        type Notebook = Unset;
78    }
79    ///State transition - sets the `notebook` field to Set
80    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    /// Marker types for field names
86    #[allow(non_camel_case_types)]
87    pub mod members {
88        ///Marker type for the `notebook` field
89        pub struct notebook(());
90    }
91}
92
93/// Builder for constructing an instance of this type
94pub 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    /// Create a new builder for this type
102    pub fn new() -> GetNotebookBuilder<'a, get_notebook_state::Empty> {
103        GetNotebookBuilder::new()
104    }
105}
106
107impl<'a> GetNotebookBuilder<'a, get_notebook_state::Empty> {
108    /// Create a new builder with all fields unset
109    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    /// Set the `notebook` field (required)
124    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    /// Build the final struct
143    pub fn build(self) -> GetNotebook<'a> {
144        GetNotebook {
145            notebook: self._fields.0.unwrap(),
146        }
147    }
148}