jacquard_api/tools_ozone/set/
delete_values.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.set.deleteValues
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct DeleteValues<'a> {
20    /// Name of the set to delete values from
21    #[serde(borrow)]
22    pub name: jacquard_common::CowStr<'a>,
23    /// Array of string values to delete from the set
24    #[serde(borrow)]
25    pub values: Vec<jacquard_common::CowStr<'a>>,
26}
27
28pub mod delete_values_state {
29
30    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
31    #[allow(unused)]
32    use ::core::marker::PhantomData;
33    mod sealed {
34        pub trait Sealed {}
35    }
36    /// State trait tracking which required fields have been set
37    pub trait State: sealed::Sealed {
38        type Name;
39        type Values;
40    }
41    /// Empty state - all required fields are unset
42    pub struct Empty(());
43    impl sealed::Sealed for Empty {}
44    impl State for Empty {
45        type Name = Unset;
46        type Values = Unset;
47    }
48    ///State transition - sets the `name` field to Set
49    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
50    impl<S: State> sealed::Sealed for SetName<S> {}
51    impl<S: State> State for SetName<S> {
52        type Name = Set<members::name>;
53        type Values = S::Values;
54    }
55    ///State transition - sets the `values` field to Set
56    pub struct SetValues<S: State = Empty>(PhantomData<fn() -> S>);
57    impl<S: State> sealed::Sealed for SetValues<S> {}
58    impl<S: State> State for SetValues<S> {
59        type Name = S::Name;
60        type Values = Set<members::values>;
61    }
62    /// Marker types for field names
63    #[allow(non_camel_case_types)]
64    pub mod members {
65        ///Marker type for the `name` field
66        pub struct name(());
67        ///Marker type for the `values` field
68        pub struct values(());
69    }
70}
71
72/// Builder for constructing an instance of this type
73pub struct DeleteValuesBuilder<'a, S: delete_values_state::State> {
74    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
75    __unsafe_private_named: (
76        ::core::option::Option<jacquard_common::CowStr<'a>>,
77        ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
78    ),
79    _phantom: ::core::marker::PhantomData<&'a ()>,
80}
81
82impl<'a> DeleteValues<'a> {
83    /// Create a new builder for this type
84    pub fn new() -> DeleteValuesBuilder<'a, delete_values_state::Empty> {
85        DeleteValuesBuilder::new()
86    }
87}
88
89impl<'a> DeleteValuesBuilder<'a, delete_values_state::Empty> {
90    /// Create a new builder with all fields unset
91    pub fn new() -> Self {
92        DeleteValuesBuilder {
93            _phantom_state: ::core::marker::PhantomData,
94            __unsafe_private_named: (None, None),
95            _phantom: ::core::marker::PhantomData,
96        }
97    }
98}
99
100impl<'a, S> DeleteValuesBuilder<'a, S>
101where
102    S: delete_values_state::State,
103    S::Name: delete_values_state::IsUnset,
104{
105    /// Set the `name` field (required)
106    pub fn name(
107        mut self,
108        value: impl Into<jacquard_common::CowStr<'a>>,
109    ) -> DeleteValuesBuilder<'a, delete_values_state::SetName<S>> {
110        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
111        DeleteValuesBuilder {
112            _phantom_state: ::core::marker::PhantomData,
113            __unsafe_private_named: self.__unsafe_private_named,
114            _phantom: ::core::marker::PhantomData,
115        }
116    }
117}
118
119impl<'a, S> DeleteValuesBuilder<'a, S>
120where
121    S: delete_values_state::State,
122    S::Values: delete_values_state::IsUnset,
123{
124    /// Set the `values` field (required)
125    pub fn values(
126        mut self,
127        value: impl Into<Vec<jacquard_common::CowStr<'a>>>,
128    ) -> DeleteValuesBuilder<'a, delete_values_state::SetValues<S>> {
129        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
130        DeleteValuesBuilder {
131            _phantom_state: ::core::marker::PhantomData,
132            __unsafe_private_named: self.__unsafe_private_named,
133            _phantom: ::core::marker::PhantomData,
134        }
135    }
136}
137
138impl<'a, S> DeleteValuesBuilder<'a, S>
139where
140    S: delete_values_state::State,
141    S::Name: delete_values_state::IsSet,
142    S::Values: delete_values_state::IsSet,
143{
144    /// Build the final struct
145    pub fn build(self) -> DeleteValues<'a> {
146        DeleteValues {
147            name: self.__unsafe_private_named.0.unwrap(),
148            values: self.__unsafe_private_named.1.unwrap(),
149            extra_data: Default::default(),
150        }
151    }
152    /// Build the final struct with custom extra_data
153    pub fn build_with_data(
154        self,
155        extra_data: std::collections::BTreeMap<
156            jacquard_common::smol_str::SmolStr,
157            jacquard_common::types::value::Data<'a>,
158        >,
159    ) -> DeleteValues<'a> {
160        DeleteValues {
161            name: self.__unsafe_private_named.0.unwrap(),
162            values: self.__unsafe_private_named.1.unwrap(),
163            extra_data: Some(extra_data),
164        }
165    }
166}
167
168#[jacquard_derive::open_union]
169#[derive(
170    serde::Serialize,
171    serde::Deserialize,
172    Debug,
173    Clone,
174    PartialEq,
175    Eq,
176    thiserror::Error,
177    miette::Diagnostic,
178    jacquard_derive::IntoStatic
179)]
180#[serde(tag = "error", content = "message")]
181#[serde(bound(deserialize = "'de: 'a"))]
182pub enum DeleteValuesError<'a> {
183    /// set with the given name does not exist
184    #[serde(rename = "SetNotFound")]
185    SetNotFound(std::option::Option<String>),
186}
187
188impl std::fmt::Display for DeleteValuesError<'_> {
189    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
190        match self {
191            Self::SetNotFound(msg) => {
192                write!(f, "SetNotFound")?;
193                if let Some(msg) = msg {
194                    write!(f, ": {}", msg)?;
195                }
196                Ok(())
197            }
198            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
199        }
200    }
201}
202
203/// Response type for
204///tools.ozone.set.deleteValues
205pub struct DeleteValuesResponse;
206impl jacquard_common::xrpc::XrpcResp for DeleteValuesResponse {
207    const NSID: &'static str = "tools.ozone.set.deleteValues";
208    const ENCODING: &'static str = "application/json";
209    type Output<'de> = ();
210    type Err<'de> = DeleteValuesError<'de>;
211}
212
213impl<'a> jacquard_common::xrpc::XrpcRequest for DeleteValues<'a> {
214    const NSID: &'static str = "tools.ozone.set.deleteValues";
215    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
216        "application/json",
217    );
218    type Response = DeleteValuesResponse;
219}
220
221/// Endpoint type for
222///tools.ozone.set.deleteValues
223pub struct DeleteValuesRequest;
224impl jacquard_common::xrpc::XrpcEndpoint for DeleteValuesRequest {
225    const PATH: &'static str = "/xrpc/tools.ozone.set.deleteValues";
226    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
227        "application/json",
228    );
229    type Request<'de> = DeleteValues<'de>;
230    type Response = DeleteValuesResponse;
231}