jacquard_api/tools_ozone/set/
get_values.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_derive::{IntoStatic, lexicon, open_union};
15use serde::{Serialize, Deserialize};
16use crate::tools_ozone::set::SetView;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetValues<'a> {
21 #[serde(skip_serializing_if = "Option::is_none")]
22 #[serde(borrow)]
23 pub cursor: Option<CowStr<'a>>,
24 #[serde(default = "_default_limit")]
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub limit: Option<i64>,
28 #[serde(borrow)]
29 pub name: CowStr<'a>,
30}
31
32
33#[lexicon]
34#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
35#[serde(rename_all = "camelCase")]
36pub struct GetValuesOutput<'a> {
37 #[serde(skip_serializing_if = "Option::is_none")]
38 #[serde(borrow)]
39 pub cursor: Option<CowStr<'a>>,
40 #[serde(borrow)]
41 pub set: SetView<'a>,
42 #[serde(borrow)]
43 pub values: Vec<CowStr<'a>>,
44}
45
46
47#[open_union]
48#[derive(
49 Serialize,
50 Deserialize,
51 Debug,
52 Clone,
53 PartialEq,
54 Eq,
55 thiserror::Error,
56 miette::Diagnostic,
57 IntoStatic
58)]
59
60#[serde(tag = "error", content = "message")]
61#[serde(bound(deserialize = "'de: 'a"))]
62pub enum GetValuesError<'a> {
63 #[serde(rename = "SetNotFound")]
65 SetNotFound(Option<CowStr<'a>>),
66}
67
68impl core::fmt::Display for GetValuesError<'_> {
69 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
70 match self {
71 Self::SetNotFound(msg) => {
72 write!(f, "SetNotFound")?;
73 if let Some(msg) = msg {
74 write!(f, ": {}", msg)?;
75 }
76 Ok(())
77 }
78 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
79 }
80 }
81}
82
83pub struct GetValuesResponse;
85impl jacquard_common::xrpc::XrpcResp for GetValuesResponse {
86 const NSID: &'static str = "tools.ozone.set.getValues";
87 const ENCODING: &'static str = "application/json";
88 type Output<'de> = GetValuesOutput<'de>;
89 type Err<'de> = GetValuesError<'de>;
90}
91
92impl<'a> jacquard_common::xrpc::XrpcRequest for GetValues<'a> {
93 const NSID: &'static str = "tools.ozone.set.getValues";
94 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
95 type Response = GetValuesResponse;
96}
97
98pub struct GetValuesRequest;
100impl jacquard_common::xrpc::XrpcEndpoint for GetValuesRequest {
101 const PATH: &'static str = "/xrpc/tools.ozone.set.getValues";
102 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
103 type Request<'de> = GetValues<'de>;
104 type Response = GetValuesResponse;
105}
106
107fn _default_limit() -> Option<i64> {
108 Some(100i64)
109}
110
111pub mod get_values_state {
112
113 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
114 #[allow(unused)]
115 use ::core::marker::PhantomData;
116 mod sealed {
117 pub trait Sealed {}
118 }
119 pub trait State: sealed::Sealed {
121 type Name;
122 }
123 pub struct Empty(());
125 impl sealed::Sealed for Empty {}
126 impl State for Empty {
127 type Name = Unset;
128 }
129 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
131 impl<S: State> sealed::Sealed for SetName<S> {}
132 impl<S: State> State for SetName<S> {
133 type Name = Set<members::name>;
134 }
135 #[allow(non_camel_case_types)]
137 pub mod members {
138 pub struct name(());
140 }
141}
142
143pub struct GetValuesBuilder<'a, S: get_values_state::State> {
145 _state: PhantomData<fn() -> S>,
146 _fields: (Option<CowStr<'a>>, Option<i64>, Option<CowStr<'a>>),
147 _lifetime: PhantomData<&'a ()>,
148}
149
150impl<'a> GetValues<'a> {
151 pub fn new() -> GetValuesBuilder<'a, get_values_state::Empty> {
153 GetValuesBuilder::new()
154 }
155}
156
157impl<'a> GetValuesBuilder<'a, get_values_state::Empty> {
158 pub fn new() -> Self {
160 GetValuesBuilder {
161 _state: PhantomData,
162 _fields: (None, None, None),
163 _lifetime: PhantomData,
164 }
165 }
166}
167
168impl<'a, S: get_values_state::State> GetValuesBuilder<'a, S> {
169 pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
171 self._fields.0 = value.into();
172 self
173 }
174 pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
176 self._fields.0 = value;
177 self
178 }
179}
180
181impl<'a, S: get_values_state::State> GetValuesBuilder<'a, S> {
182 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
184 self._fields.1 = value.into();
185 self
186 }
187 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
189 self._fields.1 = value;
190 self
191 }
192}
193
194impl<'a, S> GetValuesBuilder<'a, S>
195where
196 S: get_values_state::State,
197 S::Name: get_values_state::IsUnset,
198{
199 pub fn name(
201 mut self,
202 value: impl Into<CowStr<'a>>,
203 ) -> GetValuesBuilder<'a, get_values_state::SetName<S>> {
204 self._fields.2 = Option::Some(value.into());
205 GetValuesBuilder {
206 _state: PhantomData,
207 _fields: self._fields,
208 _lifetime: PhantomData,
209 }
210 }
211}
212
213impl<'a, S> GetValuesBuilder<'a, S>
214where
215 S: get_values_state::State,
216 S::Name: get_values_state::IsSet,
217{
218 pub fn build(self) -> GetValues<'a> {
220 GetValues {
221 cursor: self._fields.0,
222 limit: self._fields.1,
223 name: self._fields.2.unwrap(),
224 }
225 }
226}