// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: place.stream.media.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

//! Generated bindings for the `place.stream.media` Lexicon namespace/module.
pub mod create_upload;
pub mod get_upload_status;
pub mod get_video;
pub mod get_video_list;
pub mod origin;
pub mod publish_video;
pub mod track;
pub mod view_count;


#[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::string::{Did, AtUri};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::com_atproto::repo::strong_ref::StrongRef;
/// A track backed by a MUXL container

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct MuxlTrack<S: BosStr = DefaultStr> {
    ///BLAKE-3 content hash (BDASL CID) of the source video segment.
    pub blob: S,
    ///Language of the track, if applicable.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language: Option<S>,
    ///Type of the track: video, audio, or text.
    pub media_type: S,
    ///did:key of the ephemeral key that C2PA-signed this track's segments. The private key is discarded once the track is produced, so it can only ever have signed this content.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signing_key: Option<Did<S>>,
    ///Size in bytes of the source video segment.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<i64>,
    ///ID of the track within the MUXL container. 1-indexed for MP4 reasons.
    pub track_id: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// An object representing that this video's source is a clip from another video.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SourceClip<S: BosStr = DefaultStr> {
    ///End time of the clip in milliseconds.
    pub end: i64,
    ///Start time of the clip in milliseconds.
    pub start: i64,
    ///AT URI of the video we're clipping.
    pub video: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A collection of tracks representing the canonical source of a video.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SourceTracks<S: BosStr = DefaultStr> {
    ///The canonical list of tracks specifying the source of a video.
    pub tracks: Vec<StrongRef<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for MuxlTrack<S> {
    fn nsid() -> &'static str {
        "place.stream.media.defs"
    }
    fn def_name() -> &'static str {
        "muxlTrack"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_place_stream_media_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SourceClip<S> {
    fn nsid() -> &'static str {
        "place.stream.media.defs"
    }
    fn def_name() -> &'static str {
        "sourceClip"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_place_stream_media_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SourceTracks<S> {
    fn nsid() -> &'static str {
        "place.stream.media.defs"
    }
    fn def_name() -> &'static str {
        "sourceTracks"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_place_stream_media_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_place_stream_media_defs() -> 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.media.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("muxlTrack"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("A track backed by a MUXL container"),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("blob"), SmolStr::new_static("trackId"),
                            SmolStr::new_static("mediaType")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("blob"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "BLAKE-3 content hash (BDASL CID) of the source video segment.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("language"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Language of the track, if applicable."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("mediaType"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Type of the track: video, audio, or text.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("signingKey"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "did:key of the ephemeral key that C2PA-signed this track's segments. The private key is discarded once the track is produced, so it can only ever have signed this content.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("size"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("trackId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "ID of the track within the MUXL container. 1-indexed for MP4 reasons.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sourceClip"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "An object representing that this video's source is a clip from another video.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("video"), SmolStr::new_static("start"),
                            SmolStr::new_static("end")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("end"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("start"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("video"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("AT URI of the video we're clipping."),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sourceTracks"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A collection of tracks representing the canonical source of a video.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("tracks")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("tracks"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The canonical list of tracks specifying the source of a video.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod source_clip_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 End;
        type Start;
        type Video;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type End = Unset;
        type Start = Unset;
        type Video = Unset;
    }
    ///State transition - sets the `end` field to Set
    pub struct SetEnd<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEnd<St> {}
    impl<St: State> State for SetEnd<St> {
        type End = Set<members::end>;
        type Start = St::Start;
        type Video = St::Video;
    }
    ///State transition - sets the `start` field to Set
    pub struct SetStart<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStart<St> {}
    impl<St: State> State for SetStart<St> {
        type End = St::End;
        type Start = Set<members::start>;
        type Video = St::Video;
    }
    ///State transition - sets the `video` field to Set
    pub struct SetVideo<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetVideo<St> {}
    impl<St: State> State for SetVideo<St> {
        type End = St::End;
        type Start = St::Start;
        type Video = Set<members::video>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `end` field
        pub struct end(());
        ///Marker type for the `start` field
        pub struct start(());
        ///Marker type for the `video` field
        pub struct video(());
    }
}

/// Builder for constructing an instance of this type.
pub struct SourceClipBuilder<St: source_clip_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<i64>, Option<i64>, Option<AtUri<S>>),
    _type: PhantomData<fn() -> S>,
}

impl SourceClip<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> SourceClipBuilder<source_clip_state::Empty, DefaultStr> {
        SourceClipBuilder::new()
    }
}

impl<S: BosStr> SourceClip<S> {
    /// Create a new builder for this type
    pub fn builder() -> SourceClipBuilder<source_clip_state::Empty, S> {
        SourceClipBuilder::builder()
    }
}

impl SourceClipBuilder<source_clip_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        SourceClipBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> SourceClipBuilder<source_clip_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        SourceClipBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SourceClipBuilder<St, S>
where
    St: source_clip_state::State,
    St::End: source_clip_state::IsUnset,
{
    /// Set the `end` field (required)
    pub fn end(
        mut self,
        value: impl Into<i64>,
    ) -> SourceClipBuilder<source_clip_state::SetEnd<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SourceClipBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SourceClipBuilder<St, S>
where
    St: source_clip_state::State,
    St::Start: source_clip_state::IsUnset,
{
    /// Set the `start` field (required)
    pub fn start(
        mut self,
        value: impl Into<i64>,
    ) -> SourceClipBuilder<source_clip_state::SetStart<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SourceClipBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SourceClipBuilder<St, S>
where
    St: source_clip_state::State,
    St::Video: source_clip_state::IsUnset,
{
    /// Set the `video` field (required)
    pub fn video(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> SourceClipBuilder<source_clip_state::SetVideo<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SourceClipBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SourceClipBuilder<St, S>
where
    St: source_clip_state::State,
    St::End: source_clip_state::IsSet,
    St::Start: source_clip_state::IsSet,
    St::Video: source_clip_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SourceClip<S> {
        SourceClip {
            end: self._fields.0.unwrap(),
            start: self._fields.1.unwrap(),
            video: 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<SmolStr, Data<S>>,
    ) -> SourceClip<S> {
        SourceClip {
            end: self._fields.0.unwrap(),
            start: self._fields.1.unwrap(),
            video: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod source_tracks_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 Tracks;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Tracks = Unset;
    }
    ///State transition - sets the `tracks` field to Set
    pub struct SetTracks<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTracks<St> {}
    impl<St: State> State for SetTracks<St> {
        type Tracks = Set<members::tracks>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `tracks` field
        pub struct tracks(());
    }
}

/// Builder for constructing an instance of this type.
pub struct SourceTracksBuilder<St: source_tracks_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Vec<StrongRef<S>>>,),
    _type: PhantomData<fn() -> S>,
}

impl SourceTracks<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> SourceTracksBuilder<source_tracks_state::Empty, DefaultStr> {
        SourceTracksBuilder::new()
    }
}

impl<S: BosStr> SourceTracks<S> {
    /// Create a new builder for this type
    pub fn builder() -> SourceTracksBuilder<source_tracks_state::Empty, S> {
        SourceTracksBuilder::builder()
    }
}

impl SourceTracksBuilder<source_tracks_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        SourceTracksBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> SourceTracksBuilder<source_tracks_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        SourceTracksBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SourceTracksBuilder<St, S>
where
    St: source_tracks_state::State,
    St::Tracks: source_tracks_state::IsUnset,
{
    /// Set the `tracks` field (required)
    pub fn tracks(
        mut self,
        value: impl Into<Vec<StrongRef<S>>>,
    ) -> SourceTracksBuilder<source_tracks_state::SetTracks<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SourceTracksBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SourceTracksBuilder<St, S>
where
    St: source_tracks_state::State,
    St::Tracks: source_tracks_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SourceTracks<S> {
        SourceTracks {
            tracks: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> SourceTracks<S> {
        SourceTracks {
            tracks: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}