use std::path::{Path, PathBuf};
use tauri::{AppHandle, command, Runtime};
use crate::models::*;
use crate::Result;
use crate::IndexerExt;
use crate::indexer::indexer::index;
#[command]
pub(crate) async fn ping<R: Runtime>(
app: AppHandle<R>,
payload: PingRequest,
) -> Result<PingResponse> {
app.indexer().ping(payload)
}
#[command]
pub(crate) async fn index_directory(path: String) -> Result<()> {
match index::index_directory(PathBuf::from(path)) {
Ok(_) => Ok(()),
Err(e) => {
eprintln!("Error indexing directory: {}", e);
Err(std::io::Error::new(
std::io::ErrorKind::Other,
e.to_string()
).into())
}
}
}