use crate::types;
use serde_derive::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Message {
pub text: String,
pub fragments: Vec<Fragment>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[non_exhaustive]
pub enum Fragment {
Cheermote {
text: String,
cheermote: Cheermote,
},
Emote {
text: String,
emote: Emote,
},
Mention {
text: String,
mention: Mention,
},
Text {
text: String,
},
}
impl Fragment {
pub fn text(&self) -> &str {
match self {
Self::Cheermote { text, .. } => text,
Self::Emote { text, .. } => text,
Self::Mention { text, .. } => text,
Self::Text { text } => text,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct Cheermote {
pub prefix: String,
pub bits: i32,
pub tier: i32,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct Emote {
pub id: types::EmoteId,
pub emote_set_id: types::EmoteSetId,
pub owner_id: types::UserId,
pub format: Vec<types::EmoteAnimationSetting>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct Mention {
pub user_id: types::UserId,
pub user_name: types::DisplayName,
pub user_login: types::UserName,
}