// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: place.stream.segment // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[allow(unused_imports)] use alloc::collections::BTreeMap; #[allow(unused_imports)] use core::marker::PhantomData; use jacquard_common::{CowStr, BosStr, 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::{Did, AtUri, Cid, Datetime}; 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; #[allow(unused_imports)] use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; use serde::{Serialize, Deserialize}; 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; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct Audio { pub channels: i64, pub codec: S, pub rate: i64, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct Framerate { pub den: i64, pub num: i64, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } /// Media file representing a segment of a livestream #[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 { #[serde(skip_serializing_if = "Option::is_none")] pub audio: Option>>, #[serde(skip_serializing_if = "Option::is_none")] pub content_rights: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub content_warnings: Option>, pub creator: Did, #[serde(skip_serializing_if = "Option::is_none")] pub distribution_policy: Option>, ///The duration of the segment in nanoseconds #[serde(skip_serializing_if = "Option::is_none")] pub duration: Option, ///Unique identifier for the segment pub id: S, ///The DID of the signing key used for this segment pub signing_key: S, ///The size of the segment in bytes #[serde(skip_serializing_if = "Option::is_none")] pub size: Option, ///When this segment started pub start_time: Datetime, #[serde(skip_serializing_if = "Option::is_none")] pub video: Option>>, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } /// Typed wrapper for GetRecord response with this collection's record type. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase")] pub struct SegmentGetRecordOutput { #[serde(skip_serializing_if = "Option::is_none")] pub cid: Option>, pub uri: AtUri, pub value: Segment, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct SegmentView { pub cid: Cid, pub record: Data, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct Video { #[serde(skip_serializing_if = "Option::is_none")] pub bframes: Option, pub codec: S, #[serde(skip_serializing_if = "Option::is_none")] pub framerate: Option>, pub height: i64, pub width: i64, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } impl Segment { pub fn uri(uri: S) -> Result, UriError> { RecordUri::try_from_uri(AtUri::new(uri)?) } } impl LexiconSchema for Audio { 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 LexiconSchema for Framerate { 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(()) } } /// Marker type for deserializing records from this collection. #[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 = SegmentGetRecordOutput; type Err = RecordError; } impl From> for Segment { fn from(output: SegmentGetRecordOutput) -> Self { output.value } } impl Collection for Segment { 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 LexiconSchema for Segment { 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 LexiconSchema for SegmentView { 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 LexiconSchema for Video { 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::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Channels; type Codec; type Rate; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Channels = Unset; type Codec = Unset; type Rate = Unset; } ///State transition - sets the `channels` field to Set pub struct SetChannels(PhantomData St>); impl sealed::Sealed for SetChannels {} impl State for SetChannels { type Channels = Set; type Codec = St::Codec; type Rate = St::Rate; } ///State transition - sets the `codec` field to Set pub struct SetCodec(PhantomData St>); impl sealed::Sealed for SetCodec {} impl State for SetCodec { type Channels = St::Channels; type Codec = Set; type Rate = St::Rate; } ///State transition - sets the `rate` field to Set pub struct SetRate(PhantomData St>); impl sealed::Sealed for SetRate {} impl State for SetRate { type Channels = St::Channels; type Codec = St::Codec; type Rate = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `channels` field pub struct channels(()); ///Marker type for the `codec` field pub struct codec(()); ///Marker type for the `rate` field pub struct rate(()); } } /// Builder for constructing an instance of this type. pub struct AudioBuilder { _state: PhantomData St>, _fields: (Option, Option, Option), _type: PhantomData S>, } impl Audio { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> AudioBuilder { AudioBuilder::new() } } impl Audio { /// Create a new builder for this type pub fn builder() -> AudioBuilder { AudioBuilder::builder() } } impl AudioBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { AudioBuilder { _state: PhantomData, _fields: (None, None, None), _type: PhantomData, } } } impl AudioBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { AudioBuilder { _state: PhantomData, _fields: (None, None, None), _type: PhantomData, } } } impl AudioBuilder where St: audio_state::State, St::Channels: audio_state::IsUnset, { /// Set the `channels` field (required) pub fn channels( mut self, value: impl Into, ) -> AudioBuilder, S> { self._fields.0 = Option::Some(value.into()); AudioBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl AudioBuilder where St: audio_state::State, St::Codec: audio_state::IsUnset, { /// Set the `codec` field (required) pub fn codec( mut self, value: impl Into, ) -> AudioBuilder, S> { self._fields.1 = Option::Some(value.into()); AudioBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl AudioBuilder where St: audio_state::State, St::Rate: audio_state::IsUnset, { /// Set the `rate` field (required) pub fn rate( mut self, value: impl Into, ) -> AudioBuilder, S> { self._fields.2 = Option::Some(value.into()); AudioBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl AudioBuilder where St: audio_state::State, St::Channels: audio_state::IsSet, St::Codec: audio_state::IsSet, St::Rate: audio_state::IsSet, { /// Build the final struct. pub fn build(self) -> Audio { Audio { channels: self._fields.0.unwrap(), codec: self._fields.1.unwrap(), rate: self._fields.2.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> Audio { 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> { #[allow(unused_imports)] use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; use jacquard_lexicon::lexicon::*; use alloc::collections::BTreeMap; 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::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Den; type Num; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Den = Unset; type Num = Unset; } ///State transition - sets the `den` field to Set pub struct SetDen(PhantomData St>); impl sealed::Sealed for SetDen {} impl State for SetDen { type Den = Set; type Num = St::Num; } ///State transition - sets the `num` field to Set pub struct SetNum(PhantomData St>); impl sealed::Sealed for SetNum {} impl State for SetNum { type Den = St::Den; type Num = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `den` field pub struct den(()); ///Marker type for the `num` field pub struct num(()); } } /// Builder for constructing an instance of this type. pub struct FramerateBuilder { _state: PhantomData St>, _fields: (Option, Option), _type: PhantomData S>, } impl Framerate { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> FramerateBuilder { FramerateBuilder::new() } } impl Framerate { /// Create a new builder for this type pub fn builder() -> FramerateBuilder { FramerateBuilder::builder() } } impl FramerateBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { FramerateBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl FramerateBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { FramerateBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl FramerateBuilder where St: framerate_state::State, St::Den: framerate_state::IsUnset, { /// Set the `den` field (required) pub fn den( mut self, value: impl Into, ) -> FramerateBuilder, S> { self._fields.0 = Option::Some(value.into()); FramerateBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl FramerateBuilder where St: framerate_state::State, St::Num: framerate_state::IsUnset, { /// Set the `num` field (required) pub fn num( mut self, value: impl Into, ) -> FramerateBuilder, S> { self._fields.1 = Option::Some(value.into()); FramerateBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl FramerateBuilder where St: framerate_state::State, St::Den: framerate_state::IsSet, St::Num: framerate_state::IsSet, { /// Build the final struct. pub fn build(self) -> Framerate { Framerate { den: self._fields.0.unwrap(), num: self._fields.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data( self, extra_data: BTreeMap>, ) -> Framerate { 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::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Creator; type Id; type SigningKey; type StartTime; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Creator = Unset; type Id = Unset; type SigningKey = Unset; type StartTime = Unset; } ///State transition - sets the `creator` field to Set pub struct SetCreator(PhantomData St>); impl sealed::Sealed for SetCreator {} impl State for SetCreator { type Creator = Set; type Id = St::Id; type SigningKey = St::SigningKey; type StartTime = St::StartTime; } ///State transition - sets the `id` field to Set pub struct SetId(PhantomData St>); impl sealed::Sealed for SetId {} impl State for SetId { type Creator = St::Creator; type Id = Set; type SigningKey = St::SigningKey; type StartTime = St::StartTime; } ///State transition - sets the `signing_key` field to Set pub struct SetSigningKey(PhantomData St>); impl sealed::Sealed for SetSigningKey {} impl State for SetSigningKey { type Creator = St::Creator; type Id = St::Id; type SigningKey = Set; type StartTime = St::StartTime; } ///State transition - sets the `start_time` field to Set pub struct SetStartTime(PhantomData St>); impl sealed::Sealed for SetStartTime {} impl State for SetStartTime { type Creator = St::Creator; type Id = St::Id; type SigningKey = St::SigningKey; type StartTime = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `creator` field pub struct creator(()); ///Marker type for the `id` field pub struct id(()); ///Marker type for the `signing_key` field pub struct signing_key(()); ///Marker type for the `start_time` field pub struct start_time(()); } } /// Builder for constructing an instance of this type. pub struct SegmentBuilder { _state: PhantomData St>, _fields: ( Option>>, Option>, Option>, Option>, Option>, Option, Option, Option, Option, Option, Option>>, ), _type: PhantomData S>, } impl Segment { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SegmentBuilder { SegmentBuilder::new() } } impl Segment { /// Create a new builder for this type pub fn builder() -> SegmentBuilder { SegmentBuilder::builder() } } impl SegmentBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SegmentBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None, None, None, None), _type: PhantomData, } } } impl SegmentBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SegmentBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None, None, None, None), _type: PhantomData, } } } impl SegmentBuilder { /// Set the `audio` field (optional) pub fn audio(mut self, value: impl Into>>>) -> Self { self._fields.0 = value.into(); self } /// Set the `audio` field to an Option value (optional) pub fn maybe_audio(mut self, value: Option>>) -> Self { self._fields.0 = value; self } } impl SegmentBuilder { /// Set the `contentRights` field (optional) pub fn content_rights(mut self, value: impl Into>>) -> Self { self._fields.1 = value.into(); self } /// Set the `contentRights` field to an Option value (optional) pub fn maybe_content_rights(mut self, value: Option>) -> Self { self._fields.1 = value; self } } impl SegmentBuilder { /// Set the `contentWarnings` field (optional) pub fn content_warnings( mut self, value: impl Into>>, ) -> Self { self._fields.2 = value.into(); self } /// Set the `contentWarnings` field to an Option value (optional) pub fn maybe_content_warnings(mut self, value: Option>) -> Self { self._fields.2 = value; self } } impl SegmentBuilder where St: segment_state::State, St::Creator: segment_state::IsUnset, { /// Set the `creator` field (required) pub fn creator( mut self, value: impl Into>, ) -> SegmentBuilder, S> { self._fields.3 = Option::Some(value.into()); SegmentBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SegmentBuilder { /// Set the `distributionPolicy` field (optional) pub fn distribution_policy( mut self, value: impl Into>>, ) -> Self { self._fields.4 = value.into(); self } /// Set the `distributionPolicy` field to an Option value (optional) pub fn maybe_distribution_policy( mut self, value: Option>, ) -> Self { self._fields.4 = value; self } } impl SegmentBuilder { /// Set the `duration` field (optional) pub fn duration(mut self, value: impl Into>) -> Self { self._fields.5 = value.into(); self } /// Set the `duration` field to an Option value (optional) pub fn maybe_duration(mut self, value: Option) -> Self { self._fields.5 = value; self } } impl SegmentBuilder where St: segment_state::State, St::Id: segment_state::IsUnset, { /// Set the `id` field (required) pub fn id( mut self, value: impl Into, ) -> SegmentBuilder, S> { self._fields.6 = Option::Some(value.into()); SegmentBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SegmentBuilder where St: segment_state::State, St::SigningKey: segment_state::IsUnset, { /// Set the `signingKey` field (required) pub fn signing_key( mut self, value: impl Into, ) -> SegmentBuilder, S> { self._fields.7 = Option::Some(value.into()); SegmentBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SegmentBuilder { /// Set the `size` field (optional) pub fn size(mut self, value: impl Into>) -> Self { self._fields.8 = value.into(); self } /// Set the `size` field to an Option value (optional) pub fn maybe_size(mut self, value: Option) -> Self { self._fields.8 = value; self } } impl SegmentBuilder where St: segment_state::State, St::StartTime: segment_state::IsUnset, { /// Set the `startTime` field (required) pub fn start_time( mut self, value: impl Into, ) -> SegmentBuilder, S> { self._fields.9 = Option::Some(value.into()); SegmentBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SegmentBuilder { /// Set the `video` field (optional) pub fn video(mut self, value: impl Into>>>) -> Self { self._fields.10 = value.into(); self } /// Set the `video` field to an Option value (optional) pub fn maybe_video(mut self, value: Option>>) -> Self { self._fields.10 = value; self } } impl SegmentBuilder where St: segment_state::State, St::Creator: segment_state::IsSet, St::Id: segment_state::IsSet, St::SigningKey: segment_state::IsSet, St::StartTime: segment_state::IsSet, { /// Build the final struct. pub fn build(self) -> Segment { 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(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> Segment { 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::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Cid; type Record; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Cid = Unset; type Record = Unset; } ///State transition - sets the `cid` field to Set pub struct SetCid(PhantomData St>); impl sealed::Sealed for SetCid {} impl State for SetCid { type Cid = Set; type Record = St::Record; } ///State transition - sets the `record` field to Set pub struct SetRecord(PhantomData St>); impl sealed::Sealed for SetRecord {} impl State for SetRecord { type Cid = St::Cid; type Record = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `cid` field pub struct cid(()); ///Marker type for the `record` field pub struct record(()); } } /// Builder for constructing an instance of this type. pub struct SegmentViewBuilder { _state: PhantomData St>, _fields: (Option>, Option>), _type: PhantomData S>, } impl SegmentView { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SegmentViewBuilder { SegmentViewBuilder::new() } } impl SegmentView { /// Create a new builder for this type pub fn builder() -> SegmentViewBuilder { SegmentViewBuilder::builder() } } impl SegmentViewBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SegmentViewBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl SegmentViewBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SegmentViewBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl SegmentViewBuilder where St: segment_view_state::State, St::Cid: segment_view_state::IsUnset, { /// Set the `cid` field (required) pub fn cid( mut self, value: impl Into>, ) -> SegmentViewBuilder, S> { self._fields.0 = Option::Some(value.into()); SegmentViewBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SegmentViewBuilder where St: segment_view_state::State, St::Record: segment_view_state::IsUnset, { /// Set the `record` field (required) pub fn record( mut self, value: impl Into>, ) -> SegmentViewBuilder, S> { self._fields.1 = Option::Some(value.into()); SegmentViewBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SegmentViewBuilder where St: segment_view_state::State, St::Cid: segment_view_state::IsSet, St::Record: segment_view_state::IsSet, { /// Build the final struct. pub fn build(self) -> SegmentView { SegmentView { cid: self._fields.0.unwrap(), record: self._fields.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data( self, extra_data: BTreeMap>, ) -> SegmentView { 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::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Codec; type Height; type Width; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Codec = Unset; type Height = Unset; type Width = Unset; } ///State transition - sets the `codec` field to Set pub struct SetCodec(PhantomData St>); impl sealed::Sealed for SetCodec {} impl State for SetCodec { type Codec = Set; type Height = St::Height; type Width = St::Width; } ///State transition - sets the `height` field to Set pub struct SetHeight(PhantomData St>); impl sealed::Sealed for SetHeight {} impl State for SetHeight { type Codec = St::Codec; type Height = Set; type Width = St::Width; } ///State transition - sets the `width` field to Set pub struct SetWidth(PhantomData St>); impl sealed::Sealed for SetWidth {} impl State for SetWidth { type Codec = St::Codec; type Height = St::Height; type Width = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `codec` field pub struct codec(()); ///Marker type for the `height` field pub struct height(()); ///Marker type for the `width` field pub struct width(()); } } /// Builder for constructing an instance of this type. pub struct VideoBuilder { _state: PhantomData St>, _fields: ( Option, Option, Option>, Option, Option, ), _type: PhantomData S>, } impl Video { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> VideoBuilder { VideoBuilder::new() } } impl Video { /// Create a new builder for this type pub fn builder() -> VideoBuilder { VideoBuilder::builder() } } impl VideoBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { VideoBuilder { _state: PhantomData, _fields: (None, None, None, None, None), _type: PhantomData, } } } impl VideoBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { VideoBuilder { _state: PhantomData, _fields: (None, None, None, None, None), _type: PhantomData, } } } impl VideoBuilder { /// Set the `bframes` field (optional) pub fn bframes(mut self, value: impl Into>) -> Self { self._fields.0 = value.into(); self } /// Set the `bframes` field to an Option value (optional) pub fn maybe_bframes(mut self, value: Option) -> Self { self._fields.0 = value; self } } impl VideoBuilder where St: video_state::State, St::Codec: video_state::IsUnset, { /// Set the `codec` field (required) pub fn codec( mut self, value: impl Into, ) -> VideoBuilder, S> { self._fields.1 = Option::Some(value.into()); VideoBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl VideoBuilder { /// Set the `framerate` field (optional) pub fn framerate(mut self, value: impl Into>>) -> Self { self._fields.2 = value.into(); self } /// Set the `framerate` field to an Option value (optional) pub fn maybe_framerate(mut self, value: Option>) -> Self { self._fields.2 = value; self } } impl VideoBuilder where St: video_state::State, St::Height: video_state::IsUnset, { /// Set the `height` field (required) pub fn height( mut self, value: impl Into, ) -> VideoBuilder, S> { self._fields.3 = Option::Some(value.into()); VideoBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl VideoBuilder where St: video_state::State, St::Width: video_state::IsUnset, { /// Set the `width` field (required) pub fn width( mut self, value: impl Into, ) -> VideoBuilder, S> { self._fields.4 = Option::Some(value.into()); VideoBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl VideoBuilder where St: video_state::State, St::Codec: video_state::IsSet, St::Height: video_state::IsSet, St::Width: video_state::IsSet, { /// Build the final struct. pub fn build(self) -> Video { 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(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> Video { 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), } } }