atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.getPage
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9 serde::Serialize,
10 serde::Deserialize,
11 Debug,
12 Clone,
13 PartialEq,
14 Eq,
15 jacquard_derive::IntoStatic
16)]
17#[serde(rename_all = "camelCase")]
18pub struct GetPage<'a> {
19 #[serde(borrow)]
20 pub page: jacquard_common::types::string::AtUri<'a>,
21}
22
23pub mod get_page_state {
24
25 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
26 #[allow(unused)]
27 use ::core::marker::PhantomData;
28 mod sealed {
29 pub trait Sealed {}
30 }
31 /// State trait tracking which required fields have been set
32 pub trait State: sealed::Sealed {
33 type Page;
34 }
35 /// Empty state - all required fields are unset
36 pub struct Empty(());
37 impl sealed::Sealed for Empty {}
38 impl State for Empty {
39 type Page = Unset;
40 }
41 ///State transition - sets the `page` field to Set
42 pub struct SetPage<S: State = Empty>(PhantomData<fn() -> S>);
43 impl<S: State> sealed::Sealed for SetPage<S> {}
44 impl<S: State> State for SetPage<S> {
45 type Page = Set<members::page>;
46 }
47 /// Marker types for field names
48 #[allow(non_camel_case_types)]
49 pub mod members {
50 ///Marker type for the `page` field
51 pub struct page(());
52 }
53}
54
55/// Builder for constructing an instance of this type
56pub struct GetPageBuilder<'a, S: get_page_state::State> {
57 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
58 __unsafe_private_named: (
59 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
60 ),
61 _phantom: ::core::marker::PhantomData<&'a ()>,
62}
63
64impl<'a> GetPage<'a> {
65 /// Create a new builder for this type
66 pub fn new() -> GetPageBuilder<'a, get_page_state::Empty> {
67 GetPageBuilder::new()
68 }
69}
70
71impl<'a> GetPageBuilder<'a, get_page_state::Empty> {
72 /// Create a new builder with all fields unset
73 pub fn new() -> Self {
74 GetPageBuilder {
75 _phantom_state: ::core::marker::PhantomData,
76 __unsafe_private_named: (None,),
77 _phantom: ::core::marker::PhantomData,
78 }
79 }
80}
81
82impl<'a, S> GetPageBuilder<'a, S>
83where
84 S: get_page_state::State,
85 S::Page: get_page_state::IsUnset,
86{
87 /// Set the `page` field (required)
88 pub fn page(
89 mut self,
90 value: impl Into<jacquard_common::types::string::AtUri<'a>>,
91 ) -> GetPageBuilder<'a, get_page_state::SetPage<S>> {
92 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
93 GetPageBuilder {
94 _phantom_state: ::core::marker::PhantomData,
95 __unsafe_private_named: self.__unsafe_private_named,
96 _phantom: ::core::marker::PhantomData,
97 }
98 }
99}
100
101impl<'a, S> GetPageBuilder<'a, S>
102where
103 S: get_page_state::State,
104 S::Page: get_page_state::IsSet,
105{
106 /// Build the final struct
107 pub fn build(self) -> GetPage<'a> {
108 GetPage {
109 page: self.__unsafe_private_named.0.unwrap(),
110 }
111 }
112}
113
114#[jacquard_derive::lexicon]
115#[derive(
116 serde::Serialize,
117 serde::Deserialize,
118 Debug,
119 Clone,
120 PartialEq,
121 Eq,
122 jacquard_derive::IntoStatic
123)]
124#[serde(rename_all = "camelCase")]
125pub struct GetPageOutput<'a> {
126 #[serde(borrow)]
127 pub entries: Vec<crate::sh_weaver::notebook::EntryView<'a>>,
128 #[serde(borrow)]
129 pub page: crate::sh_weaver::notebook::PageView<'a>,
130}
131
132#[jacquard_derive::open_union]
133#[derive(
134 serde::Serialize,
135 serde::Deserialize,
136 Debug,
137 Clone,
138 PartialEq,
139 Eq,
140 thiserror::Error,
141 miette::Diagnostic,
142 jacquard_derive::IntoStatic
143)]
144#[serde(tag = "error", content = "message")]
145#[serde(bound(deserialize = "'de: 'a"))]
146pub enum GetPageError<'a> {
147 #[serde(rename = "PageNotFound")]
148 PageNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
149}
150
151impl core::fmt::Display for GetPageError<'_> {
152 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
153 match self {
154 Self::PageNotFound(msg) => {
155 write!(f, "PageNotFound")?;
156 if let Some(msg) = msg {
157 write!(f, ": {}", msg)?;
158 }
159 Ok(())
160 }
161 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
162 }
163 }
164}
165
166/// Response type for
167///sh.weaver.notebook.getPage
168pub struct GetPageResponse;
169impl jacquard_common::xrpc::XrpcResp for GetPageResponse {
170 const NSID: &'static str = "sh.weaver.notebook.getPage";
171 const ENCODING: &'static str = "application/json";
172 type Output<'de> = GetPageOutput<'de>;
173 type Err<'de> = GetPageError<'de>;
174}
175
176impl<'a> jacquard_common::xrpc::XrpcRequest for GetPage<'a> {
177 const NSID: &'static str = "sh.weaver.notebook.getPage";
178 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
179 type Response = GetPageResponse;
180}
181
182/// Endpoint type for
183///sh.weaver.notebook.getPage
184pub struct GetPageRequest;
185impl jacquard_common::xrpc::XrpcEndpoint for GetPageRequest {
186 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getPage";
187 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
188 type Request<'de> = GetPage<'de>;
189 type Response = GetPageResponse;
190}