Skip to main content

jacquard_api/tools_ozone/set/
add_values.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.set.addValues
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};
16
17#[lexicon]
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct AddValues<'a> {
21    ///Name of the set to add values to
22    #[serde(borrow)]
23    pub name: CowStr<'a>,
24    ///Array of string values to add to the set
25    #[serde(borrow)]
26    pub values: Vec<CowStr<'a>>,
27}
28
29/// Response type for tools.ozone.set.addValues
30pub struct AddValuesResponse;
31impl jacquard_common::xrpc::XrpcResp for AddValuesResponse {
32    const NSID: &'static str = "tools.ozone.set.addValues";
33    const ENCODING: &'static str = "application/json";
34    type Output<'de> = ();
35    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
36}
37
38impl<'a> jacquard_common::xrpc::XrpcRequest for AddValues<'a> {
39    const NSID: &'static str = "tools.ozone.set.addValues";
40    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
41        "application/json",
42    );
43    type Response = AddValuesResponse;
44}
45
46/// Endpoint type for tools.ozone.set.addValues
47pub struct AddValuesRequest;
48impl jacquard_common::xrpc::XrpcEndpoint for AddValuesRequest {
49    const PATH: &'static str = "/xrpc/tools.ozone.set.addValues";
50    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
51        "application/json",
52    );
53    type Request<'de> = AddValues<'de>;
54    type Response = AddValuesResponse;
55}
56
57pub mod add_values_state {
58
59    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
60    #[allow(unused)]
61    use ::core::marker::PhantomData;
62    mod sealed {
63        pub trait Sealed {}
64    }
65    /// State trait tracking which required fields have been set
66    pub trait State: sealed::Sealed {
67        type Values;
68        type Name;
69    }
70    /// Empty state - all required fields are unset
71    pub struct Empty(());
72    impl sealed::Sealed for Empty {}
73    impl State for Empty {
74        type Values = Unset;
75        type Name = Unset;
76    }
77    ///State transition - sets the `values` field to Set
78    pub struct SetValues<S: State = Empty>(PhantomData<fn() -> S>);
79    impl<S: State> sealed::Sealed for SetValues<S> {}
80    impl<S: State> State for SetValues<S> {
81        type Values = Set<members::values>;
82        type Name = S::Name;
83    }
84    ///State transition - sets the `name` field to Set
85    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
86    impl<S: State> sealed::Sealed for SetName<S> {}
87    impl<S: State> State for SetName<S> {
88        type Values = S::Values;
89        type Name = Set<members::name>;
90    }
91    /// Marker types for field names
92    #[allow(non_camel_case_types)]
93    pub mod members {
94        ///Marker type for the `values` field
95        pub struct values(());
96        ///Marker type for the `name` field
97        pub struct name(());
98    }
99}
100
101/// Builder for constructing an instance of this type
102pub struct AddValuesBuilder<'a, S: add_values_state::State> {
103    _state: PhantomData<fn() -> S>,
104    _fields: (Option<CowStr<'a>>, Option<Vec<CowStr<'a>>>),
105    _lifetime: PhantomData<&'a ()>,
106}
107
108impl<'a> AddValues<'a> {
109    /// Create a new builder for this type
110    pub fn new() -> AddValuesBuilder<'a, add_values_state::Empty> {
111        AddValuesBuilder::new()
112    }
113}
114
115impl<'a> AddValuesBuilder<'a, add_values_state::Empty> {
116    /// Create a new builder with all fields unset
117    pub fn new() -> Self {
118        AddValuesBuilder {
119            _state: PhantomData,
120            _fields: (None, None),
121            _lifetime: PhantomData,
122        }
123    }
124}
125
126impl<'a, S> AddValuesBuilder<'a, S>
127where
128    S: add_values_state::State,
129    S::Name: add_values_state::IsUnset,
130{
131    /// Set the `name` field (required)
132    pub fn name(
133        mut self,
134        value: impl Into<CowStr<'a>>,
135    ) -> AddValuesBuilder<'a, add_values_state::SetName<S>> {
136        self._fields.0 = Option::Some(value.into());
137        AddValuesBuilder {
138            _state: PhantomData,
139            _fields: self._fields,
140            _lifetime: PhantomData,
141        }
142    }
143}
144
145impl<'a, S> AddValuesBuilder<'a, S>
146where
147    S: add_values_state::State,
148    S::Values: add_values_state::IsUnset,
149{
150    /// Set the `values` field (required)
151    pub fn values(
152        mut self,
153        value: impl Into<Vec<CowStr<'a>>>,
154    ) -> AddValuesBuilder<'a, add_values_state::SetValues<S>> {
155        self._fields.1 = Option::Some(value.into());
156        AddValuesBuilder {
157            _state: PhantomData,
158            _fields: self._fields,
159            _lifetime: PhantomData,
160        }
161    }
162}
163
164impl<'a, S> AddValuesBuilder<'a, S>
165where
166    S: add_values_state::State,
167    S::Values: add_values_state::IsSet,
168    S::Name: add_values_state::IsSet,
169{
170    /// Build the final struct
171    pub fn build(self) -> AddValues<'a> {
172        AddValues {
173            name: self._fields.0.unwrap(),
174            values: self._fields.1.unwrap(),
175            extra_data: Default::default(),
176        }
177    }
178    /// Build the final struct with custom extra_data
179    pub fn build_with_data(
180        self,
181        extra_data: BTreeMap<
182            jacquard_common::deps::smol_str::SmolStr,
183            jacquard_common::types::value::Data<'a>,
184        >,
185    ) -> AddValues<'a> {
186        AddValues {
187            name: self._fields.0.unwrap(),
188            values: self._fields.1.unwrap(),
189            extra_data: Some(extra_data),
190        }
191    }
192}