#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, Did};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::place_stream::metadata::content_rights::ContentRights;
use crate::place_stream::metadata::content_warnings::ContentWarnings;
use crate::place_stream::metadata::distribution_policy::DistributionPolicy;
use crate::place_stream::segment;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Audio<S: BosStr = DefaultStr> {
pub channels: i64,
pub codec: S,
pub rate: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Framerate<S: BosStr = DefaultStr> {
pub den: i64,
pub num: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "place.stream.segment",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Segment<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub audio: Option<Vec<segment::Audio<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub content_rights: Option<ContentRights<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub content_warnings: Option<ContentWarnings<S>>,
pub creator: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub distribution_policy: Option<DistributionPolicy<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<i64>,
pub id: S,
pub signing_key: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
pub start_time: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub video: Option<Vec<segment::Video<S>>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SegmentGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Segment<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SegmentView<S: BosStr = DefaultStr> {
pub cid: Cid<S>,
pub record: Data<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Video<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub bframes: Option<bool>,
pub codec: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub framerate: Option<segment::Framerate<S>>,
pub height: i64,
pub width: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Segment<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, SegmentRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Audio<S> {
fn nsid() -> &'static str {
"place.stream.segment"
}
fn def_name() -> &'static str {
"audio"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_segment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Framerate<S> {
fn nsid() -> &'static str {
"place.stream.segment"
}
fn def_name() -> &'static str {
"framerate"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_segment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SegmentRecord;
impl XrpcResp for SegmentRecord {
const NSID: &'static str = "place.stream.segment";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = SegmentGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<SegmentGetRecordOutput<S>> for Segment<S> {
fn from(output: SegmentGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Segment<S> {
const NSID: &'static str = "place.stream.segment";
type Record = SegmentRecord;
}
impl Collection for SegmentRecord {
const NSID: &'static str = "place.stream.segment";
type Record = SegmentRecord;
}
impl<S: BosStr> LexiconSchema for Segment<S> {
fn nsid() -> &'static str {
"place.stream.segment"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_segment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SegmentView<S> {
fn nsid() -> &'static str {
"place.stream.segment"
}
fn def_name() -> &'static str {
"segmentView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_segment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Video<S> {
fn nsid() -> &'static str {
"place.stream.segment"
}
fn def_name() -> &'static str {
"video"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_segment()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod audio_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Codec;
type Rate;
type Channels;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Codec = Unset;
type Rate = Unset;
type Channels = Unset;
}
pub struct SetCodec<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCodec<St> {}
impl<St: State> State for SetCodec<St> {
type Codec = Set<members::codec>;
type Rate = St::Rate;
type Channels = St::Channels;
}
pub struct SetRate<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRate<St> {}
impl<St: State> State for SetRate<St> {
type Codec = St::Codec;
type Rate = Set<members::rate>;
type Channels = St::Channels;
}
pub struct SetChannels<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetChannels<St> {}
impl<St: State> State for SetChannels<St> {
type Codec = St::Codec;
type Rate = St::Rate;
type Channels = Set<members::channels>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct codec(());
pub struct rate(());
pub struct channels(());
}
}
pub struct AudioBuilder<S: BosStr, St: audio_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Audio<S> {
pub fn new() -> AudioBuilder<S, audio_state::Empty> {
AudioBuilder::new()
}
}
impl<S: BosStr> AudioBuilder<S, audio_state::Empty> {
pub fn new() -> Self {
AudioBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AudioBuilder<S, St>
where
St: audio_state::State,
St::Channels: audio_state::IsUnset,
{
pub fn channels(
mut self,
value: impl Into<i64>,
) -> AudioBuilder<S, audio_state::SetChannels<St>> {
self._fields.0 = Option::Some(value.into());
AudioBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AudioBuilder<S, St>
where
St: audio_state::State,
St::Codec: audio_state::IsUnset,
{
pub fn codec(mut self, value: impl Into<S>) -> AudioBuilder<S, audio_state::SetCodec<St>> {
self._fields.1 = Option::Some(value.into());
AudioBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AudioBuilder<S, St>
where
St: audio_state::State,
St::Rate: audio_state::IsUnset,
{
pub fn rate(mut self, value: impl Into<i64>) -> AudioBuilder<S, audio_state::SetRate<St>> {
self._fields.2 = Option::Some(value.into());
AudioBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AudioBuilder<S, St>
where
St: audio_state::State,
St::Codec: audio_state::IsSet,
St::Rate: audio_state::IsSet,
St::Channels: audio_state::IsSet,
{
pub fn build(self) -> Audio<S> {
Audio {
channels: self._fields.0.unwrap(),
codec: self._fields.1.unwrap(),
rate: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Audio<S> {
Audio {
channels: self._fields.0.unwrap(),
codec: self._fields.1.unwrap(),
rate: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_place_stream_segment() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("place.stream.segment"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("audio"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("codec"),
SmolStr::new_static("rate"),
SmolStr::new_static("channels"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("channels"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codec"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rate"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("framerate"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("num"), SmolStr::new_static("den")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("den"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("num"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static(
"Media file representing a segment of a livestream",
)),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![
SmolStr::new_static("id"),
SmolStr::new_static("signingKey"),
SmolStr::new_static("startTime"),
SmolStr::new_static("creator"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("audio"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#audio"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contentRights"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"place.stream.metadata.contentRights",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contentWarnings"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"place.stream.metadata.contentWarnings",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("creator"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("distributionPolicy"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"place.stream.metadata.distributionPolicy",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("duration"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Unique identifier for the segment",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signingKey"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The DID of the signing key used for this segment",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startTime"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"When this segment started",
)),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("video"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#video"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("segmentView"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("cid"),
SmolStr::new_static("record"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("video"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("codec"),
SmolStr::new_static("width"),
SmolStr::new_static("height"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("bframes"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codec"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("framerate"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#framerate"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod framerate_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Den;
type Num;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Den = Unset;
type Num = Unset;
}
pub struct SetDen<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDen<St> {}
impl<St: State> State for SetDen<St> {
type Den = Set<members::den>;
type Num = St::Num;
}
pub struct SetNum<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNum<St> {}
impl<St: State> State for SetNum<St> {
type Den = St::Den;
type Num = Set<members::num>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct den(());
pub struct num(());
}
}
pub struct FramerateBuilder<S: BosStr, St: framerate_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Framerate<S> {
pub fn new() -> FramerateBuilder<S, framerate_state::Empty> {
FramerateBuilder::new()
}
}
impl<S: BosStr> FramerateBuilder<S, framerate_state::Empty> {
pub fn new() -> Self {
FramerateBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FramerateBuilder<S, St>
where
St: framerate_state::State,
St::Den: framerate_state::IsUnset,
{
pub fn den(
mut self,
value: impl Into<i64>,
) -> FramerateBuilder<S, framerate_state::SetDen<St>> {
self._fields.0 = Option::Some(value.into());
FramerateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FramerateBuilder<S, St>
where
St: framerate_state::State,
St::Num: framerate_state::IsUnset,
{
pub fn num(
mut self,
value: impl Into<i64>,
) -> FramerateBuilder<S, framerate_state::SetNum<St>> {
self._fields.1 = Option::Some(value.into());
FramerateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FramerateBuilder<S, St>
where
St: framerate_state::State,
St::Den: framerate_state::IsSet,
St::Num: framerate_state::IsSet,
{
pub fn build(self) -> Framerate<S> {
Framerate {
den: self._fields.0.unwrap(),
num: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Framerate<S> {
Framerate {
den: self._fields.0.unwrap(),
num: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod segment_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Creator;
type StartTime;
type Id;
type SigningKey;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Creator = Unset;
type StartTime = Unset;
type Id = Unset;
type SigningKey = Unset;
}
pub struct SetCreator<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreator<St> {}
impl<St: State> State for SetCreator<St> {
type Creator = Set<members::creator>;
type StartTime = St::StartTime;
type Id = St::Id;
type SigningKey = St::SigningKey;
}
pub struct SetStartTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStartTime<St> {}
impl<St: State> State for SetStartTime<St> {
type Creator = St::Creator;
type StartTime = Set<members::start_time>;
type Id = St::Id;
type SigningKey = St::SigningKey;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Creator = St::Creator;
type StartTime = St::StartTime;
type Id = Set<members::id>;
type SigningKey = St::SigningKey;
}
pub struct SetSigningKey<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSigningKey<St> {}
impl<St: State> State for SetSigningKey<St> {
type Creator = St::Creator;
type StartTime = St::StartTime;
type Id = St::Id;
type SigningKey = Set<members::signing_key>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct creator(());
pub struct start_time(());
pub struct id(());
pub struct signing_key(());
}
}
pub struct SegmentBuilder<S: BosStr, St: segment_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<segment::Audio<S>>>,
Option<ContentRights<S>>,
Option<ContentWarnings<S>>,
Option<Did<S>>,
Option<DistributionPolicy<S>>,
Option<i64>,
Option<S>,
Option<S>,
Option<i64>,
Option<Datetime>,
Option<Vec<segment::Video<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Segment<S> {
pub fn new() -> SegmentBuilder<S, segment_state::Empty> {
SegmentBuilder::new()
}
}
impl<S: BosStr> SegmentBuilder<S, segment_state::Empty> {
pub fn new() -> Self {
SegmentBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn audio(mut self, value: impl Into<Option<Vec<segment::Audio<S>>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_audio(mut self, value: Option<Vec<segment::Audio<S>>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn content_rights(mut self, value: impl Into<Option<ContentRights<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_content_rights(mut self, value: Option<ContentRights<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn content_warnings(mut self, value: impl Into<Option<ContentWarnings<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_content_warnings(mut self, value: Option<ContentWarnings<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> SegmentBuilder<S, St>
where
St: segment_state::State,
St::Creator: segment_state::IsUnset,
{
pub fn creator(
mut self,
value: impl Into<Did<S>>,
) -> SegmentBuilder<S, segment_state::SetCreator<St>> {
self._fields.3 = Option::Some(value.into());
SegmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn distribution_policy(mut self, value: impl Into<Option<DistributionPolicy<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_distribution_policy(mut self, value: Option<DistributionPolicy<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn duration(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_duration(mut self, value: Option<i64>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St> SegmentBuilder<S, St>
where
St: segment_state::State,
St::Id: segment_state::IsUnset,
{
pub fn id(mut self, value: impl Into<S>) -> SegmentBuilder<S, segment_state::SetId<St>> {
self._fields.6 = Option::Some(value.into());
SegmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SegmentBuilder<S, St>
where
St: segment_state::State,
St::SigningKey: segment_state::IsUnset,
{
pub fn signing_key(
mut self,
value: impl Into<S>,
) -> SegmentBuilder<S, segment_state::SetSigningKey<St>> {
self._fields.7 = Option::Some(value.into());
SegmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn size(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_size(mut self, value: Option<i64>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> SegmentBuilder<S, St>
where
St: segment_state::State,
St::StartTime: segment_state::IsUnset,
{
pub fn start_time(
mut self,
value: impl Into<Datetime>,
) -> SegmentBuilder<S, segment_state::SetStartTime<St>> {
self._fields.9 = Option::Some(value.into());
SegmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: segment_state::State> SegmentBuilder<S, St> {
pub fn video(mut self, value: impl Into<Option<Vec<segment::Video<S>>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_video(mut self, value: Option<Vec<segment::Video<S>>>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> SegmentBuilder<S, St>
where
St: segment_state::State,
St::Creator: segment_state::IsSet,
St::StartTime: segment_state::IsSet,
St::Id: segment_state::IsSet,
St::SigningKey: segment_state::IsSet,
{
pub fn build(self) -> Segment<S> {
Segment {
audio: self._fields.0,
content_rights: self._fields.1,
content_warnings: self._fields.2,
creator: self._fields.3.unwrap(),
distribution_policy: self._fields.4,
duration: self._fields.5,
id: self._fields.6.unwrap(),
signing_key: self._fields.7.unwrap(),
size: self._fields.8,
start_time: self._fields.9.unwrap(),
video: self._fields.10,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Segment<S> {
Segment {
audio: self._fields.0,
content_rights: self._fields.1,
content_warnings: self._fields.2,
creator: self._fields.3.unwrap(),
distribution_policy: self._fields.4,
duration: self._fields.5,
id: self._fields.6.unwrap(),
signing_key: self._fields.7.unwrap(),
size: self._fields.8,
start_time: self._fields.9.unwrap(),
video: self._fields.10,
extra_data: Some(extra_data),
}
}
}
pub mod segment_view_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Cid;
type Record;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Record = Unset;
}
pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCid<St> {}
impl<St: State> State for SetCid<St> {
type Cid = Set<members::cid>;
type Record = St::Record;
}
pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRecord<St> {}
impl<St: State> State for SetRecord<St> {
type Cid = St::Cid;
type Record = Set<members::record>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct record(());
}
}
pub struct SegmentViewBuilder<S: BosStr, St: segment_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Cid<S>>, Option<Data<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SegmentView<S> {
pub fn new() -> SegmentViewBuilder<S, segment_view_state::Empty> {
SegmentViewBuilder::new()
}
}
impl<S: BosStr> SegmentViewBuilder<S, segment_view_state::Empty> {
pub fn new() -> Self {
SegmentViewBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SegmentViewBuilder<S, St>
where
St: segment_view_state::State,
St::Cid: segment_view_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> SegmentViewBuilder<S, segment_view_state::SetCid<St>> {
self._fields.0 = Option::Some(value.into());
SegmentViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SegmentViewBuilder<S, St>
where
St: segment_view_state::State,
St::Record: segment_view_state::IsUnset,
{
pub fn record(
mut self,
value: impl Into<Data<S>>,
) -> SegmentViewBuilder<S, segment_view_state::SetRecord<St>> {
self._fields.1 = Option::Some(value.into());
SegmentViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SegmentViewBuilder<S, St>
where
St: segment_view_state::State,
St::Cid: segment_view_state::IsSet,
St::Record: segment_view_state::IsSet,
{
pub fn build(self) -> SegmentView<S> {
SegmentView {
cid: self._fields.0.unwrap(),
record: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> SegmentView<S> {
SegmentView {
cid: self._fields.0.unwrap(),
record: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod video_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Height;
type Width;
type Codec;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Height = Unset;
type Width = Unset;
type Codec = Unset;
}
pub struct SetHeight<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHeight<St> {}
impl<St: State> State for SetHeight<St> {
type Height = Set<members::height>;
type Width = St::Width;
type Codec = St::Codec;
}
pub struct SetWidth<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWidth<St> {}
impl<St: State> State for SetWidth<St> {
type Height = St::Height;
type Width = Set<members::width>;
type Codec = St::Codec;
}
pub struct SetCodec<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCodec<St> {}
impl<St: State> State for SetCodec<St> {
type Height = St::Height;
type Width = St::Width;
type Codec = Set<members::codec>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct height(());
pub struct width(());
pub struct codec(());
}
}
pub struct VideoBuilder<S: BosStr, St: video_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<bool>,
Option<S>,
Option<segment::Framerate<S>>,
Option<i64>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Video<S> {
pub fn new() -> VideoBuilder<S, video_state::Empty> {
VideoBuilder::new()
}
}
impl<S: BosStr> VideoBuilder<S, video_state::Empty> {
pub fn new() -> Self {
VideoBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: video_state::State> VideoBuilder<S, St> {
pub fn bframes(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_bframes(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> VideoBuilder<S, St>
where
St: video_state::State,
St::Codec: video_state::IsUnset,
{
pub fn codec(mut self, value: impl Into<S>) -> VideoBuilder<S, video_state::SetCodec<St>> {
self._fields.1 = Option::Some(value.into());
VideoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: video_state::State> VideoBuilder<S, St> {
pub fn framerate(mut self, value: impl Into<Option<segment::Framerate<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_framerate(mut self, value: Option<segment::Framerate<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> VideoBuilder<S, St>
where
St: video_state::State,
St::Height: video_state::IsUnset,
{
pub fn height(mut self, value: impl Into<i64>) -> VideoBuilder<S, video_state::SetHeight<St>> {
self._fields.3 = Option::Some(value.into());
VideoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VideoBuilder<S, St>
where
St: video_state::State,
St::Width: video_state::IsUnset,
{
pub fn width(mut self, value: impl Into<i64>) -> VideoBuilder<S, video_state::SetWidth<St>> {
self._fields.4 = Option::Some(value.into());
VideoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VideoBuilder<S, St>
where
St: video_state::State,
St::Height: video_state::IsSet,
St::Width: video_state::IsSet,
St::Codec: video_state::IsSet,
{
pub fn build(self) -> Video<S> {
Video {
bframes: self._fields.0,
codec: self._fields.1.unwrap(),
framerate: self._fields.2,
height: self._fields.3.unwrap(),
width: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Video<S> {
Video {
bframes: self._fields.0,
codec: self._fields.1.unwrap(),
framerate: self._fields.2,
height: self._fields.3.unwrap(),
width: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}