// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: app.bsky.video.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. pub mod get_job_status; pub mod get_upload_limits; pub mod upload_video; #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct JobStatus<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub blob: std::option::Option>, #[serde(borrow)] pub did: jacquard_common::types::string::Did<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub error: std::option::Option>, #[serde(borrow)] pub job_id: jacquard_common::CowStr<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub message: std::option::Option>, /// Progress within the current processing state. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub progress: std::option::Option, /// The state of the video processing job. All values not listed as a known value indicate that the job is in process. #[serde(borrow)] pub state: JobStatusState<'a>, } pub mod job_status_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 State; type JobId; type Did; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type State = Unset; type JobId = Unset; type Did = Unset; } ///State transition - sets the `state` field to Set pub struct SetState(PhantomData S>); impl sealed::Sealed for SetState {} impl State for SetState { type State = Set; type JobId = S::JobId; type Did = S::Did; } ///State transition - sets the `job_id` field to Set pub struct SetJobId(PhantomData S>); impl sealed::Sealed for SetJobId {} impl State for SetJobId { type State = S::State; type JobId = Set; type Did = S::Did; } ///State transition - sets the `did` field to Set pub struct SetDid(PhantomData S>); impl sealed::Sealed for SetDid {} impl State for SetDid { type State = S::State; type JobId = S::JobId; type Did = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `state` field pub struct state(()); ///Marker type for the `job_id` field pub struct job_id(()); ///Marker type for the `did` field pub struct did(()); } } /// Builder for constructing an instance of this type pub struct JobStatusBuilder<'a, S: job_status_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> JobStatus<'a> { /// Create a new builder for this type pub fn new() -> JobStatusBuilder<'a, job_status_state::Empty> { JobStatusBuilder::new() } } impl<'a> JobStatusBuilder<'a, job_status_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { JobStatusBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> { /// Set the `blob` field (optional) pub fn blob( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `blob` field to an Option value (optional) pub fn maybe_blob( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S> JobStatusBuilder<'a, S> where S: job_status_state::State, S::Did: job_status_state::IsUnset, { /// Set the `did` field (required) pub fn did( mut self, value: impl Into>, ) -> JobStatusBuilder<'a, job_status_state::SetDid> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); JobStatusBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> { /// Set the `error` field (optional) pub fn error( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `error` field to an Option value (optional) pub fn maybe_error(mut self, value: Option>) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> JobStatusBuilder<'a, S> where S: job_status_state::State, S::JobId: job_status_state::IsUnset, { /// Set the `jobId` field (required) pub fn job_id( mut self, value: impl Into>, ) -> JobStatusBuilder<'a, job_status_state::SetJobId> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); JobStatusBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> { /// Set the `message` field (optional) pub fn message( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `message` field to an Option value (optional) pub fn maybe_message(mut self, value: Option>) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> { /// Set the `progress` field (optional) pub fn progress(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `progress` field to an Option value (optional) pub fn maybe_progress(mut self, value: Option) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S> JobStatusBuilder<'a, S> where S: job_status_state::State, S::State: job_status_state::IsUnset, { /// Set the `state` field (required) pub fn state( mut self, value: impl Into>, ) -> JobStatusBuilder<'a, job_status_state::SetState> { self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into()); JobStatusBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> JobStatusBuilder<'a, S> where S: job_status_state::State, S::State: job_status_state::IsSet, S::JobId: job_status_state::IsSet, S::Did: job_status_state::IsSet, { /// Build the final struct pub fn build(self) -> JobStatus<'a> { JobStatus { blob: self.__unsafe_private_named.0, did: self.__unsafe_private_named.1.unwrap(), error: self.__unsafe_private_named.2, job_id: self.__unsafe_private_named.3.unwrap(), message: self.__unsafe_private_named.4, progress: self.__unsafe_private_named.5, state: self.__unsafe_private_named.6.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> JobStatus<'a> { JobStatus { blob: self.__unsafe_private_named.0, did: self.__unsafe_private_named.1.unwrap(), error: self.__unsafe_private_named.2, job_id: self.__unsafe_private_named.3.unwrap(), message: self.__unsafe_private_named.4, progress: self.__unsafe_private_named.5, state: self.__unsafe_private_named.6.unwrap(), extra_data: Some(extra_data), } } } /// The state of the video processing job. All values not listed as a known value indicate that the job is in process. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum JobStatusState<'a> { JobStateCompleted, JobStateFailed, Other(jacquard_common::CowStr<'a>), } impl<'a> JobStatusState<'a> { pub fn as_str(&self) -> &str { match self { Self::JobStateCompleted => "JOB_STATE_COMPLETED", Self::JobStateFailed => "JOB_STATE_FAILED", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for JobStatusState<'a> { fn from(s: &'a str) -> Self { match s { "JOB_STATE_COMPLETED" => Self::JobStateCompleted, "JOB_STATE_FAILED" => Self::JobStateFailed, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for JobStatusState<'a> { fn from(s: String) -> Self { match s.as_str() { "JOB_STATE_COMPLETED" => Self::JobStateCompleted, "JOB_STATE_FAILED" => Self::JobStateFailed, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> core::fmt::Display for JobStatusState<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> AsRef for JobStatusState<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> serde::Serialize for JobStatusState<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for JobStatusState<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl<'a> Default for JobStatusState<'a> { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for JobStatusState<'_> { type Output = JobStatusState<'static>; fn into_static(self) -> Self::Output { match self { JobStatusState::JobStateCompleted => JobStatusState::JobStateCompleted, JobStatusState::JobStateFailed => JobStatusState::JobStateFailed, JobStatusState::Other(v) => JobStatusState::Other(v.into_static()), } } } fn lexicon_doc_app_bsky_video_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("app.bsky.video.defs"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("jobStatus"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("jobId"), ::jacquard_common::smol_str::SmolStr::new_static("did"), ::jacquard_common::smol_str::SmolStr::new_static("state") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("blob"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("did"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Did, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("error"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("jobId"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("message"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("progress"), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: Some(0i64), maximum: Some(100i64), r#enum: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("state"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "The state of the video processing job. All values not listed as a known value indicate that the job is in process.", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for JobStatus<'a> { fn nsid() -> &'static str { "app.bsky.video.defs" } fn def_name() -> &'static str { "jobStatus" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_app_bsky_video_defs() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.progress { if *value > 100i64 { return Err(::jacquard_lexicon::validation::ConstraintError::Maximum { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "progress", ), max: 100i64, actual: *value, }); } } if let Some(ref value) = self.progress { if *value < 0i64 { return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "progress", ), min: 0i64, actual: *value, }); } } Ok(()) } }