jacquard_api/tools_ozone/setting/
list_options.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::Nsid;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17use crate::tools_ozone::setting::DefsOption;
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct ListOptions<'a> {
22 #[serde(skip_serializing_if = "Option::is_none")]
23 #[serde(borrow)]
24 pub cursor: Option<CowStr<'a>>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 #[serde(borrow)]
27 pub keys: Option<Vec<Nsid<'a>>>,
28 #[serde(default = "_default_limit")]
30 #[serde(skip_serializing_if = "Option::is_none")]
31 pub limit: Option<i64>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 #[serde(borrow)]
34 pub prefix: Option<CowStr<'a>>,
35 #[serde(default = "_default_scope")]
37 #[serde(skip_serializing_if = "Option::is_none")]
38 #[serde(borrow)]
39 pub scope: Option<CowStr<'a>>,
40}
41
42
43#[lexicon]
44#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
45#[serde(rename_all = "camelCase")]
46pub struct ListOptionsOutput<'a> {
47 #[serde(skip_serializing_if = "Option::is_none")]
48 #[serde(borrow)]
49 pub cursor: Option<CowStr<'a>>,
50 #[serde(borrow)]
51 pub options: Vec<DefsOption<'a>>,
52}
53
54pub struct ListOptionsResponse;
56impl jacquard_common::xrpc::XrpcResp for ListOptionsResponse {
57 const NSID: &'static str = "tools.ozone.setting.listOptions";
58 const ENCODING: &'static str = "application/json";
59 type Output<'de> = ListOptionsOutput<'de>;
60 type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
61}
62
63impl<'a> jacquard_common::xrpc::XrpcRequest for ListOptions<'a> {
64 const NSID: &'static str = "tools.ozone.setting.listOptions";
65 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
66 type Response = ListOptionsResponse;
67}
68
69pub struct ListOptionsRequest;
71impl jacquard_common::xrpc::XrpcEndpoint for ListOptionsRequest {
72 const PATH: &'static str = "/xrpc/tools.ozone.setting.listOptions";
73 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
74 type Request<'de> = ListOptions<'de>;
75 type Response = ListOptionsResponse;
76}
77
78fn _default_limit() -> Option<i64> {
79 Some(50i64)
80}
81
82fn _default_scope() -> Option<CowStr<'static>> {
83 Some(CowStr::from("instance"))
84}
85
86pub mod list_options_state {
87
88 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
89 #[allow(unused)]
90 use ::core::marker::PhantomData;
91 mod sealed {
92 pub trait Sealed {}
93 }
94 pub trait State: sealed::Sealed {}
96 pub struct Empty(());
98 impl sealed::Sealed for Empty {}
99 impl State for Empty {}
100 #[allow(non_camel_case_types)]
102 pub mod members {}
103}
104
105pub struct ListOptionsBuilder<'a, S: list_options_state::State> {
107 _state: PhantomData<fn() -> S>,
108 _fields: (
109 Option<CowStr<'a>>,
110 Option<Vec<Nsid<'a>>>,
111 Option<i64>,
112 Option<CowStr<'a>>,
113 Option<CowStr<'a>>,
114 ),
115 _lifetime: PhantomData<&'a ()>,
116}
117
118impl<'a> ListOptions<'a> {
119 pub fn new() -> ListOptionsBuilder<'a, list_options_state::Empty> {
121 ListOptionsBuilder::new()
122 }
123}
124
125impl<'a> ListOptionsBuilder<'a, list_options_state::Empty> {
126 pub fn new() -> Self {
128 ListOptionsBuilder {
129 _state: PhantomData,
130 _fields: (None, None, None, None, None),
131 _lifetime: PhantomData,
132 }
133 }
134}
135
136impl<'a, S: list_options_state::State> ListOptionsBuilder<'a, S> {
137 pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
139 self._fields.0 = value.into();
140 self
141 }
142 pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
144 self._fields.0 = value;
145 self
146 }
147}
148
149impl<'a, S: list_options_state::State> ListOptionsBuilder<'a, S> {
150 pub fn keys(mut self, value: impl Into<Option<Vec<Nsid<'a>>>>) -> Self {
152 self._fields.1 = value.into();
153 self
154 }
155 pub fn maybe_keys(mut self, value: Option<Vec<Nsid<'a>>>) -> Self {
157 self._fields.1 = value;
158 self
159 }
160}
161
162impl<'a, S: list_options_state::State> ListOptionsBuilder<'a, S> {
163 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
165 self._fields.2 = value.into();
166 self
167 }
168 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
170 self._fields.2 = value;
171 self
172 }
173}
174
175impl<'a, S: list_options_state::State> ListOptionsBuilder<'a, S> {
176 pub fn prefix(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
178 self._fields.3 = value.into();
179 self
180 }
181 pub fn maybe_prefix(mut self, value: Option<CowStr<'a>>) -> Self {
183 self._fields.3 = value;
184 self
185 }
186}
187
188impl<'a, S: list_options_state::State> ListOptionsBuilder<'a, S> {
189 pub fn scope(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
191 self._fields.4 = value.into();
192 self
193 }
194 pub fn maybe_scope(mut self, value: Option<CowStr<'a>>) -> Self {
196 self._fields.4 = value;
197 self
198 }
199}
200
201impl<'a, S> ListOptionsBuilder<'a, S>
202where
203 S: list_options_state::State,
204{
205 pub fn build(self) -> ListOptions<'a> {
207 ListOptions {
208 cursor: self._fields.0,
209 keys: self._fields.1,
210 limit: self._fields.2,
211 prefix: self._fields.3,
212 scope: self._fields.4,
213 }
214 }
215}