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:
@@ -12,7 +12,7 @@ use super::storage::DatabaseWrapper;
|
||||
use crate::storage::db_service::{DatabaseService, Query, QueryParam};
|
||||
|
||||
/// Sync queue item returned to frontend
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(specta::Type, Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SyncQueueItem {
|
||||
pub id: i64,
|
||||
@@ -28,6 +28,7 @@ pub struct SyncQueueItem {
|
||||
|
||||
/// Queue a mutation for sync to server
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_queue_mutation(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
user_id: String,
|
||||
@@ -59,6 +60,7 @@ pub async fn sync_queue_mutation(
|
||||
|
||||
/// Get all pending sync operations for a user
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_get_pending(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
user_id: String,
|
||||
@@ -107,6 +109,7 @@ pub async fn sync_get_pending(
|
||||
|
||||
/// Mark a sync operation as in progress
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_mark_processing(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
id: i64,
|
||||
@@ -127,6 +130,7 @@ pub async fn sync_mark_processing(
|
||||
|
||||
/// Mark a sync operation as completed
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_mark_completed(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
id: i64,
|
||||
@@ -147,6 +151,7 @@ pub async fn sync_mark_completed(
|
||||
|
||||
/// Mark a sync operation as failed with error message
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_mark_failed(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
id: i64,
|
||||
@@ -173,6 +178,7 @@ pub async fn sync_mark_failed(
|
||||
|
||||
/// Get count of pending sync operations for a user
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_get_pending_count(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
user_id: String,
|
||||
@@ -195,6 +201,7 @@ pub async fn sync_get_pending_count(
|
||||
|
||||
/// Delete completed sync operations older than specified days
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_cleanup_completed(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
days_old: i32,
|
||||
@@ -217,6 +224,7 @@ pub async fn sync_cleanup_completed(
|
||||
|
||||
/// Delete all sync operations for a user (used during logout)
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sync_clear_user(
|
||||
db: State<'_, DatabaseWrapper>,
|
||||
user_id: String,
|
||||
|
||||
Reference in New Issue
Block a user