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