2026-11-19 20:08:21 +01:00
|
|
|
mod media;
|
2026-11-19 20:31:29 +01:00
|
|
|
mod thumbnails;
|
2026-11-19 20:08:21 +01:00
|
|
|
|
|
|
|
|
use media::{list_files, FileInfo};
|
2026-11-19 20:31:29 +01:00
|
|
|
use thumbnails::{ThumbnailCache, get_thumbnail};
|
|
|
|
|
use tauri::State;
|
2026-11-19 20:08:21 +01:00
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
async fn list_files_command(dir_path: String) -> Result<Vec<FileInfo>, String> {
|
|
|
|
|
list_files(&dir_path).map_err(|e| e.to_string())
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-19 20:31:29 +01:00
|
|
|
#[tauri::command]
|
|
|
|
|
async fn get_thumbnail_command(path: String, cache: State<'_, ThumbnailCache>) -> Result<String, String> {
|
|
|
|
|
get_thumbnail(&path, cache.inner()).await.map_err(|e| e.to_string())
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-19 20:08:21 +01:00
|
|
|
#[tauri::command]
|
|
|
|
|
fn greet(name: &str) -> String {
|
|
|
|
|
format!("Hello, {}! You've been greeted from Rust!", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
|
|
|
pub fn run() {
|
|
|
|
|
tauri::Builder::default()
|
|
|
|
|
.plugin(tauri_plugin_opener::init())
|
|
|
|
|
.plugin(tauri_plugin_dialog::init())
|
2026-11-19 20:31:29 +01:00
|
|
|
.manage(ThumbnailCache::default())
|
|
|
|
|
.invoke_handler(tauri::generate_handler![greet, list_files_command, get_thumbnail_command])
|
2026-11-19 20:08:21 +01:00
|
|
|
.run(tauri::generate_context!())
|
|
|
|
|
.expect("error while running tauri application");
|
|
|
|
|
}
|