#[cfg(feature = "discord")]
mod discord;
mod error;
#[cfg(feature = "instagram")]
mod instagram;
#[cfg(any(feature = "telegram", feature = "instagram"))]
mod json_array;
#[cfg(feature = "telegram")]
mod telegram;
mod traits;
#[cfg(feature = "whatsapp")]
mod whatsapp;
#[cfg(feature = "discord")]
pub use discord::DiscordStreamingParser;
pub use error::{StreamingError, StreamingResult};
#[cfg(feature = "instagram")]
pub use instagram::InstagramStreamingParser;
#[cfg(feature = "telegram")]
pub use telegram::TelegramStreamingParser;
pub use traits::{MessageIterator, StreamingConfig, StreamingParser};
#[cfg(feature = "whatsapp")]
pub use whatsapp::WhatsAppStreamingParser;
use crate::parser::Platform;
pub fn create_streaming_parser(platform: Platform) -> Box<dyn StreamingParser> {
match platform {
#[cfg(feature = "telegram")]
Platform::Telegram => Box::new(TelegramStreamingParser::new()),
#[cfg(feature = "discord")]
Platform::Discord => Box::new(DiscordStreamingParser::new()),
#[cfg(feature = "instagram")]
Platform::Instagram => Box::new(InstagramStreamingParser::new()),
#[cfg(feature = "whatsapp")]
Platform::WhatsApp => Box::new(WhatsAppStreamingParser::new()),
#[allow(unreachable_patterns)]
_ => panic!(
"Streaming parser for {:?} is not enabled. Enable the corresponding feature.",
platform
),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[cfg(feature = "telegram")]
#[test]
fn test_create_streaming_parser_telegram() {
let parser = create_streaming_parser(Platform::Telegram);
assert_eq!(parser.name(), "Telegram (Streaming)");
}
#[cfg(feature = "discord")]
#[test]
fn test_create_streaming_parser_discord() {
let parser = create_streaming_parser(Platform::Discord);
assert_eq!(parser.name(), "Discord (Streaming)");
}
#[cfg(feature = "instagram")]
#[test]
fn test_create_streaming_parser_instagram() {
let parser = create_streaming_parser(Platform::Instagram);
assert_eq!(parser.name(), "Instagram (Streaming)");
}
#[cfg(feature = "whatsapp")]
#[test]
fn test_create_streaming_parser_whatsapp() {
let parser = create_streaming_parser(Platform::WhatsApp);
assert_eq!(parser.name(), "WhatsApp (Streaming)");
}
}