Phase 2: Extract Services (Medium Risk)
Objective: Move service structs and related functionality to dedicated modules
Task Checklist (Phase 2)
-
Create services module structure
-
Create
speakr-tauri/src/services/
directory -
Create
services/mod.rs
with module declarations -
Create
services/types.rs
for shared enums -
Create
services/hotkey.rs
for GlobalHotkeyService -
Create
services/status.rs
for BackendStatusService
-
Create
-
Extract ServiceComponent enum
-
Move
ServiceComponent
enum →services/types.rs
- Add appropriate derives and documentation
-
Re-export from
services/mod.rs
-
Move
-
Extract GlobalHotkeyService
-
Move entire
GlobalHotkeyService
struct →services/hotkey.rs
- Move all impl blocks and methods
- Add necessary imports (tauri, tracing, etc.)
-
Extract
register_global_hotkey()
implementation →services/hotkey.rs
asregister_global_hotkey_internal()
-
Extract
unregister_global_hotkey()
implementation →services/hotkey.rs
asunregister_global_hotkey_internal()
-
Keep
#[tauri::command]
wrappers inlib.rs
that call_internal
functions -
Make service and methods
pub(crate)
for module visibility
-
Move entire
-
Extract BackendStatusService
-
Move
BackendStatusService
struct →services/status.rs
- Move all impl blocks and methods
-
Move
GLOBAL_BACKEND_SERVICE
static →services/status.rs
-
Move
get_global_backend_service()
helper →services/status.rs
-
Move
update_global_service_status()
helper →services/status.rs
-
Extract
get_backend_status()
implementation →services/status.rs
asget_backend_status_internal()
-
Extract
update_service_status()
implementation →services/status.rs
asupdate_service_status_internal()
-
Keep
#[tauri::command]
wrappers inlib.rs
that call_internal
functions - Add necessary imports for Tauri AppHandle, etc.
-
Make all functions
pub(crate)
for module visibility -
Add
Default
implementation
-
Move
-
Update lib.rs imports and exports
-
Add
mod services;
tolib.rs
-
Add
use services::*;
or specific imports -
Remove original service implementations from
lib.rs
-
Update command registration in
run()
function
-
Add
-
Test service extraction
-
Run
cargo check
to verify compilation -
Run
cargo test --workspace
to ensure tests pass - Test hotkey registration functionality manually
- Test status service functionality
-
Run