pub mod get_job_status;
pub mod get_upload_limits;
pub mod upload_video;
#[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::blob::BlobRef;
use jacquard_common::types::string::Did;
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::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct JobStatus<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub blob: Option<BlobRef<S>>,
pub did: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<S>,
pub job_id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub progress: Option<i64>,
pub state: JobStatusState<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum JobStatusState<S: BosStr = DefaultStr> {
JobStateCompleted,
JobStateFailed,
Other(S),
}
impl<S: BosStr> JobStatusState<S> {
pub fn as_str(&self) -> &str {
match self {
Self::JobStateCompleted => "JOB_STATE_COMPLETED",
Self::JobStateFailed => "JOB_STATE_FAILED",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"JOB_STATE_COMPLETED" => Self::JobStateCompleted,
"JOB_STATE_FAILED" => Self::JobStateFailed,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for JobStatusState<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for JobStatusState<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for JobStatusState<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for JobStatusState<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for JobStatusState<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for JobStatusState<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = JobStatusState<S::Output>;
fn into_static(self) -> Self::Output {
match self {
JobStatusState::JobStateCompleted => JobStatusState::JobStateCompleted,
JobStatusState::JobStateFailed => JobStatusState::JobStateFailed,
JobStatusState::Other(v) => JobStatusState::Other(v.into_static()),
}
}
}
impl<S: BosStr> LexiconSchema for JobStatus<S> {
fn nsid() -> &'static str {
"app.bsky.video.defs"
}
fn def_name() -> &'static str {
"jobStatus"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_video_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.progress {
if *value > 100i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("progress"),
max: 100i64,
actual: *value,
});
}
}
if let Some(ref value) = self.progress {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("progress"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
pub mod job_status_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 Did;
type State;
type JobId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
type State = Unset;
type JobId = Unset;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
type State = St::State;
type JobId = St::JobId;
}
pub struct SetState<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetState<St> {}
impl<St: State> State for SetState<St> {
type Did = St::Did;
type State = Set<members::state>;
type JobId = St::JobId;
}
pub struct SetJobId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetJobId<St> {}
impl<St: State> State for SetJobId<St> {
type Did = St::Did;
type State = St::State;
type JobId = Set<members::job_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
pub struct state(());
pub struct job_id(());
}
}
pub struct JobStatusBuilder<S: BosStr, St: job_status_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<BlobRef<S>>,
Option<Did<S>>,
Option<S>,
Option<S>,
Option<S>,
Option<i64>,
Option<JobStatusState<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> JobStatus<S> {
pub fn new() -> JobStatusBuilder<S, job_status_state::Empty> {
JobStatusBuilder::new()
}
}
impl<S: BosStr> JobStatusBuilder<S, job_status_state::Empty> {
pub fn new() -> Self {
JobStatusBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: job_status_state::State> JobStatusBuilder<S, St> {
pub fn blob(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_blob(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> JobStatusBuilder<S, St>
where
St: job_status_state::State,
St::Did: job_status_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> JobStatusBuilder<S, job_status_state::SetDid<St>> {
self._fields.1 = Option::Some(value.into());
JobStatusBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: job_status_state::State> JobStatusBuilder<S, St> {
pub fn error(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_error(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> JobStatusBuilder<S, St>
where
St: job_status_state::State,
St::JobId: job_status_state::IsUnset,
{
pub fn job_id(
mut self,
value: impl Into<S>,
) -> JobStatusBuilder<S, job_status_state::SetJobId<St>> {
self._fields.3 = Option::Some(value.into());
JobStatusBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: job_status_state::State> JobStatusBuilder<S, St> {
pub fn message(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_message(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: job_status_state::State> JobStatusBuilder<S, St> {
pub fn progress(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_progress(mut self, value: Option<i64>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St> JobStatusBuilder<S, St>
where
St: job_status_state::State,
St::State: job_status_state::IsUnset,
{
pub fn state(
mut self,
value: impl Into<JobStatusState<S>>,
) -> JobStatusBuilder<S, job_status_state::SetState<St>> {
self._fields.6 = Option::Some(value.into());
JobStatusBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> JobStatusBuilder<S, St>
where
St: job_status_state::State,
St::Did: job_status_state::IsSet,
St::State: job_status_state::IsSet,
St::JobId: job_status_state::IsSet,
{
pub fn build(self) -> JobStatus<S> {
JobStatus {
blob: self._fields.0,
did: self._fields.1.unwrap(),
error: self._fields.2,
job_id: self._fields.3.unwrap(),
message: self._fields.4,
progress: self._fields.5,
state: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> JobStatus<S> {
JobStatus {
blob: self._fields.0,
did: self._fields.1.unwrap(),
error: self._fields.2,
job_id: self._fields.3.unwrap(),
message: self._fields.4,
progress: self._fields.5,
state: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_bsky_video_defs() -> 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("app.bsky.video.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("jobStatus"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("jobId"), SmolStr::new_static("did"),
SmolStr::new_static("state")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blob"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("error"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("jobId"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("progress"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(100i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("state"),
LexObjectProperty::String(LexString {
description: Some(
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.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}