use crate::types::File; use std::path::{Path}; use walkdir::WalkDir; pub mod ascii_reduce; pub mod tag_extractor; pub mod transcoder; pub fn is_valid_file_extension(file_path: &Path) -> bool { let ext = file_path.extension().unwrap().to_str().unwrap(); matches!(ext, "mp3" | "flac") } pub fn scan_for_music(src_dir: &String) -> Result, Box> { let mut files: Vec = Vec::new(); for entry in WalkDir::new(&src_dir) { let entry = entry.unwrap(); let entry_path = entry.into_path(); if entry_path.is_dir() { continue; } if is_valid_file_extension(&entry_path) { let file = File::from_path( src_dir.clone(), entry_path, ); files.push(file); } } Ok(files) }