Proper binary-library boundary #8

Merged
maleszka merged 7 commits from feature/refactor into main 2026-07-02 19:16:00 +02:00
Owner
  • Fixed binary/library boundary: removed five duplicate mod declarations from src/main.rs that caused the binary to recompile library source files into its own namespace. Replaced with pub(crate) use librespot_dl::{collection, download, error, provider} so the binary consumes the compiled library artifact.
  • Added UserInput enum and MusicSourceProvider::classify_input: provider-specific URI parsing no longer lives in the binary. Both interactive.rs and script.rs now dispatch via provider.classify_input(line) and match on TrackUri / PlaylistUri / SearchQuery. Eliminated duplicated to_spotify_uri / to_track_uri / is_playlist functions and the provider-specific if/else chain in each CLI module.
  • Added QueueEntry::for_track: constructor in src/download/queue.rs consolidates output-path computation and filesystem stat into one place. Eliminates duplicated make_entry in interactive.rs and manual QueueEntry construction in script.rs.
  • Added DownloadQueue session lifecycle helpers: all_terminal(), prepare_for_restore(valid_partial_ids), and skip_existing() are now library methods with unit tests.
  • Added DownloadSession<P> in src/download/session.rs: owns the queue, provider Arc, channels, concurrency limit, and byte counters. spawn_pending, handle_msg, cancel_all, and reset_cancel are methods on the session rather than free functions in the binary. The interactive event loop is reduced to a thin dispatcher that creates a session and selects on terminal events and worker messages.
  • Eliminated OGG_320_BYTES_PER_SEC duplication: declared once as pub const in src/download/worker.rs; both CLI modules import it.
- Fixed binary/library boundary: removed five duplicate mod declarations from src/main.rs that caused the binary to recompile library source files into its own namespace. Replaced with pub(crate) use librespot_dl::{collection, download, error, provider} so the binary consumes the compiled library artifact. - Added UserInput enum and MusicSourceProvider::classify_input: provider-specific URI parsing no longer lives in the binary. Both interactive.rs and script.rs now dispatch via provider.classify_input(line) and match on TrackUri / PlaylistUri / SearchQuery. Eliminated duplicated to_spotify_uri / to_track_uri / is_playlist functions and the provider-specific if/else chain in each CLI module. - Added QueueEntry::for_track: constructor in src/download/queue.rs consolidates output-path computation and filesystem stat into one place. Eliminates duplicated make_entry in interactive.rs and manual QueueEntry construction in script.rs. - Added DownloadQueue session lifecycle helpers: all_terminal(), prepare_for_restore(valid_partial_ids), and skip_existing() are now library methods with unit tests. - Added DownloadSession\<P\> in src/download/session.rs: owns the queue, provider Arc, channels, concurrency limit, and byte counters. spawn_pending, handle_msg, cancel_all, and reset_cancel are methods on the session rather than free functions in the binary. The interactive event loop is reduced to a thin dispatcher that creates a session and selects on terminal events and worker messages. - Eliminated OGG_320_BYTES_PER_SEC duplication: declared once as pub const in src/download/worker.rs; both CLI modules import it.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
maleszka/librespot-dl!8
No description provided.