Skip to main content

jacquard_api/app_bsky/
video.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.video.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod get_job_status;
9pub mod get_upload_limits;
10pub mod upload_video;
11
12
13#[allow(unused_imports)]
14use alloc::collections::BTreeMap;
15
16#[allow(unused_imports)]
17use core::marker::PhantomData;
18use jacquard_common::CowStr;
19
20#[allow(unused_imports)]
21use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
22use jacquard_common::types::blob::BlobRef;
23use jacquard_common::types::string::Did;
24use jacquard_derive::{IntoStatic, lexicon};
25use jacquard_lexicon::lexicon::LexiconDoc;
26use jacquard_lexicon::schema::LexiconSchema;
27
28#[allow(unused_imports)]
29use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
30use serde::{Serialize, Deserialize};
31
32#[lexicon]
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
34#[serde(rename_all = "camelCase")]
35pub struct JobStatus<'a> {
36    #[serde(skip_serializing_if = "Option::is_none")]
37    #[serde(borrow)]
38    pub blob: Option<BlobRef<'a>>,
39    #[serde(borrow)]
40    pub did: Did<'a>,
41    #[serde(skip_serializing_if = "Option::is_none")]
42    #[serde(borrow)]
43    pub error: Option<CowStr<'a>>,
44    #[serde(borrow)]
45    pub job_id: CowStr<'a>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    #[serde(borrow)]
48    pub message: Option<CowStr<'a>>,
49    ///Progress within the current processing state.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub progress: Option<i64>,
52    ///The state of the video processing job. All values not listed as a known value indicate that the job is in process.
53    #[serde(borrow)]
54    pub state: JobStatusState<'a>,
55}
56
57/// The state of the video processing job. All values not listed as a known value indicate that the job is in process.
58
59#[derive(Debug, Clone, PartialEq, Eq, Hash)]
60pub enum JobStatusState<'a> {
61    JobStateCompleted,
62    JobStateFailed,
63    Other(CowStr<'a>),
64}
65
66impl<'a> JobStatusState<'a> {
67    pub fn as_str(&self) -> &str {
68        match self {
69            Self::JobStateCompleted => "JOB_STATE_COMPLETED",
70            Self::JobStateFailed => "JOB_STATE_FAILED",
71            Self::Other(s) => s.as_ref(),
72        }
73    }
74}
75
76impl<'a> From<&'a str> for JobStatusState<'a> {
77    fn from(s: &'a str) -> Self {
78        match s {
79            "JOB_STATE_COMPLETED" => Self::JobStateCompleted,
80            "JOB_STATE_FAILED" => Self::JobStateFailed,
81            _ => Self::Other(CowStr::from(s)),
82        }
83    }
84}
85
86impl<'a> From<String> for JobStatusState<'a> {
87    fn from(s: String) -> Self {
88        match s.as_str() {
89            "JOB_STATE_COMPLETED" => Self::JobStateCompleted,
90            "JOB_STATE_FAILED" => Self::JobStateFailed,
91            _ => Self::Other(CowStr::from(s)),
92        }
93    }
94}
95
96impl<'a> core::fmt::Display for JobStatusState<'a> {
97    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
98        write!(f, "{}", self.as_str())
99    }
100}
101
102impl<'a> AsRef<str> for JobStatusState<'a> {
103    fn as_ref(&self) -> &str {
104        self.as_str()
105    }
106}
107
108impl<'a> serde::Serialize for JobStatusState<'a> {
109    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
110    where
111        S: serde::Serializer,
112    {
113        serializer.serialize_str(self.as_str())
114    }
115}
116
117impl<'de, 'a> serde::Deserialize<'de> for JobStatusState<'a>
118where
119    'de: 'a,
120{
121    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
122    where
123        D: serde::Deserializer<'de>,
124    {
125        let s = <&'de str>::deserialize(deserializer)?;
126        Ok(Self::from(s))
127    }
128}
129
130impl<'a> Default for JobStatusState<'a> {
131    fn default() -> Self {
132        Self::Other(Default::default())
133    }
134}
135
136impl jacquard_common::IntoStatic for JobStatusState<'_> {
137    type Output = JobStatusState<'static>;
138    fn into_static(self) -> Self::Output {
139        match self {
140            JobStatusState::JobStateCompleted => JobStatusState::JobStateCompleted,
141            JobStatusState::JobStateFailed => JobStatusState::JobStateFailed,
142            JobStatusState::Other(v) => JobStatusState::Other(v.into_static()),
143        }
144    }
145}
146
147impl<'a> LexiconSchema for JobStatus<'a> {
148    fn nsid() -> &'static str {
149        "app.bsky.video.defs"
150    }
151    fn def_name() -> &'static str {
152        "jobStatus"
153    }
154    fn lexicon_doc() -> LexiconDoc<'static> {
155        lexicon_doc_app_bsky_video_defs()
156    }
157    fn validate(&self) -> Result<(), ConstraintError> {
158        if let Some(ref value) = self.progress {
159            if *value > 100i64 {
160                return Err(ConstraintError::Maximum {
161                    path: ValidationPath::from_field("progress"),
162                    max: 100i64,
163                    actual: *value,
164                });
165            }
166        }
167        if let Some(ref value) = self.progress {
168            if *value < 0i64 {
169                return Err(ConstraintError::Minimum {
170                    path: ValidationPath::from_field("progress"),
171                    min: 0i64,
172                    actual: *value,
173                });
174            }
175        }
176        Ok(())
177    }
178}
179
180pub mod job_status_state {
181
182    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
183    #[allow(unused)]
184    use ::core::marker::PhantomData;
185    mod sealed {
186        pub trait Sealed {}
187    }
188    /// State trait tracking which required fields have been set
189    pub trait State: sealed::Sealed {
190        type Did;
191        type State;
192        type JobId;
193    }
194    /// Empty state - all required fields are unset
195    pub struct Empty(());
196    impl sealed::Sealed for Empty {}
197    impl State for Empty {
198        type Did = Unset;
199        type State = Unset;
200        type JobId = Unset;
201    }
202    ///State transition - sets the `did` field to Set
203    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
204    impl<S: State> sealed::Sealed for SetDid<S> {}
205    impl<S: State> State for SetDid<S> {
206        type Did = Set<members::did>;
207        type State = S::State;
208        type JobId = S::JobId;
209    }
210    ///State transition - sets the `state` field to Set
211    pub struct SetState<S: State = Empty>(PhantomData<fn() -> S>);
212    impl<S: State> sealed::Sealed for SetState<S> {}
213    impl<S: State> State for SetState<S> {
214        type Did = S::Did;
215        type State = Set<members::state>;
216        type JobId = S::JobId;
217    }
218    ///State transition - sets the `job_id` field to Set
219    pub struct SetJobId<S: State = Empty>(PhantomData<fn() -> S>);
220    impl<S: State> sealed::Sealed for SetJobId<S> {}
221    impl<S: State> State for SetJobId<S> {
222        type Did = S::Did;
223        type State = S::State;
224        type JobId = Set<members::job_id>;
225    }
226    /// Marker types for field names
227    #[allow(non_camel_case_types)]
228    pub mod members {
229        ///Marker type for the `did` field
230        pub struct did(());
231        ///Marker type for the `state` field
232        pub struct state(());
233        ///Marker type for the `job_id` field
234        pub struct job_id(());
235    }
236}
237
238/// Builder for constructing an instance of this type
239pub struct JobStatusBuilder<'a, S: job_status_state::State> {
240    _state: PhantomData<fn() -> S>,
241    _fields: (
242        Option<BlobRef<'a>>,
243        Option<Did<'a>>,
244        Option<CowStr<'a>>,
245        Option<CowStr<'a>>,
246        Option<CowStr<'a>>,
247        Option<i64>,
248        Option<JobStatusState<'a>>,
249    ),
250    _lifetime: PhantomData<&'a ()>,
251}
252
253impl<'a> JobStatus<'a> {
254    /// Create a new builder for this type
255    pub fn new() -> JobStatusBuilder<'a, job_status_state::Empty> {
256        JobStatusBuilder::new()
257    }
258}
259
260impl<'a> JobStatusBuilder<'a, job_status_state::Empty> {
261    /// Create a new builder with all fields unset
262    pub fn new() -> Self {
263        JobStatusBuilder {
264            _state: PhantomData,
265            _fields: (None, None, None, None, None, None, None),
266            _lifetime: PhantomData,
267        }
268    }
269}
270
271impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
272    /// Set the `blob` field (optional)
273    pub fn blob(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
274        self._fields.0 = value.into();
275        self
276    }
277    /// Set the `blob` field to an Option value (optional)
278    pub fn maybe_blob(mut self, value: Option<BlobRef<'a>>) -> Self {
279        self._fields.0 = value;
280        self
281    }
282}
283
284impl<'a, S> JobStatusBuilder<'a, S>
285where
286    S: job_status_state::State,
287    S::Did: job_status_state::IsUnset,
288{
289    /// Set the `did` field (required)
290    pub fn did(
291        mut self,
292        value: impl Into<Did<'a>>,
293    ) -> JobStatusBuilder<'a, job_status_state::SetDid<S>> {
294        self._fields.1 = Option::Some(value.into());
295        JobStatusBuilder {
296            _state: PhantomData,
297            _fields: self._fields,
298            _lifetime: PhantomData,
299        }
300    }
301}
302
303impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
304    /// Set the `error` field (optional)
305    pub fn error(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
306        self._fields.2 = value.into();
307        self
308    }
309    /// Set the `error` field to an Option value (optional)
310    pub fn maybe_error(mut self, value: Option<CowStr<'a>>) -> Self {
311        self._fields.2 = value;
312        self
313    }
314}
315
316impl<'a, S> JobStatusBuilder<'a, S>
317where
318    S: job_status_state::State,
319    S::JobId: job_status_state::IsUnset,
320{
321    /// Set the `jobId` field (required)
322    pub fn job_id(
323        mut self,
324        value: impl Into<CowStr<'a>>,
325    ) -> JobStatusBuilder<'a, job_status_state::SetJobId<S>> {
326        self._fields.3 = Option::Some(value.into());
327        JobStatusBuilder {
328            _state: PhantomData,
329            _fields: self._fields,
330            _lifetime: PhantomData,
331        }
332    }
333}
334
335impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
336    /// Set the `message` field (optional)
337    pub fn message(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
338        self._fields.4 = value.into();
339        self
340    }
341    /// Set the `message` field to an Option value (optional)
342    pub fn maybe_message(mut self, value: Option<CowStr<'a>>) -> Self {
343        self._fields.4 = value;
344        self
345    }
346}
347
348impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
349    /// Set the `progress` field (optional)
350    pub fn progress(mut self, value: impl Into<Option<i64>>) -> Self {
351        self._fields.5 = value.into();
352        self
353    }
354    /// Set the `progress` field to an Option value (optional)
355    pub fn maybe_progress(mut self, value: Option<i64>) -> Self {
356        self._fields.5 = value;
357        self
358    }
359}
360
361impl<'a, S> JobStatusBuilder<'a, S>
362where
363    S: job_status_state::State,
364    S::State: job_status_state::IsUnset,
365{
366    /// Set the `state` field (required)
367    pub fn state(
368        mut self,
369        value: impl Into<JobStatusState<'a>>,
370    ) -> JobStatusBuilder<'a, job_status_state::SetState<S>> {
371        self._fields.6 = Option::Some(value.into());
372        JobStatusBuilder {
373            _state: PhantomData,
374            _fields: self._fields,
375            _lifetime: PhantomData,
376        }
377    }
378}
379
380impl<'a, S> JobStatusBuilder<'a, S>
381where
382    S: job_status_state::State,
383    S::Did: job_status_state::IsSet,
384    S::State: job_status_state::IsSet,
385    S::JobId: job_status_state::IsSet,
386{
387    /// Build the final struct
388    pub fn build(self) -> JobStatus<'a> {
389        JobStatus {
390            blob: self._fields.0,
391            did: self._fields.1.unwrap(),
392            error: self._fields.2,
393            job_id: self._fields.3.unwrap(),
394            message: self._fields.4,
395            progress: self._fields.5,
396            state: self._fields.6.unwrap(),
397            extra_data: Default::default(),
398        }
399    }
400    /// Build the final struct with custom extra_data
401    pub fn build_with_data(
402        self,
403        extra_data: BTreeMap<
404            jacquard_common::deps::smol_str::SmolStr,
405            jacquard_common::types::value::Data<'a>,
406        >,
407    ) -> JobStatus<'a> {
408        JobStatus {
409            blob: self._fields.0,
410            did: self._fields.1.unwrap(),
411            error: self._fields.2,
412            job_id: self._fields.3.unwrap(),
413            message: self._fields.4,
414            progress: self._fields.5,
415            state: self._fields.6.unwrap(),
416            extra_data: Some(extra_data),
417        }
418    }
419}
420
421fn lexicon_doc_app_bsky_video_defs() -> LexiconDoc<'static> {
422    #[allow(unused_imports)]
423    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
424    use jacquard_lexicon::lexicon::*;
425    use alloc::collections::BTreeMap;
426    LexiconDoc {
427        lexicon: Lexicon::Lexicon1,
428        id: CowStr::new_static("app.bsky.video.defs"),
429        defs: {
430            let mut map = BTreeMap::new();
431            map.insert(
432                SmolStr::new_static("jobStatus"),
433                LexUserType::Object(LexObject {
434                    required: Some(
435                        vec![
436                            SmolStr::new_static("jobId"), SmolStr::new_static("did"),
437                            SmolStr::new_static("state")
438                        ],
439                    ),
440                    properties: {
441                        #[allow(unused_mut)]
442                        let mut map = BTreeMap::new();
443                        map.insert(
444                            SmolStr::new_static("blob"),
445                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
446                        );
447                        map.insert(
448                            SmolStr::new_static("did"),
449                            LexObjectProperty::String(LexString {
450                                format: Some(LexStringFormat::Did),
451                                ..Default::default()
452                            }),
453                        );
454                        map.insert(
455                            SmolStr::new_static("error"),
456                            LexObjectProperty::String(LexString { ..Default::default() }),
457                        );
458                        map.insert(
459                            SmolStr::new_static("jobId"),
460                            LexObjectProperty::String(LexString { ..Default::default() }),
461                        );
462                        map.insert(
463                            SmolStr::new_static("message"),
464                            LexObjectProperty::String(LexString { ..Default::default() }),
465                        );
466                        map.insert(
467                            SmolStr::new_static("progress"),
468                            LexObjectProperty::Integer(LexInteger {
469                                minimum: Some(0i64),
470                                maximum: Some(100i64),
471                                ..Default::default()
472                            }),
473                        );
474                        map.insert(
475                            SmolStr::new_static("state"),
476                            LexObjectProperty::String(LexString {
477                                description: Some(
478                                    CowStr::new_static(
479                                        "The state of the video processing job. All values not listed as a known value indicate that the job is in process.",
480                                    ),
481                                ),
482                                ..Default::default()
483                            }),
484                        );
485                        map
486                    },
487                    ..Default::default()
488                }),
489            );
490            map
491        },
492        ..Default::default()
493    }
494}