Skip to main content

jacquard_api/tools_ozone/set/
query_sets.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.set.querySets
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_derive::{IntoStatic, lexicon};
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 QuerySets<'a> {
21    #[serde(skip_serializing_if = "Option::is_none")]
22    #[serde(borrow)]
23    pub cursor: Option<CowStr<'a>>,
24    ///Defaults to `50`. Min: 1. Max: 100.
25    #[serde(default = "_default_limit")]
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub limit: Option<i64>,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    #[serde(borrow)]
30    pub name_prefix: Option<CowStr<'a>>,
31    ///Defaults to `"name"`.
32    #[serde(default = "_default_sort_by")]
33    #[serde(skip_serializing_if = "Option::is_none")]
34    #[serde(borrow)]
35    pub sort_by: Option<CowStr<'a>>,
36    ///Defaults to `"asc"`.
37    #[serde(default = "_default_sort_direction")]
38    #[serde(skip_serializing_if = "Option::is_none")]
39    #[serde(borrow)]
40    pub sort_direction: Option<CowStr<'a>>,
41}
42
43
44#[lexicon]
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
46#[serde(rename_all = "camelCase")]
47pub struct QuerySetsOutput<'a> {
48    #[serde(skip_serializing_if = "Option::is_none")]
49    #[serde(borrow)]
50    pub cursor: Option<CowStr<'a>>,
51    #[serde(borrow)]
52    pub sets: Vec<SetView<'a>>,
53}
54
55/// Response type for tools.ozone.set.querySets
56pub struct QuerySetsResponse;
57impl jacquard_common::xrpc::XrpcResp for QuerySetsResponse {
58    const NSID: &'static str = "tools.ozone.set.querySets";
59    const ENCODING: &'static str = "application/json";
60    type Output<'de> = QuerySetsOutput<'de>;
61    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
62}
63
64impl<'a> jacquard_common::xrpc::XrpcRequest for QuerySets<'a> {
65    const NSID: &'static str = "tools.ozone.set.querySets";
66    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
67    type Response = QuerySetsResponse;
68}
69
70/// Endpoint type for tools.ozone.set.querySets
71pub struct QuerySetsRequest;
72impl jacquard_common::xrpc::XrpcEndpoint for QuerySetsRequest {
73    const PATH: &'static str = "/xrpc/tools.ozone.set.querySets";
74    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
75    type Request<'de> = QuerySets<'de>;
76    type Response = QuerySetsResponse;
77}
78
79fn _default_limit() -> Option<i64> {
80    Some(50i64)
81}
82
83fn _default_sort_by() -> Option<CowStr<'static>> {
84    Some(CowStr::from("name"))
85}
86
87fn _default_sort_direction() -> Option<CowStr<'static>> {
88    Some(CowStr::from("asc"))
89}
90
91pub mod query_sets_state {
92
93    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
94    #[allow(unused)]
95    use ::core::marker::PhantomData;
96    mod sealed {
97        pub trait Sealed {}
98    }
99    /// State trait tracking which required fields have been set
100    pub trait State: sealed::Sealed {}
101    /// Empty state - all required fields are unset
102    pub struct Empty(());
103    impl sealed::Sealed for Empty {}
104    impl State for Empty {}
105    /// Marker types for field names
106    #[allow(non_camel_case_types)]
107    pub mod members {}
108}
109
110/// Builder for constructing an instance of this type
111pub struct QuerySetsBuilder<'a, S: query_sets_state::State> {
112    _state: PhantomData<fn() -> S>,
113    _fields: (
114        Option<CowStr<'a>>,
115        Option<i64>,
116        Option<CowStr<'a>>,
117        Option<CowStr<'a>>,
118        Option<CowStr<'a>>,
119    ),
120    _lifetime: PhantomData<&'a ()>,
121}
122
123impl<'a> QuerySets<'a> {
124    /// Create a new builder for this type
125    pub fn new() -> QuerySetsBuilder<'a, query_sets_state::Empty> {
126        QuerySetsBuilder::new()
127    }
128}
129
130impl<'a> QuerySetsBuilder<'a, query_sets_state::Empty> {
131    /// Create a new builder with all fields unset
132    pub fn new() -> Self {
133        QuerySetsBuilder {
134            _state: PhantomData,
135            _fields: (None, None, None, None, None),
136            _lifetime: PhantomData,
137        }
138    }
139}
140
141impl<'a, S: query_sets_state::State> QuerySetsBuilder<'a, S> {
142    /// Set the `cursor` field (optional)
143    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
144        self._fields.0 = value.into();
145        self
146    }
147    /// Set the `cursor` field to an Option value (optional)
148    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
149        self._fields.0 = value;
150        self
151    }
152}
153
154impl<'a, S: query_sets_state::State> QuerySetsBuilder<'a, S> {
155    /// Set the `limit` field (optional)
156    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
157        self._fields.1 = value.into();
158        self
159    }
160    /// Set the `limit` field to an Option value (optional)
161    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
162        self._fields.1 = value;
163        self
164    }
165}
166
167impl<'a, S: query_sets_state::State> QuerySetsBuilder<'a, S> {
168    /// Set the `namePrefix` field (optional)
169    pub fn name_prefix(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
170        self._fields.2 = value.into();
171        self
172    }
173    /// Set the `namePrefix` field to an Option value (optional)
174    pub fn maybe_name_prefix(mut self, value: Option<CowStr<'a>>) -> Self {
175        self._fields.2 = value;
176        self
177    }
178}
179
180impl<'a, S: query_sets_state::State> QuerySetsBuilder<'a, S> {
181    /// Set the `sortBy` field (optional)
182    pub fn sort_by(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
183        self._fields.3 = value.into();
184        self
185    }
186    /// Set the `sortBy` field to an Option value (optional)
187    pub fn maybe_sort_by(mut self, value: Option<CowStr<'a>>) -> Self {
188        self._fields.3 = value;
189        self
190    }
191}
192
193impl<'a, S: query_sets_state::State> QuerySetsBuilder<'a, S> {
194    /// Set the `sortDirection` field (optional)
195    pub fn sort_direction(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
196        self._fields.4 = value.into();
197        self
198    }
199    /// Set the `sortDirection` field to an Option value (optional)
200    pub fn maybe_sort_direction(mut self, value: Option<CowStr<'a>>) -> Self {
201        self._fields.4 = value;
202        self
203    }
204}
205
206impl<'a, S> QuerySetsBuilder<'a, S>
207where
208    S: query_sets_state::State,
209{
210    /// Build the final struct
211    pub fn build(self) -> QuerySets<'a> {
212        QuerySets {
213            cursor: self._fields.0,
214            limit: self._fields.1,
215            name_prefix: self._fields.2,
216            sort_by: self._fields.3,
217            sort_direction: self._fields.4,
218        }
219    }
220}