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
+17 -17
View File
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
/// Error types for repository operations
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum RepoError {
Network { message: String },
@@ -28,7 +28,7 @@ impl std::fmt::Display for RepoError {
impl std::error::Error for RepoError {}
/// Library (media collection)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Library {
pub id: String,
@@ -39,7 +39,7 @@ pub struct Library {
}
/// User-specific data for an item (playback state, favorites, etc.)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserData {
#[serde(skip_serializing_if = "Option::is_none")]
@@ -59,7 +59,7 @@ pub struct UserData {
}
/// Artist item with ID and name (for clickable artist links)
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "PascalCase")]
pub struct ArtistItem {
pub id: String,
@@ -67,7 +67,7 @@ pub struct ArtistItem {
}
/// Person (cast/crew member) - for movies, series, and episodes
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Person {
/// Deserializes from API's "Id" field (PascalCase), serializes as "id" (camelCase to frontend)
@@ -95,7 +95,7 @@ pub struct Person {
}
/// Media item
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MediaItem {
pub id: String,
@@ -158,7 +158,7 @@ pub struct MediaItem {
}
/// Media stream information (audio, video, subtitle tracks)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MediaStream {
#[serde(rename = "type")]
@@ -175,7 +175,7 @@ pub struct MediaStream {
}
/// Media source information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MediaSource {
pub id: String,
@@ -194,7 +194,7 @@ pub struct MediaSource {
}
/// Search result with pagination
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchResult {
pub items: Vec<MediaItem>,
@@ -202,7 +202,7 @@ pub struct SearchResult {
}
/// Options for querying items
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetItemsOptions {
#[serde(skip_serializing_if = "Option::is_none")]
@@ -224,7 +224,7 @@ pub struct GetItemsOptions {
}
/// Options for search queries
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SearchOptions {
#[serde(skip_serializing_if = "Option::is_none")]
@@ -236,7 +236,7 @@ pub struct SearchOptions {
}
/// Playback information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaybackInfo {
pub media_source_id: String,
@@ -247,7 +247,7 @@ pub struct PlaybackInfo {
}
/// Genre
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Genre {
pub id: String,
@@ -255,7 +255,7 @@ pub struct Genre {
}
/// Image type
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
pub enum ImageType {
Primary,
Backdrop,
@@ -277,7 +277,7 @@ impl ImageType {
}
/// Image options
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ImageOptions {
#[serde(skip_serializing_if = "Option::is_none")]
@@ -335,7 +335,7 @@ impl MeaningfulContent for PlaybackInfo {
/// needed for remove/reorder operations (distinct from the media item's ID)
///
/// @req: UR-014 - Make and edit playlists of music that sync back to Jellyfin
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaylistEntry {
/// The playlist-scoped entry ID (Jellyfin's PlaylistItemId)
@@ -348,7 +348,7 @@ pub struct PlaylistEntry {
/// Result of creating a playlist
///
/// @req: JA-019 - Get/create/update playlists
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaylistCreatedResult {
pub id: String,