jacquard_api/sh_weaver/notebook/
get_published_versions.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_common::types::value::Data;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17use crate::sh_weaver::notebook::PublishedVersionView;
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct GetPublishedVersions<'a> {
22 #[serde(borrow)]
23 pub entry: AtUri<'a>,
24 #[serde(default = "_default_include_content")]
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub include_content: Option<bool>,
28}
29
30
31#[lexicon]
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase")]
34pub struct GetPublishedVersionsOutput<'a> {
35 #[serde(skip_serializing_if = "Option::is_none")]
36 #[serde(borrow)]
37 pub canonical: Option<PublishedVersionView<'a>>,
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub has_divergence: Option<bool>,
40 #[serde(skip_serializing_if = "Option::is_none")]
42 #[serde(borrow)]
43 pub records: Option<Vec<Data<'a>>>,
44 #[serde(borrow)]
45 pub versions: Vec<PublishedVersionView<'a>>,
46}
47
48pub struct GetPublishedVersionsResponse;
50impl jacquard_common::xrpc::XrpcResp for GetPublishedVersionsResponse {
51 const NSID: &'static str = "sh.weaver.notebook.getPublishedVersions";
52 const ENCODING: &'static str = "application/json";
53 type Output<'de> = GetPublishedVersionsOutput<'de>;
54 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
55}
56
57impl<'a> jacquard_common::xrpc::XrpcRequest for GetPublishedVersions<'a> {
58 const NSID: &'static str = "sh.weaver.notebook.getPublishedVersions";
59 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
60 type Response = GetPublishedVersionsResponse;
61}
62
63pub struct GetPublishedVersionsRequest;
65impl jacquard_common::xrpc::XrpcEndpoint for GetPublishedVersionsRequest {
66 const PATH: &'static str = "/xrpc/sh.weaver.notebook.getPublishedVersions";
67 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
68 type Request<'de> = GetPublishedVersions<'de>;
69 type Response = GetPublishedVersionsResponse;
70}
71
72fn _default_include_content() -> Option<bool> {
73 Some(false)
74}
75
76pub mod get_published_versions_state {
77
78 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
79 #[allow(unused)]
80 use ::core::marker::PhantomData;
81 mod sealed {
82 pub trait Sealed {}
83 }
84 pub trait State: sealed::Sealed {
86 type Entry;
87 }
88 pub struct Empty(());
90 impl sealed::Sealed for Empty {}
91 impl State for Empty {
92 type Entry = Unset;
93 }
94 pub struct SetEntry<S: State = Empty>(PhantomData<fn() -> S>);
96 impl<S: State> sealed::Sealed for SetEntry<S> {}
97 impl<S: State> State for SetEntry<S> {
98 type Entry = Set<members::entry>;
99 }
100 #[allow(non_camel_case_types)]
102 pub mod members {
103 pub struct entry(());
105 }
106}
107
108pub struct GetPublishedVersionsBuilder<'a, S: get_published_versions_state::State> {
110 _state: PhantomData<fn() -> S>,
111 _fields: (Option<AtUri<'a>>, Option<bool>),
112 _lifetime: PhantomData<&'a ()>,
113}
114
115impl<'a> GetPublishedVersions<'a> {
116 pub fn new() -> GetPublishedVersionsBuilder<
118 'a,
119 get_published_versions_state::Empty,
120 > {
121 GetPublishedVersionsBuilder::new()
122 }
123}
124
125impl<'a> GetPublishedVersionsBuilder<'a, get_published_versions_state::Empty> {
126 pub fn new() -> Self {
128 GetPublishedVersionsBuilder {
129 _state: PhantomData,
130 _fields: (None, None),
131 _lifetime: PhantomData,
132 }
133 }
134}
135
136impl<'a, S> GetPublishedVersionsBuilder<'a, S>
137where
138 S: get_published_versions_state::State,
139 S::Entry: get_published_versions_state::IsUnset,
140{
141 pub fn entry(
143 mut self,
144 value: impl Into<AtUri<'a>>,
145 ) -> GetPublishedVersionsBuilder<'a, get_published_versions_state::SetEntry<S>> {
146 self._fields.0 = Option::Some(value.into());
147 GetPublishedVersionsBuilder {
148 _state: PhantomData,
149 _fields: self._fields,
150 _lifetime: PhantomData,
151 }
152 }
153}
154
155impl<'a, S: get_published_versions_state::State> GetPublishedVersionsBuilder<'a, S> {
156 pub fn include_content(mut self, value: impl Into<Option<bool>>) -> Self {
158 self._fields.1 = value.into();
159 self
160 }
161 pub fn maybe_include_content(mut self, value: Option<bool>) -> Self {
163 self._fields.1 = value;
164 self
165 }
166}
167
168impl<'a, S> GetPublishedVersionsBuilder<'a, S>
169where
170 S: get_published_versions_state::State,
171 S::Entry: get_published_versions_state::IsSet,
172{
173 pub fn build(self) -> GetPublishedVersions<'a> {
175 GetPublishedVersions {
176 entry: self._fields.0.unwrap(),
177 include_content: self._fields.1,
178 }
179 }
180}