Browse and listen to thousands of radio stations across the globe right from your terminal 🌎 📻 🎵✨
radio rust tokio web-radio command-line-tool tui
at main 28 lines 784 B view raw
1pub mod radiobrowser; 2pub mod tunein; 3 4use crate::types::Station; 5use anyhow::Error; 6use async_trait::async_trait; 7use regex::Regex; 8 9#[async_trait] 10pub trait Provider { 11 async fn search(&self, name: String) -> Result<Vec<Station>, Error>; 12 async fn get_station(&self, id: String) -> Result<Option<Station>, Error>; 13 async fn browse( 14 &self, 15 category: String, 16 offset: u32, 17 limit: u32, 18 ) -> Result<Vec<Station>, Error>; 19 async fn categories(&self, offset: u32, limit: u32) -> Result<Vec<String>, Error>; 20} 21 22pub fn is_valid_uuid(uuid: &str) -> bool { 23 let uuid_pattern = Regex::new( 24 r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" 25 ).unwrap(); 26 27 uuid_pattern.is_match(uuid) 28}