Skip to main content

jacquard_api/tools_ozone/set/
get_values.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.set.getValues
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, 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    ///Defaults to `100`. Min: 1. Max: 1000.
25    #[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    /// set with the given name does not exist
64    #[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
83/// Response type for tools.ozone.set.getValues
84pub 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
98/// Endpoint type for tools.ozone.set.getValues
99pub 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    /// State trait tracking which required fields have been set
120    pub trait State: sealed::Sealed {
121        type Name;
122    }
123    /// Empty state - all required fields are unset
124    pub struct Empty(());
125    impl sealed::Sealed for Empty {}
126    impl State for Empty {
127        type Name = Unset;
128    }
129    ///State transition - sets the `name` field to Set
130    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    /// Marker types for field names
136    #[allow(non_camel_case_types)]
137    pub mod members {
138        ///Marker type for the `name` field
139        pub struct name(());
140    }
141}
142
143/// Builder for constructing an instance of this type
144pub 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    /// Create a new builder for this type
152    pub fn new() -> GetValuesBuilder<'a, get_values_state::Empty> {
153        GetValuesBuilder::new()
154    }
155}
156
157impl<'a> GetValuesBuilder<'a, get_values_state::Empty> {
158    /// Create a new builder with all fields unset
159    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    /// Set the `cursor` field (optional)
170    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
171        self._fields.0 = value.into();
172        self
173    }
174    /// Set the `cursor` field to an Option value (optional)
175    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    /// Set the `limit` field (optional)
183    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
184        self._fields.1 = value.into();
185        self
186    }
187    /// Set the `limit` field to an Option value (optional)
188    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    /// Set the `name` field (required)
200    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    /// Build the final struct
219    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}