jacquard_api/network_slices/tools/bug/
issue.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::collection::{Collection, RecordError};
18use jacquard_common::types::string::{AtUri, Cid, Datetime};
19use jacquard_common::types::uri::{RecordUri, UriError};
20use jacquard_common::xrpc::XrpcResp;
21use jacquard_derive::{IntoStatic, lexicon};
22use jacquard_lexicon::lexicon::LexiconDoc;
23use jacquard_lexicon::schema::LexiconSchema;
24
25#[allow(unused_imports)]
26use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
27use serde::{Serialize, Deserialize};
28
29#[lexicon]
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
31#[serde(
32 rename_all = "camelCase",
33 rename = "network.slices.tools.bug.issue",
34 tag = "$type"
35)]
36pub struct Issue<'a> {
37 #[serde(borrow)]
39 pub bug: AtUri<'a>,
40 pub created_at: Datetime,
41 #[serde(borrow)]
43 pub issue: AtUri<'a>,
44}
45
46#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
49#[serde(rename_all = "camelCase")]
50pub struct IssueGetRecordOutput<'a> {
51 #[serde(skip_serializing_if = "Option::is_none")]
52 #[serde(borrow)]
53 pub cid: Option<Cid<'a>>,
54 #[serde(borrow)]
55 pub uri: AtUri<'a>,
56 #[serde(borrow)]
57 pub value: Issue<'a>,
58}
59
60impl<'a> Issue<'a> {
61 pub fn uri(
62 uri: impl Into<CowStr<'a>>,
63 ) -> Result<RecordUri<'a, IssueRecord>, UriError> {
64 RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
65 }
66}
67
68#[derive(Debug, Serialize, Deserialize)]
71pub struct IssueRecord;
72impl XrpcResp for IssueRecord {
73 const NSID: &'static str = "network.slices.tools.bug.issue";
74 const ENCODING: &'static str = "application/json";
75 type Output<'de> = IssueGetRecordOutput<'de>;
76 type Err<'de> = RecordError<'de>;
77}
78
79impl From<IssueGetRecordOutput<'_>> for Issue<'_> {
80 fn from(output: IssueGetRecordOutput<'_>) -> Self {
81 use jacquard_common::IntoStatic;
82 output.value.into_static()
83 }
84}
85
86impl Collection for Issue<'_> {
87 const NSID: &'static str = "network.slices.tools.bug.issue";
88 type Record = IssueRecord;
89}
90
91impl Collection for IssueRecord {
92 const NSID: &'static str = "network.slices.tools.bug.issue";
93 type Record = IssueRecord;
94}
95
96impl<'a> LexiconSchema for Issue<'a> {
97 fn nsid() -> &'static str {
98 "network.slices.tools.bug.issue"
99 }
100 fn def_name() -> &'static str {
101 "main"
102 }
103 fn lexicon_doc() -> LexiconDoc<'static> {
104 lexicon_doc_network_slices_tools_bug_issue()
105 }
106 fn validate(&self) -> Result<(), ConstraintError> {
107 Ok(())
108 }
109}
110
111pub mod issue_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 pub trait State: sealed::Sealed {
121 type Bug;
122 type Issue;
123 type CreatedAt;
124 }
125 pub struct Empty(());
127 impl sealed::Sealed for Empty {}
128 impl State for Empty {
129 type Bug = Unset;
130 type Issue = Unset;
131 type CreatedAt = Unset;
132 }
133 pub struct SetBug<S: State = Empty>(PhantomData<fn() -> S>);
135 impl<S: State> sealed::Sealed for SetBug<S> {}
136 impl<S: State> State for SetBug<S> {
137 type Bug = Set<members::bug>;
138 type Issue = S::Issue;
139 type CreatedAt = S::CreatedAt;
140 }
141 pub struct SetIssue<S: State = Empty>(PhantomData<fn() -> S>);
143 impl<S: State> sealed::Sealed for SetIssue<S> {}
144 impl<S: State> State for SetIssue<S> {
145 type Bug = S::Bug;
146 type Issue = Set<members::issue>;
147 type CreatedAt = S::CreatedAt;
148 }
149 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
151 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
152 impl<S: State> State for SetCreatedAt<S> {
153 type Bug = S::Bug;
154 type Issue = S::Issue;
155 type CreatedAt = Set<members::created_at>;
156 }
157 #[allow(non_camel_case_types)]
159 pub mod members {
160 pub struct bug(());
162 pub struct issue(());
164 pub struct created_at(());
166 }
167}
168
169pub struct IssueBuilder<'a, S: issue_state::State> {
171 _state: PhantomData<fn() -> S>,
172 _fields: (Option<AtUri<'a>>, Option<Datetime>, Option<AtUri<'a>>),
173 _lifetime: PhantomData<&'a ()>,
174}
175
176impl<'a> Issue<'a> {
177 pub fn new() -> IssueBuilder<'a, issue_state::Empty> {
179 IssueBuilder::new()
180 }
181}
182
183impl<'a> IssueBuilder<'a, issue_state::Empty> {
184 pub fn new() -> Self {
186 IssueBuilder {
187 _state: PhantomData,
188 _fields: (None, None, None),
189 _lifetime: PhantomData,
190 }
191 }
192}
193
194impl<'a, S> IssueBuilder<'a, S>
195where
196 S: issue_state::State,
197 S::Bug: issue_state::IsUnset,
198{
199 pub fn bug(
201 mut self,
202 value: impl Into<AtUri<'a>>,
203 ) -> IssueBuilder<'a, issue_state::SetBug<S>> {
204 self._fields.0 = Option::Some(value.into());
205 IssueBuilder {
206 _state: PhantomData,
207 _fields: self._fields,
208 _lifetime: PhantomData,
209 }
210 }
211}
212
213impl<'a, S> IssueBuilder<'a, S>
214where
215 S: issue_state::State,
216 S::CreatedAt: issue_state::IsUnset,
217{
218 pub fn created_at(
220 mut self,
221 value: impl Into<Datetime>,
222 ) -> IssueBuilder<'a, issue_state::SetCreatedAt<S>> {
223 self._fields.1 = Option::Some(value.into());
224 IssueBuilder {
225 _state: PhantomData,
226 _fields: self._fields,
227 _lifetime: PhantomData,
228 }
229 }
230}
231
232impl<'a, S> IssueBuilder<'a, S>
233where
234 S: issue_state::State,
235 S::Issue: issue_state::IsUnset,
236{
237 pub fn issue(
239 mut self,
240 value: impl Into<AtUri<'a>>,
241 ) -> IssueBuilder<'a, issue_state::SetIssue<S>> {
242 self._fields.2 = Option::Some(value.into());
243 IssueBuilder {
244 _state: PhantomData,
245 _fields: self._fields,
246 _lifetime: PhantomData,
247 }
248 }
249}
250
251impl<'a, S> IssueBuilder<'a, S>
252where
253 S: issue_state::State,
254 S::Bug: issue_state::IsSet,
255 S::Issue: issue_state::IsSet,
256 S::CreatedAt: issue_state::IsSet,
257{
258 pub fn build(self) -> Issue<'a> {
260 Issue {
261 bug: self._fields.0.unwrap(),
262 created_at: self._fields.1.unwrap(),
263 issue: self._fields.2.unwrap(),
264 extra_data: Default::default(),
265 }
266 }
267 pub fn build_with_data(
269 self,
270 extra_data: BTreeMap<
271 jacquard_common::deps::smol_str::SmolStr,
272 jacquard_common::types::value::Data<'a>,
273 >,
274 ) -> Issue<'a> {
275 Issue {
276 bug: self._fields.0.unwrap(),
277 created_at: self._fields.1.unwrap(),
278 issue: self._fields.2.unwrap(),
279 extra_data: Some(extra_data),
280 }
281 }
282}
283
284fn lexicon_doc_network_slices_tools_bug_issue() -> LexiconDoc<'static> {
285 #[allow(unused_imports)]
286 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
287 use jacquard_lexicon::lexicon::*;
288 use alloc::collections::BTreeMap;
289 LexiconDoc {
290 lexicon: Lexicon::Lexicon1,
291 id: CowStr::new_static("network.slices.tools.bug.issue"),
292 defs: {
293 let mut map = BTreeMap::new();
294 map.insert(
295 SmolStr::new_static("main"),
296 LexUserType::Record(LexRecord {
297 key: Some(CowStr::new_static("tid")),
298 record: LexRecordRecord::Object(LexObject {
299 required: Some(
300 vec![
301 SmolStr::new_static("bug"), SmolStr::new_static("issue"),
302 SmolStr::new_static("createdAt")
303 ],
304 ),
305 properties: {
306 #[allow(unused_mut)]
307 let mut map = BTreeMap::new();
308 map.insert(
309 SmolStr::new_static("bug"),
310 LexObjectProperty::String(LexString {
311 description: Some(
312 CowStr::new_static("Reference to the bug report"),
313 ),
314 format: Some(LexStringFormat::AtUri),
315 ..Default::default()
316 }),
317 );
318 map.insert(
319 SmolStr::new_static("createdAt"),
320 LexObjectProperty::String(LexString {
321 format: Some(LexStringFormat::Datetime),
322 ..Default::default()
323 }),
324 );
325 map.insert(
326 SmolStr::new_static("issue"),
327 LexObjectProperty::String(LexString {
328 description: Some(
329 CowStr::new_static("Reference to the linked issue"),
330 ),
331 format: Some(LexStringFormat::AtUri),
332 ..Default::default()
333 }),
334 );
335 map
336 },
337 ..Default::default()
338 }),
339 ..Default::default()
340 }),
341 );
342 map
343 },
344 ..Default::default()
345 }
346}