From b8ee90bac9d004022c4da0216c6462a627c90756 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 4 Apr 2025 01:26:09 +0500 Subject: feat: emote base --- src/betterttv.rs | 16 +++++++++++++++- src/emotes.rs | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/betterttv.rs b/src/betterttv.rs index 0698a16..1fc99b2 100644 --- a/src/betterttv.rs +++ b/src/betterttv.rs @@ -2,7 +2,7 @@ use reqwest::{Client, Error}; use serde::Deserialize; use serde_json::Value; -use crate::emotes::RetrieveEmoteAPI; +use crate::emotes::{EmoteBase, RetrieveEmoteAPI}; #[derive(Debug, Deserialize, Clone)] pub struct BetterTTVEmote { @@ -15,6 +15,20 @@ pub struct BetterTTVEmote { pub animated: bool, } +impl EmoteBase for BetterTTVEmote { + fn get_id(&self) -> &String { + &self.id + } + + fn get_code(&self) -> &String { + &self.code + } + + fn get_original_code(&self) -> &Option { + &self.original_code + } +} + pub struct BetterTTVAPIClient { client: Client, base_url: String, diff --git a/src/emotes.rs b/src/emotes.rs index 7242f82..c602f84 100644 --- a/src/emotes.rs +++ b/src/emotes.rs @@ -1,6 +1,12 @@ use reqwest::Error; use serde::{Deserialize, Serialize}; +pub trait EmoteBase { + fn get_id(&self) -> &String; + fn get_code(&self) -> &String; + fn get_original_code(&self) -> &Option; +} + #[derive(Deserialize, Serialize, Clone, Debug)] pub struct Emote { pub id: String, @@ -8,6 +14,20 @@ pub struct Emote { pub original_code: Option, } +impl EmoteBase for Emote { + fn get_id(&self) -> &String { + &self.id + } + + fn get_code(&self) -> &String { + &self.code + } + + fn get_original_code(&self) -> &Option { + &self.original_code + } +} + pub trait RetrieveEmoteAPI { async fn get_channel_emotes(&self, channel_login: &str) -> Result, Error>; async fn get_global_emotes(&self) -> Result, Error>; -- cgit v1.2.3