manual_braid! {
pub struct UserId;
pub struct UserIdRef;
}
impl_extra!(numeric, UserId, UserIdRef);
manual_braid! {
pub struct DisplayName;
pub struct DisplayNameRef;
}
impl_extra!(DisplayName, DisplayNameRef);
manual_braid! {
pub struct Nickname;
pub struct NicknameRef;
}
impl_extra!(ascii, Nickname, NicknameRef);
pub type UserName = Nickname;
pub type UserNameRef = NicknameRef;
manual_braid! {
pub struct MsgId;
pub struct MsgIdRef;
}
impl_extra!(MsgId, MsgIdRef);
#[derive(Copy, Clone, Default, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde_derive::Deserialize))]
pub enum BroadcasterType {
#[cfg_attr(feature = "serde", serde(rename = "partner"))]
Partner,
#[cfg_attr(feature = "serde", serde(rename = "affiliate"))]
Affiliate,
#[cfg_attr(feature = "serde", serde(other))]
#[default]
None,
}
#[cfg(feature = "serde")]
impl serde::Serialize for BroadcasterType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer {
serializer.serialize_str(match self {
BroadcasterType::Partner => "partner",
BroadcasterType::Affiliate => "affiliate",
BroadcasterType::None => "",
})
}
}
#[derive(Copy, Clone, Default, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde_derive::Deserialize))]
pub enum UserType {
#[cfg_attr(feature = "serde", serde(rename = "staff"))]
Staff,
#[cfg_attr(feature = "serde", serde(rename = "admin"))]
Admin,
#[cfg_attr(feature = "serde", serde(rename = "global_mod"))]
GlobalMod,
#[cfg_attr(feature = "serde", serde(other))]
#[default]
None,
}
impl UserType {
pub fn parse(input: &str) -> Self {
match input {
"admin" => Self::Admin,
"global_mod" => Self::GlobalMod,
"staff" => Self::Staff,
_ => Self::None,
}
}
}
#[cfg(feature = "serde")]
impl serde::Serialize for UserType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer {
serializer.serialize_str(match self {
UserType::Staff => "staff",
UserType::Admin => "admin",
UserType::GlobalMod => "global_mod",
UserType::None => "",
})
}
}