Skip to main content

jacquard_api/tools_ozone/setting/
list_options.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.setting.listOptions
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::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    ///Defaults to `50`. Min: 1. Max: 100.
29    #[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    ///Defaults to `"instance"`.
36    #[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
54/// Response type for tools.ozone.setting.listOptions
55pub 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
69/// Endpoint type for tools.ozone.setting.listOptions
70pub 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    /// State trait tracking which required fields have been set
95    pub trait State: sealed::Sealed {}
96    /// Empty state - all required fields are unset
97    pub struct Empty(());
98    impl sealed::Sealed for Empty {}
99    impl State for Empty {}
100    /// Marker types for field names
101    #[allow(non_camel_case_types)]
102    pub mod members {}
103}
104
105/// Builder for constructing an instance of this type
106pub 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    /// Create a new builder for this type
120    pub fn new() -> ListOptionsBuilder<'a, list_options_state::Empty> {
121        ListOptionsBuilder::new()
122    }
123}
124
125impl<'a> ListOptionsBuilder<'a, list_options_state::Empty> {
126    /// Create a new builder with all fields unset
127    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    /// Set the `cursor` field (optional)
138    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
139        self._fields.0 = value.into();
140        self
141    }
142    /// Set the `cursor` field to an Option value (optional)
143    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    /// Set the `keys` field (optional)
151    pub fn keys(mut self, value: impl Into<Option<Vec<Nsid<'a>>>>) -> Self {
152        self._fields.1 = value.into();
153        self
154    }
155    /// Set the `keys` field to an Option value (optional)
156    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    /// Set the `limit` field (optional)
164    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
165        self._fields.2 = value.into();
166        self
167    }
168    /// Set the `limit` field to an Option value (optional)
169    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    /// Set the `prefix` field (optional)
177    pub fn prefix(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
178        self._fields.3 = value.into();
179        self
180    }
181    /// Set the `prefix` field to an Option value (optional)
182    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    /// Set the `scope` field (optional)
190    pub fn scope(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
191        self._fields.4 = value.into();
192        self
193    }
194    /// Set the `scope` field to an Option value (optional)
195    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    /// Build the final struct
206    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}