Workstream E (backend): wire tauri-specta — annotate commands, derive Type, generate-ready Builder

- Add #[specta::specta] to all 201 #[tauri::command] functions.
- Derive specta::Type on all IPC DTOs (repository/types, settings, player/storage/
  download command DTOs, player enums, jellyfin SessionInfo/NowPlayingItem/PlayState,
  ThumbnailCacheStats, DownloadInfo, CacheConfig, etc.).
- Replace tauri::generate_handler! with a tauri_specta::Builder + collect_commands!
  in lib.rs (exports bindings.ts in debug builds).

Two contract changes required by specta constraints (frontend migration follows):
- specta caps command arity at 10 args: download_item_and_start / download_item /
  download_video now take a single request struct (params bundled, body unchanged
  via destructuring).
- specta can't parse split serde rename_all: SessionInfo/NowPlayingItem/PlayState
  switched to rename_all = "PascalCase" (Jellyfin deserialization preserved; these
  now serialize PascalCase to the frontend).

cargo check --lib is clean (0 errors). Frontend migration to bindings.ts is the next step.
This commit is contained in:
2026-06-20 18:20:25 +02:00
parent 55f1b85f12
commit ada3ed64ab
40 changed files with 598 additions and 354 deletions
+8
View File
@@ -17,6 +17,7 @@ use crate::storage::db_service::{DatabaseService, Query, QueryParam};
/// Set sleep timer mode
#[tauri::command]
#[specta::specta]
pub async fn player_set_sleep_timer(
player: State<'_, PlayerStateWrapper>,
mode: SleepTimerMode,
@@ -28,6 +29,7 @@ pub async fn player_set_sleep_timer(
/// Cancel sleep timer
#[tauri::command]
#[specta::specta]
pub async fn player_cancel_sleep_timer(
player: State<'_, PlayerStateWrapper>,
) -> Result<SleepTimerState, String> {
@@ -38,6 +40,7 @@ pub async fn player_cancel_sleep_timer(
/// Get current sleep timer state
#[tauri::command]
#[specta::specta]
pub async fn player_get_sleep_timer(
player: State<'_, PlayerStateWrapper>,
) -> Result<SleepTimerState, String> {
@@ -49,6 +52,7 @@ pub async fn player_get_sleep_timer(
/// Get autoplay settings
#[tauri::command]
#[specta::specta]
pub async fn player_get_autoplay_settings(
player: State<'_, PlayerStateWrapper>,
) -> Result<AutoplaySettings, String> {
@@ -58,6 +62,7 @@ pub async fn player_get_autoplay_settings(
/// Set autoplay settings and persist to database
#[tauri::command]
#[specta::specta]
pub async fn player_set_autoplay_settings(
player: State<'_, PlayerStateWrapper>,
db: State<'_, DatabaseWrapper>,
@@ -101,6 +106,7 @@ pub async fn player_set_autoplay_settings(
/// Cancel active autoplay countdown
#[tauri::command]
#[specta::specta]
pub async fn player_cancel_autoplay_countdown(
player: State<'_, PlayerStateWrapper>,
) -> Result<(), String> {
@@ -111,6 +117,7 @@ pub async fn player_cancel_autoplay_countdown(
/// Play next episode (user confirmed from popup)
#[tauri::command]
#[specta::specta]
pub async fn player_play_next_episode(
player: State<'_, PlayerStateWrapper>,
db: State<'_, DatabaseWrapper>,
@@ -131,6 +138,7 @@ pub async fn player_play_next_episode(
/// - Frontend when audio track ends via backend event - no itemId/repositoryHandle needed
/// - Android JNI callback also triggers this logic directly
#[tauri::command]
#[specta::specta]
pub async fn player_on_playback_ended(
player: State<'_, PlayerStateWrapper>,
repository_manager: State<'_, crate::commands::repository::RepositoryManagerWrapper>,