game_manager_lib\commands\metadata/
search.rs1use crate::database;
7use crate::errors::AppError;
8use crate::services::gamerpower::{self, Giveaway};
9use crate::services::rawg;
10use tauri::AppHandle;
11
12#[tauri::command]
14pub async fn fetch_game_details(
15 app: AppHandle,
16 query: String,
17) -> Result<rawg::GameDetails, AppError> {
18 let api_key = database::get_secret(&app, "rawg_api_key")?;
19 rawg::fetch_game_details(&api_key, query)
20 .await
21 .map_err(AppError::NetworkError)
22}
23
24#[tauri::command]
26pub async fn get_trending_games(app: AppHandle) -> Result<Vec<rawg::RawgGame>, AppError> {
27 let api_key = database::get_secret(&app, "rawg_api_key")?;
28 rawg::fetch_trending_games(&app, &api_key)
29 .await
30 .map_err(AppError::NetworkError)
31}
32
33#[tauri::command]
35pub async fn get_upcoming_games(app: AppHandle) -> Result<Vec<rawg::RawgGame>, AppError> {
36 let api_key = database::get_secret(&app, "rawg_api_key")?;
37 rawg::fetch_upcoming_games(&app, &api_key)
38 .await
39 .map_err(AppError::NetworkError)
40}
41
42#[tauri::command]
44pub async fn get_active_giveaways(app: AppHandle) -> Result<Vec<Giveaway>, AppError> {
45 gamerpower::fetch_giveaways(&app)
46 .await
47 .map_err(AppError::NetworkError)
48}