#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid, Did};
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::{IntoStatic, open_union};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct UpdateLivestream<S: BosStr = DefaultStr> {
pub livestream_uri: AtUri<S>,
pub streamer: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<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 UpdateLivestreamOutput<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 UpdateLivestreamError {
#[serde(rename = "Unauthorized")]
Unauthorized(Option<SmolStr>),
#[serde(rename = "Forbidden")]
Forbidden(Option<SmolStr>),
#[serde(rename = "SessionNotFound")]
SessionNotFound(Option<SmolStr>),
#[serde(rename = "RecordNotFound")]
RecordNotFound(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
impl core::fmt::Display for UpdateLivestreamError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Unauthorized(msg) => {
write!(f, "Unauthorized")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Forbidden(msg) => {
write!(f, "Forbidden")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::SessionNotFound(msg) => {
write!(f, "SessionNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::RecordNotFound(msg) => {
write!(f, "RecordNotFound")?;
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 UpdateLivestreamResponse;
impl jacquard_common::xrpc::XrpcResp for UpdateLivestreamResponse {
const NSID: &'static str = "place.stream.moderation.updateLivestream";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = UpdateLivestreamOutput<S>;
type Err = UpdateLivestreamError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for UpdateLivestream<S> {
const NSID: &'static str = "place.stream.moderation.updateLivestream";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = UpdateLivestreamResponse;
}
pub struct UpdateLivestreamRequest;
impl jacquard_common::xrpc::XrpcEndpoint for UpdateLivestreamRequest {
const PATH: &'static str = "/xrpc/place.stream.moderation.updateLivestream";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = UpdateLivestream<S>;
type Response = UpdateLivestreamResponse;
}
pub mod update_livestream_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 LivestreamUri;
type Streamer;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type LivestreamUri = Unset;
type Streamer = Unset;
}
pub struct SetLivestreamUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLivestreamUri<St> {}
impl<St: State> State for SetLivestreamUri<St> {
type LivestreamUri = Set<members::livestream_uri>;
type Streamer = St::Streamer;
}
pub struct SetStreamer<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStreamer<St> {}
impl<St: State> State for SetStreamer<St> {
type LivestreamUri = St::LivestreamUri;
type Streamer = Set<members::streamer>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct livestream_uri(());
pub struct streamer(());
}
}
pub struct UpdateLivestreamBuilder<S: BosStr, St: update_livestream_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtUri<S>>, Option<Did<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> UpdateLivestream<S> {
pub fn new() -> UpdateLivestreamBuilder<S, update_livestream_state::Empty> {
UpdateLivestreamBuilder::new()
}
}
impl<S: BosStr> UpdateLivestreamBuilder<S, update_livestream_state::Empty> {
pub fn new() -> Self {
UpdateLivestreamBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateLivestreamBuilder<S, St>
where
St: update_livestream_state::State,
St::LivestreamUri: update_livestream_state::IsUnset,
{
pub fn livestream_uri(
mut self,
value: impl Into<AtUri<S>>,
) -> UpdateLivestreamBuilder<S, update_livestream_state::SetLivestreamUri<St>> {
self._fields.0 = Option::Some(value.into());
UpdateLivestreamBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UpdateLivestreamBuilder<S, St>
where
St: update_livestream_state::State,
St::Streamer: update_livestream_state::IsUnset,
{
pub fn streamer(
mut self,
value: impl Into<Did<S>>,
) -> UpdateLivestreamBuilder<S, update_livestream_state::SetStreamer<St>> {
self._fields.1 = Option::Some(value.into());
UpdateLivestreamBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: update_livestream_state::State> UpdateLivestreamBuilder<S, St> {
pub fn title(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_title(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> UpdateLivestreamBuilder<S, St>
where
St: update_livestream_state::State,
St::LivestreamUri: update_livestream_state::IsSet,
St::Streamer: update_livestream_state::IsSet,
{
pub fn build(self) -> UpdateLivestream<S> {
UpdateLivestream {
livestream_uri: self._fields.0.unwrap(),
streamer: self._fields.1.unwrap(),
title: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> UpdateLivestream<S> {
UpdateLivestream {
livestream_uri: self._fields.0.unwrap(),
streamer: self._fields.1.unwrap(),
title: self._fields.2,
extra_data: Some(extra_data),
}
}
}