#[cfg(feature = "serde")]
use serde::Serialize;
manual_braid! {
pub struct StreamId;
pub struct StreamIdRef;
}
impl_extra!(StreamId, StreamIdRef);
manual_braid! {
pub struct CategoryId;
pub struct CategoryIdRef;
}
impl_extra!(CategoryId, CategoryIdRef);
manual_braid! {
pub struct TagId;
pub struct TagIdRef;
}
impl_extra!(TagId, TagIdRef);
manual_braid! {
pub struct TeamId;
pub struct TeamIdRef;
}
impl_extra!(TeamId, TeamIdRef);
manual_braid! {
pub struct VideoId;
pub struct VideoIdRef;
}
impl_extra!(VideoId, VideoIdRef);
manual_braid! {
pub struct ClipId;
pub struct ClipIdRef;
}
impl_extra!(ClipId, ClipIdRef);
manual_braid! {
pub struct StreamSegmentId;
pub struct StreamSegmentIdRef;
}
impl_extra!(StreamSegmentId, StreamSegmentIdRef);
manual_braid! {
pub struct HypeTrainId;
pub struct HypeTrainIdRef;
}
impl_extra!(HypeTrainId, HypeTrainIdRef);
manual_braid! {
pub struct CharityCampaignId;
pub struct CharityCampaignIdRef;
}
impl_extra!(CharityCampaignId, CharityCampaignIdRef);
manual_braid! {
pub struct CharityDonationId;
pub struct CharityDonationIdRef;
}
impl_extra!(CharityDonationId, CharityDonationIdRef);
manual_braid! {
pub struct IgdbId;
pub struct IgdbIdRef;
}
impl_extra!(IgdbId, IgdbIdRef);
manual_braid! {
pub struct GuestStarSessionId;
pub struct GuestStarSessionIdRef;
}
impl_extra!(GuestStarSessionId, GuestStarSessionIdRef);
manual_braid! {
pub struct GuestStarSlotId;
pub struct GuestStarSlotIdRef;
}
impl_extra!(GuestStarSlotId, GuestStarSlotIdRef);
manual_braid! {
pub struct StreamMarkerId;
pub struct StreamMarkerIdRef;
}
impl_extra!(StreamMarkerId, StreamMarkerIdRef);
manual_braid! {
redact("stream key");
pub struct StreamKey;
pub struct StreamKeyRef;
}
impl_extra!(StreamKey, StreamKeyRef);
#[derive(PartialEq, Eq, Debug, Clone)]
#[cfg_attr(
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct TwitchCategory {
pub box_art_url: String,
pub id: CategoryId,
pub name: String,
#[cfg_attr(
feature = "serde",
serde(
deserialize_with = "crate::deserialize_none_from_empty_string",
default
)
)]
pub igdb_id: Option<IgdbId>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde_derive::Deserialize))]
#[cfg_attr(feature = "serde", serde(field_identifier))]
pub enum SubscriptionTier {
#[cfg_attr(feature = "serde", serde(rename = "1000"))]
Tier1,
#[cfg_attr(feature = "serde", serde(rename = "2000"))]
Tier2,
#[cfg_attr(feature = "serde", serde(rename = "3000"))]
Tier3,
Prime,
Other(String),
}
#[cfg(feature = "serde")]
impl Serialize for SubscriptionTier {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer {
serializer.serialize_str(match self {
SubscriptionTier::Tier1 => "1000",
SubscriptionTier::Tier2 => "2000",
SubscriptionTier::Tier3 => "3000",
SubscriptionTier::Prime => "Prime",
SubscriptionTier::Other(o) => o,
})
}
}
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
pub enum VideoPeriod {
All,
Day,
Week,
Month,
}
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
pub enum VideoType {
Live,
Playlist,
Upload,
Archive,
Highlight,
Premiere,
Rerun,
WatchParty,
WatchPartyPremiere,
WatchPartyRerun,
}
#[derive(PartialEq, Eq, Clone, Debug)]
#[cfg_attr(
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
pub enum VideoPrivacy {
Public,
Private,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
#[non_exhaustive]
pub enum CommercialLength {
Length30 = 30,
Length60 = 60,
Length90 = 90,
Length120 = 120,
Length150 = 150,
Length180 = 180,
}
#[cfg(feature = "serde")]
impl serde::Serialize for CommercialLength {
#[allow(clippy::use_self)]
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where S: serde::Serializer {
let value: u64 = *self as u64;
serde::Serialize::serialize(&value, serializer)
}
}
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for CommercialLength {
#[allow(clippy::use_self)]
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where D: serde::Deserializer<'de> {
#[allow(non_camel_case_types)]
struct discriminant;
#[allow(non_upper_case_globals)]
impl discriminant {
const Length120: u64 = CommercialLength::Length120 as u64;
const Length150: u64 = CommercialLength::Length150 as u64;
const Length180: u64 = CommercialLength::Length180 as u64;
const Length30: u64 = CommercialLength::Length30 as u64;
const Length60: u64 = CommercialLength::Length60 as u64;
const Length90: u64 = CommercialLength::Length90 as u64;
}
match <u64 as serde::Deserialize>::deserialize(deserializer)? {
discriminant::Length30 => core::result::Result::Ok(CommercialLength::Length30),
discriminant::Length60 => core::result::Result::Ok(CommercialLength::Length60),
discriminant::Length90 => core::result::Result::Ok(CommercialLength::Length90),
discriminant::Length120 => core::result::Result::Ok(CommercialLength::Length120),
discriminant::Length150 => core::result::Result::Ok(CommercialLength::Length150),
discriminant::Length180 => core::result::Result::Ok(CommercialLength::Length180),
other => core::result::Result::Err(serde::de::Error::custom(format_args!(
"invalid value: {}, expected one of: {}, {}, {}, {}, {}, {}",
other,
discriminant::Length30,
discriminant::Length60,
discriminant::Length90,
discriminant::Length120,
discriminant::Length150,
discriminant::Length180
))),
}
}
}
impl std::fmt::Display for CommercialLength {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}s", *self as u64)
}
}
impl std::convert::TryFrom<u64> for CommercialLength {
type Error = CommercialLengthParseError;
fn try_from(l: u64) -> Result<Self, Self::Error> {
match l {
30 => Ok(CommercialLength::Length30),
60 => Ok(CommercialLength::Length60),
90 => Ok(CommercialLength::Length90),
120 => Ok(CommercialLength::Length120),
150 => Ok(CommercialLength::Length150),
180 => Ok(CommercialLength::Length180),
other => Err(CommercialLengthParseError::InvalidLength(other)),
}
}
}
#[derive(Debug)]
pub enum CommercialLengthParseError {
InvalidLength(u64),
}
impl std::error::Error for CommercialLengthParseError {}
impl core::fmt::Display for CommercialLengthParseError {
fn fmt(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
#[allow(unused_variables)]
match self {
CommercialLengthParseError::InvalidLength(len) => {
write!(formatter, "invalid length of {len}")
}
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde_derive::Deserialize))]
#[cfg_attr(feature = "serde", serde(field_identifier))]
pub enum ContentClassificationId {
DrugsIntoxication,
SexualThemes,
ViolentGraphic,
Gambling,
ProfanityVulgarity,
MatureGame,
Other(String),
}
#[cfg(feature = "serde")]
impl Serialize for ContentClassificationId {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer {
serializer.serialize_str(match self {
ContentClassificationId::DrugsIntoxication => "DrugsIntoxication",
ContentClassificationId::SexualThemes => "SexualThemes",
ContentClassificationId::ViolentGraphic => "ViolentGraphic",
ContentClassificationId::Gambling => "Gambling",
ContentClassificationId::ProfanityVulgarity => "ProfanityVulgarity",
ContentClassificationId::MatureGame => "MatureGame",
ContentClassificationId::Other(o) => o,
})
}
}