1#[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::{Did, AtUri, Cid, Datetime};
19use jacquard_common::types::uri::{RecordUri, UriError};
20use jacquard_common::types::value::Data;
21use jacquard_common::xrpc::XrpcResp;
22use jacquard_derive::{IntoStatic, lexicon};
23use jacquard_lexicon::lexicon::LexiconDoc;
24use jacquard_lexicon::schema::LexiconSchema;
25
26#[allow(unused_imports)]
27use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
28use serde::{Serialize, Deserialize};
29use crate::place_stream::metadata::content_rights::ContentRights;
30use crate::place_stream::metadata::content_warnings::ContentWarnings;
31use crate::place_stream::metadata::distribution_policy::DistributionPolicy;
32use crate::place_stream::segment;
33
34#[lexicon]
35#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
36#[serde(rename_all = "camelCase")]
37pub struct Audio<'a> {
38 pub channels: i64,
39 #[serde(borrow)]
40 pub codec: CowStr<'a>,
41 pub rate: i64,
42}
43
44
45#[lexicon]
46#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
47#[serde(rename_all = "camelCase")]
48pub struct Framerate<'a> {
49 pub den: i64,
50 pub num: i64,
51}
52
53#[lexicon]
56#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
57#[serde(rename_all = "camelCase", rename = "place.stream.segment", tag = "$type")]
58pub struct Segment<'a> {
59 #[serde(skip_serializing_if = "Option::is_none")]
60 #[serde(borrow)]
61 pub audio: Option<Vec<segment::Audio<'a>>>,
62 #[serde(skip_serializing_if = "Option::is_none")]
63 #[serde(borrow)]
64 pub content_rights: Option<ContentRights<'a>>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 #[serde(borrow)]
67 pub content_warnings: Option<ContentWarnings<'a>>,
68 #[serde(borrow)]
69 pub creator: Did<'a>,
70 #[serde(skip_serializing_if = "Option::is_none")]
71 #[serde(borrow)]
72 pub distribution_policy: Option<DistributionPolicy<'a>>,
73 #[serde(skip_serializing_if = "Option::is_none")]
75 pub duration: Option<i64>,
76 #[serde(borrow)]
78 pub id: CowStr<'a>,
79 #[serde(borrow)]
81 pub signing_key: CowStr<'a>,
82 #[serde(skip_serializing_if = "Option::is_none")]
84 pub size: Option<i64>,
85 pub start_time: Datetime,
87 #[serde(skip_serializing_if = "Option::is_none")]
88 #[serde(borrow)]
89 pub video: Option<Vec<segment::Video<'a>>>,
90}
91
92#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
95#[serde(rename_all = "camelCase")]
96pub struct SegmentGetRecordOutput<'a> {
97 #[serde(skip_serializing_if = "Option::is_none")]
98 #[serde(borrow)]
99 pub cid: Option<Cid<'a>>,
100 #[serde(borrow)]
101 pub uri: AtUri<'a>,
102 #[serde(borrow)]
103 pub value: Segment<'a>,
104}
105
106
107#[lexicon]
108#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
109#[serde(rename_all = "camelCase")]
110pub struct SegmentView<'a> {
111 #[serde(borrow)]
112 pub cid: Cid<'a>,
113 #[serde(borrow)]
114 pub record: Data<'a>,
115}
116
117
118#[lexicon]
119#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
120#[serde(rename_all = "camelCase")]
121pub struct Video<'a> {
122 #[serde(skip_serializing_if = "Option::is_none")]
123 pub bframes: Option<bool>,
124 #[serde(borrow)]
125 pub codec: CowStr<'a>,
126 #[serde(skip_serializing_if = "Option::is_none")]
127 #[serde(borrow)]
128 pub framerate: Option<segment::Framerate<'a>>,
129 pub height: i64,
130 pub width: i64,
131}
132
133impl<'a> Segment<'a> {
134 pub fn uri(
135 uri: impl Into<CowStr<'a>>,
136 ) -> Result<RecordUri<'a, SegmentRecord>, UriError> {
137 RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
138 }
139}
140
141impl<'a> LexiconSchema for Audio<'a> {
142 fn nsid() -> &'static str {
143 "place.stream.segment"
144 }
145 fn def_name() -> &'static str {
146 "audio"
147 }
148 fn lexicon_doc() -> LexiconDoc<'static> {
149 lexicon_doc_place_stream_segment()
150 }
151 fn validate(&self) -> Result<(), ConstraintError> {
152 Ok(())
153 }
154}
155
156impl<'a> LexiconSchema for Framerate<'a> {
157 fn nsid() -> &'static str {
158 "place.stream.segment"
159 }
160 fn def_name() -> &'static str {
161 "framerate"
162 }
163 fn lexicon_doc() -> LexiconDoc<'static> {
164 lexicon_doc_place_stream_segment()
165 }
166 fn validate(&self) -> Result<(), ConstraintError> {
167 Ok(())
168 }
169}
170
171#[derive(Debug, Serialize, Deserialize)]
174pub struct SegmentRecord;
175impl XrpcResp for SegmentRecord {
176 const NSID: &'static str = "place.stream.segment";
177 const ENCODING: &'static str = "application/json";
178 type Output<'de> = SegmentGetRecordOutput<'de>;
179 type Err<'de> = RecordError<'de>;
180}
181
182impl From<SegmentGetRecordOutput<'_>> for Segment<'_> {
183 fn from(output: SegmentGetRecordOutput<'_>) -> Self {
184 use jacquard_common::IntoStatic;
185 output.value.into_static()
186 }
187}
188
189impl Collection for Segment<'_> {
190 const NSID: &'static str = "place.stream.segment";
191 type Record = SegmentRecord;
192}
193
194impl Collection for SegmentRecord {
195 const NSID: &'static str = "place.stream.segment";
196 type Record = SegmentRecord;
197}
198
199impl<'a> LexiconSchema for Segment<'a> {
200 fn nsid() -> &'static str {
201 "place.stream.segment"
202 }
203 fn def_name() -> &'static str {
204 "main"
205 }
206 fn lexicon_doc() -> LexiconDoc<'static> {
207 lexicon_doc_place_stream_segment()
208 }
209 fn validate(&self) -> Result<(), ConstraintError> {
210 Ok(())
211 }
212}
213
214impl<'a> LexiconSchema for SegmentView<'a> {
215 fn nsid() -> &'static str {
216 "place.stream.segment"
217 }
218 fn def_name() -> &'static str {
219 "segmentView"
220 }
221 fn lexicon_doc() -> LexiconDoc<'static> {
222 lexicon_doc_place_stream_segment()
223 }
224 fn validate(&self) -> Result<(), ConstraintError> {
225 Ok(())
226 }
227}
228
229impl<'a> LexiconSchema for Video<'a> {
230 fn nsid() -> &'static str {
231 "place.stream.segment"
232 }
233 fn def_name() -> &'static str {
234 "video"
235 }
236 fn lexicon_doc() -> LexiconDoc<'static> {
237 lexicon_doc_place_stream_segment()
238 }
239 fn validate(&self) -> Result<(), ConstraintError> {
240 Ok(())
241 }
242}
243
244pub mod audio_state {
245
246 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
247 #[allow(unused)]
248 use ::core::marker::PhantomData;
249 mod sealed {
250 pub trait Sealed {}
251 }
252 pub trait State: sealed::Sealed {
254 type Channels;
255 type Codec;
256 type Rate;
257 }
258 pub struct Empty(());
260 impl sealed::Sealed for Empty {}
261 impl State for Empty {
262 type Channels = Unset;
263 type Codec = Unset;
264 type Rate = Unset;
265 }
266 pub struct SetChannels<S: State = Empty>(PhantomData<fn() -> S>);
268 impl<S: State> sealed::Sealed for SetChannels<S> {}
269 impl<S: State> State for SetChannels<S> {
270 type Channels = Set<members::channels>;
271 type Codec = S::Codec;
272 type Rate = S::Rate;
273 }
274 pub struct SetCodec<S: State = Empty>(PhantomData<fn() -> S>);
276 impl<S: State> sealed::Sealed for SetCodec<S> {}
277 impl<S: State> State for SetCodec<S> {
278 type Channels = S::Channels;
279 type Codec = Set<members::codec>;
280 type Rate = S::Rate;
281 }
282 pub struct SetRate<S: State = Empty>(PhantomData<fn() -> S>);
284 impl<S: State> sealed::Sealed for SetRate<S> {}
285 impl<S: State> State for SetRate<S> {
286 type Channels = S::Channels;
287 type Codec = S::Codec;
288 type Rate = Set<members::rate>;
289 }
290 #[allow(non_camel_case_types)]
292 pub mod members {
293 pub struct channels(());
295 pub struct codec(());
297 pub struct rate(());
299 }
300}
301
302pub struct AudioBuilder<'a, S: audio_state::State> {
304 _state: PhantomData<fn() -> S>,
305 _fields: (Option<i64>, Option<CowStr<'a>>, Option<i64>),
306 _lifetime: PhantomData<&'a ()>,
307}
308
309impl<'a> Audio<'a> {
310 pub fn new() -> AudioBuilder<'a, audio_state::Empty> {
312 AudioBuilder::new()
313 }
314}
315
316impl<'a> AudioBuilder<'a, audio_state::Empty> {
317 pub fn new() -> Self {
319 AudioBuilder {
320 _state: PhantomData,
321 _fields: (None, None, None),
322 _lifetime: PhantomData,
323 }
324 }
325}
326
327impl<'a, S> AudioBuilder<'a, S>
328where
329 S: audio_state::State,
330 S::Channels: audio_state::IsUnset,
331{
332 pub fn channels(
334 mut self,
335 value: impl Into<i64>,
336 ) -> AudioBuilder<'a, audio_state::SetChannels<S>> {
337 self._fields.0 = Option::Some(value.into());
338 AudioBuilder {
339 _state: PhantomData,
340 _fields: self._fields,
341 _lifetime: PhantomData,
342 }
343 }
344}
345
346impl<'a, S> AudioBuilder<'a, S>
347where
348 S: audio_state::State,
349 S::Codec: audio_state::IsUnset,
350{
351 pub fn codec(
353 mut self,
354 value: impl Into<CowStr<'a>>,
355 ) -> AudioBuilder<'a, audio_state::SetCodec<S>> {
356 self._fields.1 = Option::Some(value.into());
357 AudioBuilder {
358 _state: PhantomData,
359 _fields: self._fields,
360 _lifetime: PhantomData,
361 }
362 }
363}
364
365impl<'a, S> AudioBuilder<'a, S>
366where
367 S: audio_state::State,
368 S::Rate: audio_state::IsUnset,
369{
370 pub fn rate(
372 mut self,
373 value: impl Into<i64>,
374 ) -> AudioBuilder<'a, audio_state::SetRate<S>> {
375 self._fields.2 = Option::Some(value.into());
376 AudioBuilder {
377 _state: PhantomData,
378 _fields: self._fields,
379 _lifetime: PhantomData,
380 }
381 }
382}
383
384impl<'a, S> AudioBuilder<'a, S>
385where
386 S: audio_state::State,
387 S::Channels: audio_state::IsSet,
388 S::Codec: audio_state::IsSet,
389 S::Rate: audio_state::IsSet,
390{
391 pub fn build(self) -> Audio<'a> {
393 Audio {
394 channels: self._fields.0.unwrap(),
395 codec: self._fields.1.unwrap(),
396 rate: self._fields.2.unwrap(),
397 extra_data: Default::default(),
398 }
399 }
400 pub fn build_with_data(
402 self,
403 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
404 ) -> Audio<'a> {
405 Audio {
406 channels: self._fields.0.unwrap(),
407 codec: self._fields.1.unwrap(),
408 rate: self._fields.2.unwrap(),
409 extra_data: Some(extra_data),
410 }
411 }
412}
413
414fn lexicon_doc_place_stream_segment() -> LexiconDoc<'static> {
415 #[allow(unused_imports)]
416 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
417 use jacquard_lexicon::lexicon::*;
418 use alloc::collections::BTreeMap;
419 LexiconDoc {
420 lexicon: Lexicon::Lexicon1,
421 id: CowStr::new_static("place.stream.segment"),
422 defs: {
423 let mut map = BTreeMap::new();
424 map.insert(
425 SmolStr::new_static("audio"),
426 LexUserType::Object(LexObject {
427 required: Some(
428 vec![
429 SmolStr::new_static("codec"), SmolStr::new_static("rate"),
430 SmolStr::new_static("channels")
431 ],
432 ),
433 properties: {
434 #[allow(unused_mut)]
435 let mut map = BTreeMap::new();
436 map.insert(
437 SmolStr::new_static("channels"),
438 LexObjectProperty::Integer(LexInteger {
439 ..Default::default()
440 }),
441 );
442 map.insert(
443 SmolStr::new_static("codec"),
444 LexObjectProperty::String(LexString { ..Default::default() }),
445 );
446 map.insert(
447 SmolStr::new_static("rate"),
448 LexObjectProperty::Integer(LexInteger {
449 ..Default::default()
450 }),
451 );
452 map
453 },
454 ..Default::default()
455 }),
456 );
457 map.insert(
458 SmolStr::new_static("framerate"),
459 LexUserType::Object(LexObject {
460 required: Some(
461 vec![SmolStr::new_static("num"), SmolStr::new_static("den")],
462 ),
463 properties: {
464 #[allow(unused_mut)]
465 let mut map = BTreeMap::new();
466 map.insert(
467 SmolStr::new_static("den"),
468 LexObjectProperty::Integer(LexInteger {
469 ..Default::default()
470 }),
471 );
472 map.insert(
473 SmolStr::new_static("num"),
474 LexObjectProperty::Integer(LexInteger {
475 ..Default::default()
476 }),
477 );
478 map
479 },
480 ..Default::default()
481 }),
482 );
483 map.insert(
484 SmolStr::new_static("main"),
485 LexUserType::Record(LexRecord {
486 description: Some(
487 CowStr::new_static(
488 "Media file representing a segment of a livestream",
489 ),
490 ),
491 key: Some(CowStr::new_static("tid")),
492 record: LexRecordRecord::Object(LexObject {
493 required: Some(
494 vec![
495 SmolStr::new_static("id"),
496 SmolStr::new_static("signingKey"),
497 SmolStr::new_static("startTime"),
498 SmolStr::new_static("creator")
499 ],
500 ),
501 properties: {
502 #[allow(unused_mut)]
503 let mut map = BTreeMap::new();
504 map.insert(
505 SmolStr::new_static("audio"),
506 LexObjectProperty::Array(LexArray {
507 items: LexArrayItem::Ref(LexRef {
508 r#ref: CowStr::new_static("#audio"),
509 ..Default::default()
510 }),
511 ..Default::default()
512 }),
513 );
514 map.insert(
515 SmolStr::new_static("contentRights"),
516 LexObjectProperty::Ref(LexRef {
517 r#ref: CowStr::new_static(
518 "place.stream.metadata.contentRights",
519 ),
520 ..Default::default()
521 }),
522 );
523 map.insert(
524 SmolStr::new_static("contentWarnings"),
525 LexObjectProperty::Ref(LexRef {
526 r#ref: CowStr::new_static(
527 "place.stream.metadata.contentWarnings",
528 ),
529 ..Default::default()
530 }),
531 );
532 map.insert(
533 SmolStr::new_static("creator"),
534 LexObjectProperty::String(LexString {
535 format: Some(LexStringFormat::Did),
536 ..Default::default()
537 }),
538 );
539 map.insert(
540 SmolStr::new_static("distributionPolicy"),
541 LexObjectProperty::Ref(LexRef {
542 r#ref: CowStr::new_static(
543 "place.stream.metadata.distributionPolicy",
544 ),
545 ..Default::default()
546 }),
547 );
548 map.insert(
549 SmolStr::new_static("duration"),
550 LexObjectProperty::Integer(LexInteger {
551 ..Default::default()
552 }),
553 );
554 map.insert(
555 SmolStr::new_static("id"),
556 LexObjectProperty::String(LexString {
557 description: Some(
558 CowStr::new_static("Unique identifier for the segment"),
559 ),
560 ..Default::default()
561 }),
562 );
563 map.insert(
564 SmolStr::new_static("signingKey"),
565 LexObjectProperty::String(LexString {
566 description: Some(
567 CowStr::new_static(
568 "The DID of the signing key used for this segment",
569 ),
570 ),
571 ..Default::default()
572 }),
573 );
574 map.insert(
575 SmolStr::new_static("size"),
576 LexObjectProperty::Integer(LexInteger {
577 ..Default::default()
578 }),
579 );
580 map.insert(
581 SmolStr::new_static("startTime"),
582 LexObjectProperty::String(LexString {
583 description: Some(
584 CowStr::new_static("When this segment started"),
585 ),
586 format: Some(LexStringFormat::Datetime),
587 ..Default::default()
588 }),
589 );
590 map.insert(
591 SmolStr::new_static("video"),
592 LexObjectProperty::Array(LexArray {
593 items: LexArrayItem::Ref(LexRef {
594 r#ref: CowStr::new_static("#video"),
595 ..Default::default()
596 }),
597 ..Default::default()
598 }),
599 );
600 map
601 },
602 ..Default::default()
603 }),
604 ..Default::default()
605 }),
606 );
607 map.insert(
608 SmolStr::new_static("segmentView"),
609 LexUserType::Object(LexObject {
610 required: Some(
611 vec![SmolStr::new_static("cid"), SmolStr::new_static("record")],
612 ),
613 properties: {
614 #[allow(unused_mut)]
615 let mut map = BTreeMap::new();
616 map.insert(
617 SmolStr::new_static("cid"),
618 LexObjectProperty::String(LexString {
619 format: Some(LexStringFormat::Cid),
620 ..Default::default()
621 }),
622 );
623 map.insert(
624 SmolStr::new_static("record"),
625 LexObjectProperty::Unknown(LexUnknown {
626 ..Default::default()
627 }),
628 );
629 map
630 },
631 ..Default::default()
632 }),
633 );
634 map.insert(
635 SmolStr::new_static("video"),
636 LexUserType::Object(LexObject {
637 required: Some(
638 vec![
639 SmolStr::new_static("codec"), SmolStr::new_static("width"),
640 SmolStr::new_static("height")
641 ],
642 ),
643 properties: {
644 #[allow(unused_mut)]
645 let mut map = BTreeMap::new();
646 map.insert(
647 SmolStr::new_static("bframes"),
648 LexObjectProperty::Boolean(LexBoolean {
649 ..Default::default()
650 }),
651 );
652 map.insert(
653 SmolStr::new_static("codec"),
654 LexObjectProperty::String(LexString { ..Default::default() }),
655 );
656 map.insert(
657 SmolStr::new_static("framerate"),
658 LexObjectProperty::Ref(LexRef {
659 r#ref: CowStr::new_static("#framerate"),
660 ..Default::default()
661 }),
662 );
663 map.insert(
664 SmolStr::new_static("height"),
665 LexObjectProperty::Integer(LexInteger {
666 ..Default::default()
667 }),
668 );
669 map.insert(
670 SmolStr::new_static("width"),
671 LexObjectProperty::Integer(LexInteger {
672 ..Default::default()
673 }),
674 );
675 map
676 },
677 ..Default::default()
678 }),
679 );
680 map
681 },
682 ..Default::default()
683 }
684}
685
686pub mod framerate_state {
687
688 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
689 #[allow(unused)]
690 use ::core::marker::PhantomData;
691 mod sealed {
692 pub trait Sealed {}
693 }
694 pub trait State: sealed::Sealed {
696 type Num;
697 type Den;
698 }
699 pub struct Empty(());
701 impl sealed::Sealed for Empty {}
702 impl State for Empty {
703 type Num = Unset;
704 type Den = Unset;
705 }
706 pub struct SetNum<S: State = Empty>(PhantomData<fn() -> S>);
708 impl<S: State> sealed::Sealed for SetNum<S> {}
709 impl<S: State> State for SetNum<S> {
710 type Num = Set<members::num>;
711 type Den = S::Den;
712 }
713 pub struct SetDen<S: State = Empty>(PhantomData<fn() -> S>);
715 impl<S: State> sealed::Sealed for SetDen<S> {}
716 impl<S: State> State for SetDen<S> {
717 type Num = S::Num;
718 type Den = Set<members::den>;
719 }
720 #[allow(non_camel_case_types)]
722 pub mod members {
723 pub struct num(());
725 pub struct den(());
727 }
728}
729
730pub struct FramerateBuilder<'a, S: framerate_state::State> {
732 _state: PhantomData<fn() -> S>,
733 _fields: (Option<i64>, Option<i64>),
734 _lifetime: PhantomData<&'a ()>,
735}
736
737impl<'a> Framerate<'a> {
738 pub fn new() -> FramerateBuilder<'a, framerate_state::Empty> {
740 FramerateBuilder::new()
741 }
742}
743
744impl<'a> FramerateBuilder<'a, framerate_state::Empty> {
745 pub fn new() -> Self {
747 FramerateBuilder {
748 _state: PhantomData,
749 _fields: (None, None),
750 _lifetime: PhantomData,
751 }
752 }
753}
754
755impl<'a, S> FramerateBuilder<'a, S>
756where
757 S: framerate_state::State,
758 S::Den: framerate_state::IsUnset,
759{
760 pub fn den(
762 mut self,
763 value: impl Into<i64>,
764 ) -> FramerateBuilder<'a, framerate_state::SetDen<S>> {
765 self._fields.0 = Option::Some(value.into());
766 FramerateBuilder {
767 _state: PhantomData,
768 _fields: self._fields,
769 _lifetime: PhantomData,
770 }
771 }
772}
773
774impl<'a, S> FramerateBuilder<'a, S>
775where
776 S: framerate_state::State,
777 S::Num: framerate_state::IsUnset,
778{
779 pub fn num(
781 mut self,
782 value: impl Into<i64>,
783 ) -> FramerateBuilder<'a, framerate_state::SetNum<S>> {
784 self._fields.1 = Option::Some(value.into());
785 FramerateBuilder {
786 _state: PhantomData,
787 _fields: self._fields,
788 _lifetime: PhantomData,
789 }
790 }
791}
792
793impl<'a, S> FramerateBuilder<'a, S>
794where
795 S: framerate_state::State,
796 S::Num: framerate_state::IsSet,
797 S::Den: framerate_state::IsSet,
798{
799 pub fn build(self) -> Framerate<'a> {
801 Framerate {
802 den: self._fields.0.unwrap(),
803 num: self._fields.1.unwrap(),
804 extra_data: Default::default(),
805 }
806 }
807 pub fn build_with_data(
809 self,
810 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
811 ) -> Framerate<'a> {
812 Framerate {
813 den: self._fields.0.unwrap(),
814 num: self._fields.1.unwrap(),
815 extra_data: Some(extra_data),
816 }
817 }
818}
819
820pub mod segment_state {
821
822 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
823 #[allow(unused)]
824 use ::core::marker::PhantomData;
825 mod sealed {
826 pub trait Sealed {}
827 }
828 pub trait State: sealed::Sealed {
830 type Id;
831 type StartTime;
832 type SigningKey;
833 type Creator;
834 }
835 pub struct Empty(());
837 impl sealed::Sealed for Empty {}
838 impl State for Empty {
839 type Id = Unset;
840 type StartTime = Unset;
841 type SigningKey = Unset;
842 type Creator = Unset;
843 }
844 pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
846 impl<S: State> sealed::Sealed for SetId<S> {}
847 impl<S: State> State for SetId<S> {
848 type Id = Set<members::id>;
849 type StartTime = S::StartTime;
850 type SigningKey = S::SigningKey;
851 type Creator = S::Creator;
852 }
853 pub struct SetStartTime<S: State = Empty>(PhantomData<fn() -> S>);
855 impl<S: State> sealed::Sealed for SetStartTime<S> {}
856 impl<S: State> State for SetStartTime<S> {
857 type Id = S::Id;
858 type StartTime = Set<members::start_time>;
859 type SigningKey = S::SigningKey;
860 type Creator = S::Creator;
861 }
862 pub struct SetSigningKey<S: State = Empty>(PhantomData<fn() -> S>);
864 impl<S: State> sealed::Sealed for SetSigningKey<S> {}
865 impl<S: State> State for SetSigningKey<S> {
866 type Id = S::Id;
867 type StartTime = S::StartTime;
868 type SigningKey = Set<members::signing_key>;
869 type Creator = S::Creator;
870 }
871 pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
873 impl<S: State> sealed::Sealed for SetCreator<S> {}
874 impl<S: State> State for SetCreator<S> {
875 type Id = S::Id;
876 type StartTime = S::StartTime;
877 type SigningKey = S::SigningKey;
878 type Creator = Set<members::creator>;
879 }
880 #[allow(non_camel_case_types)]
882 pub mod members {
883 pub struct id(());
885 pub struct start_time(());
887 pub struct signing_key(());
889 pub struct creator(());
891 }
892}
893
894pub struct SegmentBuilder<'a, S: segment_state::State> {
896 _state: PhantomData<fn() -> S>,
897 _fields: (
898 Option<Vec<segment::Audio<'a>>>,
899 Option<ContentRights<'a>>,
900 Option<ContentWarnings<'a>>,
901 Option<Did<'a>>,
902 Option<DistributionPolicy<'a>>,
903 Option<i64>,
904 Option<CowStr<'a>>,
905 Option<CowStr<'a>>,
906 Option<i64>,
907 Option<Datetime>,
908 Option<Vec<segment::Video<'a>>>,
909 ),
910 _lifetime: PhantomData<&'a ()>,
911}
912
913impl<'a> Segment<'a> {
914 pub fn new() -> SegmentBuilder<'a, segment_state::Empty> {
916 SegmentBuilder::new()
917 }
918}
919
920impl<'a> SegmentBuilder<'a, segment_state::Empty> {
921 pub fn new() -> Self {
923 SegmentBuilder {
924 _state: PhantomData,
925 _fields: (None, None, None, None, None, None, None, None, None, None, None),
926 _lifetime: PhantomData,
927 }
928 }
929}
930
931impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
932 pub fn audio(mut self, value: impl Into<Option<Vec<segment::Audio<'a>>>>) -> Self {
934 self._fields.0 = value.into();
935 self
936 }
937 pub fn maybe_audio(mut self, value: Option<Vec<segment::Audio<'a>>>) -> Self {
939 self._fields.0 = value;
940 self
941 }
942}
943
944impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
945 pub fn content_rights(
947 mut self,
948 value: impl Into<Option<ContentRights<'a>>>,
949 ) -> Self {
950 self._fields.1 = value.into();
951 self
952 }
953 pub fn maybe_content_rights(mut self, value: Option<ContentRights<'a>>) -> Self {
955 self._fields.1 = value;
956 self
957 }
958}
959
960impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
961 pub fn content_warnings(
963 mut self,
964 value: impl Into<Option<ContentWarnings<'a>>>,
965 ) -> Self {
966 self._fields.2 = value.into();
967 self
968 }
969 pub fn maybe_content_warnings(mut self, value: Option<ContentWarnings<'a>>) -> Self {
971 self._fields.2 = value;
972 self
973 }
974}
975
976impl<'a, S> SegmentBuilder<'a, S>
977where
978 S: segment_state::State,
979 S::Creator: segment_state::IsUnset,
980{
981 pub fn creator(
983 mut self,
984 value: impl Into<Did<'a>>,
985 ) -> SegmentBuilder<'a, segment_state::SetCreator<S>> {
986 self._fields.3 = Option::Some(value.into());
987 SegmentBuilder {
988 _state: PhantomData,
989 _fields: self._fields,
990 _lifetime: PhantomData,
991 }
992 }
993}
994
995impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
996 pub fn distribution_policy(
998 mut self,
999 value: impl Into<Option<DistributionPolicy<'a>>>,
1000 ) -> Self {
1001 self._fields.4 = value.into();
1002 self
1003 }
1004 pub fn maybe_distribution_policy(
1006 mut self,
1007 value: Option<DistributionPolicy<'a>>,
1008 ) -> Self {
1009 self._fields.4 = value;
1010 self
1011 }
1012}
1013
1014impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
1015 pub fn duration(mut self, value: impl Into<Option<i64>>) -> Self {
1017 self._fields.5 = value.into();
1018 self
1019 }
1020 pub fn maybe_duration(mut self, value: Option<i64>) -> Self {
1022 self._fields.5 = value;
1023 self
1024 }
1025}
1026
1027impl<'a, S> SegmentBuilder<'a, S>
1028where
1029 S: segment_state::State,
1030 S::Id: segment_state::IsUnset,
1031{
1032 pub fn id(
1034 mut self,
1035 value: impl Into<CowStr<'a>>,
1036 ) -> SegmentBuilder<'a, segment_state::SetId<S>> {
1037 self._fields.6 = Option::Some(value.into());
1038 SegmentBuilder {
1039 _state: PhantomData,
1040 _fields: self._fields,
1041 _lifetime: PhantomData,
1042 }
1043 }
1044}
1045
1046impl<'a, S> SegmentBuilder<'a, S>
1047where
1048 S: segment_state::State,
1049 S::SigningKey: segment_state::IsUnset,
1050{
1051 pub fn signing_key(
1053 mut self,
1054 value: impl Into<CowStr<'a>>,
1055 ) -> SegmentBuilder<'a, segment_state::SetSigningKey<S>> {
1056 self._fields.7 = Option::Some(value.into());
1057 SegmentBuilder {
1058 _state: PhantomData,
1059 _fields: self._fields,
1060 _lifetime: PhantomData,
1061 }
1062 }
1063}
1064
1065impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
1066 pub fn size(mut self, value: impl Into<Option<i64>>) -> Self {
1068 self._fields.8 = value.into();
1069 self
1070 }
1071 pub fn maybe_size(mut self, value: Option<i64>) -> Self {
1073 self._fields.8 = value;
1074 self
1075 }
1076}
1077
1078impl<'a, S> SegmentBuilder<'a, S>
1079where
1080 S: segment_state::State,
1081 S::StartTime: segment_state::IsUnset,
1082{
1083 pub fn start_time(
1085 mut self,
1086 value: impl Into<Datetime>,
1087 ) -> SegmentBuilder<'a, segment_state::SetStartTime<S>> {
1088 self._fields.9 = Option::Some(value.into());
1089 SegmentBuilder {
1090 _state: PhantomData,
1091 _fields: self._fields,
1092 _lifetime: PhantomData,
1093 }
1094 }
1095}
1096
1097impl<'a, S: segment_state::State> SegmentBuilder<'a, S> {
1098 pub fn video(mut self, value: impl Into<Option<Vec<segment::Video<'a>>>>) -> Self {
1100 self._fields.10 = value.into();
1101 self
1102 }
1103 pub fn maybe_video(mut self, value: Option<Vec<segment::Video<'a>>>) -> Self {
1105 self._fields.10 = value;
1106 self
1107 }
1108}
1109
1110impl<'a, S> SegmentBuilder<'a, S>
1111where
1112 S: segment_state::State,
1113 S::Id: segment_state::IsSet,
1114 S::StartTime: segment_state::IsSet,
1115 S::SigningKey: segment_state::IsSet,
1116 S::Creator: segment_state::IsSet,
1117{
1118 pub fn build(self) -> Segment<'a> {
1120 Segment {
1121 audio: self._fields.0,
1122 content_rights: self._fields.1,
1123 content_warnings: self._fields.2,
1124 creator: self._fields.3.unwrap(),
1125 distribution_policy: self._fields.4,
1126 duration: self._fields.5,
1127 id: self._fields.6.unwrap(),
1128 signing_key: self._fields.7.unwrap(),
1129 size: self._fields.8,
1130 start_time: self._fields.9.unwrap(),
1131 video: self._fields.10,
1132 extra_data: Default::default(),
1133 }
1134 }
1135 pub fn build_with_data(
1137 self,
1138 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
1139 ) -> Segment<'a> {
1140 Segment {
1141 audio: self._fields.0,
1142 content_rights: self._fields.1,
1143 content_warnings: self._fields.2,
1144 creator: self._fields.3.unwrap(),
1145 distribution_policy: self._fields.4,
1146 duration: self._fields.5,
1147 id: self._fields.6.unwrap(),
1148 signing_key: self._fields.7.unwrap(),
1149 size: self._fields.8,
1150 start_time: self._fields.9.unwrap(),
1151 video: self._fields.10,
1152 extra_data: Some(extra_data),
1153 }
1154 }
1155}
1156
1157pub mod segment_view_state {
1158
1159 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1160 #[allow(unused)]
1161 use ::core::marker::PhantomData;
1162 mod sealed {
1163 pub trait Sealed {}
1164 }
1165 pub trait State: sealed::Sealed {
1167 type Cid;
1168 type Record;
1169 }
1170 pub struct Empty(());
1172 impl sealed::Sealed for Empty {}
1173 impl State for Empty {
1174 type Cid = Unset;
1175 type Record = Unset;
1176 }
1177 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
1179 impl<S: State> sealed::Sealed for SetCid<S> {}
1180 impl<S: State> State for SetCid<S> {
1181 type Cid = Set<members::cid>;
1182 type Record = S::Record;
1183 }
1184 pub struct SetRecord<S: State = Empty>(PhantomData<fn() -> S>);
1186 impl<S: State> sealed::Sealed for SetRecord<S> {}
1187 impl<S: State> State for SetRecord<S> {
1188 type Cid = S::Cid;
1189 type Record = Set<members::record>;
1190 }
1191 #[allow(non_camel_case_types)]
1193 pub mod members {
1194 pub struct cid(());
1196 pub struct record(());
1198 }
1199}
1200
1201pub struct SegmentViewBuilder<'a, S: segment_view_state::State> {
1203 _state: PhantomData<fn() -> S>,
1204 _fields: (Option<Cid<'a>>, Option<Data<'a>>),
1205 _lifetime: PhantomData<&'a ()>,
1206}
1207
1208impl<'a> SegmentView<'a> {
1209 pub fn new() -> SegmentViewBuilder<'a, segment_view_state::Empty> {
1211 SegmentViewBuilder::new()
1212 }
1213}
1214
1215impl<'a> SegmentViewBuilder<'a, segment_view_state::Empty> {
1216 pub fn new() -> Self {
1218 SegmentViewBuilder {
1219 _state: PhantomData,
1220 _fields: (None, None),
1221 _lifetime: PhantomData,
1222 }
1223 }
1224}
1225
1226impl<'a, S> SegmentViewBuilder<'a, S>
1227where
1228 S: segment_view_state::State,
1229 S::Cid: segment_view_state::IsUnset,
1230{
1231 pub fn cid(
1233 mut self,
1234 value: impl Into<Cid<'a>>,
1235 ) -> SegmentViewBuilder<'a, segment_view_state::SetCid<S>> {
1236 self._fields.0 = Option::Some(value.into());
1237 SegmentViewBuilder {
1238 _state: PhantomData,
1239 _fields: self._fields,
1240 _lifetime: PhantomData,
1241 }
1242 }
1243}
1244
1245impl<'a, S> SegmentViewBuilder<'a, S>
1246where
1247 S: segment_view_state::State,
1248 S::Record: segment_view_state::IsUnset,
1249{
1250 pub fn record(
1252 mut self,
1253 value: impl Into<Data<'a>>,
1254 ) -> SegmentViewBuilder<'a, segment_view_state::SetRecord<S>> {
1255 self._fields.1 = Option::Some(value.into());
1256 SegmentViewBuilder {
1257 _state: PhantomData,
1258 _fields: self._fields,
1259 _lifetime: PhantomData,
1260 }
1261 }
1262}
1263
1264impl<'a, S> SegmentViewBuilder<'a, S>
1265where
1266 S: segment_view_state::State,
1267 S::Cid: segment_view_state::IsSet,
1268 S::Record: segment_view_state::IsSet,
1269{
1270 pub fn build(self) -> SegmentView<'a> {
1272 SegmentView {
1273 cid: self._fields.0.unwrap(),
1274 record: self._fields.1.unwrap(),
1275 extra_data: Default::default(),
1276 }
1277 }
1278 pub fn build_with_data(
1280 self,
1281 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
1282 ) -> SegmentView<'a> {
1283 SegmentView {
1284 cid: self._fields.0.unwrap(),
1285 record: self._fields.1.unwrap(),
1286 extra_data: Some(extra_data),
1287 }
1288 }
1289}
1290
1291pub mod video_state {
1292
1293 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1294 #[allow(unused)]
1295 use ::core::marker::PhantomData;
1296 mod sealed {
1297 pub trait Sealed {}
1298 }
1299 pub trait State: sealed::Sealed {
1301 type Width;
1302 type Codec;
1303 type Height;
1304 }
1305 pub struct Empty(());
1307 impl sealed::Sealed for Empty {}
1308 impl State for Empty {
1309 type Width = Unset;
1310 type Codec = Unset;
1311 type Height = Unset;
1312 }
1313 pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
1315 impl<S: State> sealed::Sealed for SetWidth<S> {}
1316 impl<S: State> State for SetWidth<S> {
1317 type Width = Set<members::width>;
1318 type Codec = S::Codec;
1319 type Height = S::Height;
1320 }
1321 pub struct SetCodec<S: State = Empty>(PhantomData<fn() -> S>);
1323 impl<S: State> sealed::Sealed for SetCodec<S> {}
1324 impl<S: State> State for SetCodec<S> {
1325 type Width = S::Width;
1326 type Codec = Set<members::codec>;
1327 type Height = S::Height;
1328 }
1329 pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
1331 impl<S: State> sealed::Sealed for SetHeight<S> {}
1332 impl<S: State> State for SetHeight<S> {
1333 type Width = S::Width;
1334 type Codec = S::Codec;
1335 type Height = Set<members::height>;
1336 }
1337 #[allow(non_camel_case_types)]
1339 pub mod members {
1340 pub struct width(());
1342 pub struct codec(());
1344 pub struct height(());
1346 }
1347}
1348
1349pub struct VideoBuilder<'a, S: video_state::State> {
1351 _state: PhantomData<fn() -> S>,
1352 _fields: (
1353 Option<bool>,
1354 Option<CowStr<'a>>,
1355 Option<segment::Framerate<'a>>,
1356 Option<i64>,
1357 Option<i64>,
1358 ),
1359 _lifetime: PhantomData<&'a ()>,
1360}
1361
1362impl<'a> Video<'a> {
1363 pub fn new() -> VideoBuilder<'a, video_state::Empty> {
1365 VideoBuilder::new()
1366 }
1367}
1368
1369impl<'a> VideoBuilder<'a, video_state::Empty> {
1370 pub fn new() -> Self {
1372 VideoBuilder {
1373 _state: PhantomData,
1374 _fields: (None, None, None, None, None),
1375 _lifetime: PhantomData,
1376 }
1377 }
1378}
1379
1380impl<'a, S: video_state::State> VideoBuilder<'a, S> {
1381 pub fn bframes(mut self, value: impl Into<Option<bool>>) -> Self {
1383 self._fields.0 = value.into();
1384 self
1385 }
1386 pub fn maybe_bframes(mut self, value: Option<bool>) -> Self {
1388 self._fields.0 = value;
1389 self
1390 }
1391}
1392
1393impl<'a, S> VideoBuilder<'a, S>
1394where
1395 S: video_state::State,
1396 S::Codec: video_state::IsUnset,
1397{
1398 pub fn codec(
1400 mut self,
1401 value: impl Into<CowStr<'a>>,
1402 ) -> VideoBuilder<'a, video_state::SetCodec<S>> {
1403 self._fields.1 = Option::Some(value.into());
1404 VideoBuilder {
1405 _state: PhantomData,
1406 _fields: self._fields,
1407 _lifetime: PhantomData,
1408 }
1409 }
1410}
1411
1412impl<'a, S: video_state::State> VideoBuilder<'a, S> {
1413 pub fn framerate(
1415 mut self,
1416 value: impl Into<Option<segment::Framerate<'a>>>,
1417 ) -> Self {
1418 self._fields.2 = value.into();
1419 self
1420 }
1421 pub fn maybe_framerate(mut self, value: Option<segment::Framerate<'a>>) -> Self {
1423 self._fields.2 = value;
1424 self
1425 }
1426}
1427
1428impl<'a, S> VideoBuilder<'a, S>
1429where
1430 S: video_state::State,
1431 S::Height: video_state::IsUnset,
1432{
1433 pub fn height(
1435 mut self,
1436 value: impl Into<i64>,
1437 ) -> VideoBuilder<'a, video_state::SetHeight<S>> {
1438 self._fields.3 = Option::Some(value.into());
1439 VideoBuilder {
1440 _state: PhantomData,
1441 _fields: self._fields,
1442 _lifetime: PhantomData,
1443 }
1444 }
1445}
1446
1447impl<'a, S> VideoBuilder<'a, S>
1448where
1449 S: video_state::State,
1450 S::Width: video_state::IsUnset,
1451{
1452 pub fn width(
1454 mut self,
1455 value: impl Into<i64>,
1456 ) -> VideoBuilder<'a, video_state::SetWidth<S>> {
1457 self._fields.4 = Option::Some(value.into());
1458 VideoBuilder {
1459 _state: PhantomData,
1460 _fields: self._fields,
1461 _lifetime: PhantomData,
1462 }
1463 }
1464}
1465
1466impl<'a, S> VideoBuilder<'a, S>
1467where
1468 S: video_state::State,
1469 S::Width: video_state::IsSet,
1470 S::Codec: video_state::IsSet,
1471 S::Height: video_state::IsSet,
1472{
1473 pub fn build(self) -> Video<'a> {
1475 Video {
1476 bframes: self._fields.0,
1477 codec: self._fields.1.unwrap(),
1478 framerate: self._fields.2,
1479 height: self._fields.3.unwrap(),
1480 width: self._fields.4.unwrap(),
1481 extra_data: Default::default(),
1482 }
1483 }
1484 pub fn build_with_data(
1486 self,
1487 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
1488 ) -> Video<'a> {
1489 Video {
1490 bframes: self._fields.0,
1491 codec: self._fields.1.unwrap(),
1492 framerate: self._fields.2,
1493 height: self._fields.3.unwrap(),
1494 width: self._fields.4.unwrap(),
1495 extra_data: Some(extra_data),
1496 }
1497 }
1498}