Skip to main content

jacquard_api/sh_weaver/notebook/
get_published_versions.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.getPublishedVersions
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_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    /// Defaults to `false`.
25    #[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    ///Full entry records if includeContent=true
41    #[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
48/// Response type for sh.weaver.notebook.getPublishedVersions
49pub 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
63/// Endpoint type for sh.weaver.notebook.getPublishedVersions
64pub 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    /// State trait tracking which required fields have been set
85    pub trait State: sealed::Sealed {
86        type Entry;
87    }
88    /// Empty state - all required fields are unset
89    pub struct Empty(());
90    impl sealed::Sealed for Empty {}
91    impl State for Empty {
92        type Entry = Unset;
93    }
94    ///State transition - sets the `entry` field to Set
95    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    /// Marker types for field names
101    #[allow(non_camel_case_types)]
102    pub mod members {
103        ///Marker type for the `entry` field
104        pub struct entry(());
105    }
106}
107
108/// Builder for constructing an instance of this type
109pub 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    /// Create a new builder for this type
117    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    /// Create a new builder with all fields unset
127    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    /// Set the `entry` field (required)
142    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    /// Set the `includeContent` field (optional)
157    pub fn include_content(mut self, value: impl Into<Option<bool>>) -> Self {
158        self._fields.1 = value.into();
159        self
160    }
161    /// Set the `includeContent` field to an Option value (optional)
162    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    /// Build the final struct
174    pub fn build(self) -> GetPublishedVersions<'a> {
175        GetPublishedVersions {
176            entry: self._fields.0.unwrap(),
177            include_content: self._fields.1,
178        }
179    }
180}