#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use serde::{Serialize, Deserialize};
use crate::place_stream::video::Video;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PublishVideo<S: BosStr = DefaultStr> {
pub record: Video<S>,
pub upload_id: 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 PublishVideoOutput<S: BosStr = DefaultStr> {
pub cid: Cid<S>,
pub uri: AtUri<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,
thiserror::Error,
miette::Diagnostic
)]
#[serde(tag = "error", content = "message")]
pub enum PublishVideoError {
#[serde(rename = "UploadNotFound")]
UploadNotFound(Option<SmolStr>),
#[serde(rename = "UploadNotReady")]
UploadNotReady(Option<SmolStr>),
#[serde(untagged)]
Other { error: SmolStr, message: Option<SmolStr> },
}
impl core::fmt::Display for PublishVideoError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::UploadNotFound(msg) => {
write!(f, "UploadNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::UploadNotReady(msg) => {
write!(f, "UploadNotReady")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
pub struct PublishVideoResponse;
impl jacquard_common::xrpc::XrpcResp for PublishVideoResponse {
const NSID: &'static str = "place.stream.media.publishVideo";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = PublishVideoOutput<S>;
type Err = PublishVideoError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for PublishVideo<S> {
const NSID: &'static str = "place.stream.media.publishVideo";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = PublishVideoResponse;
}
pub struct PublishVideoRequest;
impl jacquard_common::xrpc::XrpcEndpoint for PublishVideoRequest {
const PATH: &'static str = "/xrpc/place.stream.media.publishVideo";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<S: BosStr> = PublishVideo<S>;
type Response = PublishVideoResponse;
}
pub mod publish_video_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Record;
type UploadId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Record = Unset;
type UploadId = Unset;
}
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 Record = Set<members::record>;
type UploadId = St::UploadId;
}
pub struct SetUploadId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUploadId<St> {}
impl<St: State> State for SetUploadId<St> {
type Record = St::Record;
type UploadId = Set<members::upload_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct record(());
pub struct upload_id(());
}
}
pub struct PublishVideoBuilder<St: publish_video_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Video<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl PublishVideo<DefaultStr> {
pub fn new() -> PublishVideoBuilder<publish_video_state::Empty, DefaultStr> {
PublishVideoBuilder::new()
}
}
impl<S: BosStr> PublishVideo<S> {
pub fn builder() -> PublishVideoBuilder<publish_video_state::Empty, S> {
PublishVideoBuilder::builder()
}
}
impl PublishVideoBuilder<publish_video_state::Empty, DefaultStr> {
pub fn new() -> Self {
PublishVideoBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> PublishVideoBuilder<publish_video_state::Empty, S> {
pub fn builder() -> Self {
PublishVideoBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> PublishVideoBuilder<St, S>
where
St: publish_video_state::State,
St::Record: publish_video_state::IsUnset,
{
pub fn record(
mut self,
value: impl Into<Video<S>>,
) -> PublishVideoBuilder<publish_video_state::SetRecord<St>, S> {
self._fields.0 = Option::Some(value.into());
PublishVideoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> PublishVideoBuilder<St, S>
where
St: publish_video_state::State,
St::UploadId: publish_video_state::IsUnset,
{
pub fn upload_id(
mut self,
value: impl Into<S>,
) -> PublishVideoBuilder<publish_video_state::SetUploadId<St>, S> {
self._fields.1 = Option::Some(value.into());
PublishVideoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> PublishVideoBuilder<St, S>
where
St: publish_video_state::State,
St::Record: publish_video_state::IsSet,
St::UploadId: publish_video_state::IsSet,
{
pub fn build(self) -> PublishVideo<S> {
PublishVideo {
record: self._fields.0.unwrap(),
upload_id: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> PublishVideo<S> {
PublishVideo {
record: self._fields.0.unwrap(),
upload_id: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}