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:
@@ -16,7 +16,7 @@ use crate::repository::types::{ImageOptions, ImageType};
|
||||
use crate::repository::MediaRepository;
|
||||
|
||||
/// Request to add items to queue
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(specta::Type, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddToQueueRequest {
|
||||
pub items: Vec<PlayItemRequest>,
|
||||
@@ -24,7 +24,7 @@ pub struct AddToQueueRequest {
|
||||
}
|
||||
|
||||
/// Request to add a track by ID - backend fetches metadata
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(specta::Type, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddTrackByIdRequest {
|
||||
pub track_id: String,
|
||||
@@ -32,7 +32,7 @@ pub struct AddTrackByIdRequest {
|
||||
}
|
||||
|
||||
/// Request to add multiple tracks by IDs - backend fetches metadata
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(specta::Type, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddTracksByIdsRequest {
|
||||
pub track_ids: Vec<String>,
|
||||
@@ -40,6 +40,7 @@ pub struct AddTracksByIdsRequest {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn player_add_to_queue(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
@@ -81,6 +82,7 @@ pub async fn player_add_to_queue(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn player_remove_from_queue(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
index: usize,
|
||||
@@ -107,6 +109,7 @@ pub async fn player_remove_from_queue(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn player_move_in_queue(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
from_index: usize,
|
||||
@@ -137,6 +140,7 @@ pub async fn player_move_in_queue(
|
||||
|
||||
/// Add a track to queue by ID - backend fetches metadata and constructs URLs
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn player_add_track_by_id(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
@@ -236,6 +240,7 @@ pub async fn player_add_track_by_id(
|
||||
|
||||
/// Add multiple tracks to queue by IDs - backend fetches metadata and constructs URLs
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn player_add_tracks_by_ids(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
@@ -339,6 +344,7 @@ pub async fn player_add_tracks_by_ids(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn player_skip_to(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
index: usize,
|
||||
|
||||
Reference in New Issue
Block a user