From d60baee4a7f6a9ea72afcd2f09920c9a1e6958be Mon Sep 17 00:00:00 2001 From: zarzet <42882290+zarzet@users.noreply.github.com> Date: Sun, 18 Oct 2026 22:12:37 +0700 Subject: [PATCH] refactor(rust): restrict test-only functions check_from_deezer and the lyrics cache_size accessor are only called by unit tests in their own crate, so compile them only for tests and narrow them to the crate. call_download is only used by the extensions integration tests, which can only reach public items; the download manager goes through call_download_provider. Keep it public but hide it from the docs. RequestLease::wait_cancelled stays public: the extensions crate's unit tests call it across the crate boundary and a later coalescer change is expected to use it. --- rust_backend/crates/extensions/src/runtime.rs | 3 +++ rust_backend/crates/providers/src/lyrics/service.rs | 3 ++- .../crates/providers/src/resolver/availability/cache.rs | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rust_backend/crates/extensions/src/runtime.rs b/rust_backend/crates/extensions/src/runtime.rs index bea8f9e0..bc562089 100644 --- a/rust_backend/crates/extensions/src/runtime.rs +++ b/rust_backend/crates/extensions/src/runtime.rs @@ -570,6 +570,9 @@ impl ExtensionRuntime { /// Native provider-manager entry point. Resolver/callback/retry time shares /// one allowance; established native media reads pause only that allowance. + // Public only for the integration tests in `tests/`; the download manager + // uses `call_download_provider`. + #[doc(hidden)] pub fn call_download( &self, method: &str, diff --git a/rust_backend/crates/providers/src/lyrics/service.rs b/rust_backend/crates/providers/src/lyrics/service.rs index 832cc50c..c7ef6c41 100644 --- a/rust_backend/crates/providers/src/lyrics/service.rs +++ b/rust_backend/crates/providers/src/lyrics/service.rs @@ -162,7 +162,8 @@ impl LyricsService { Ok(()) } - pub fn cache_size(&self) -> usize { + #[cfg(test)] + pub(crate) fn cache_size(&self) -> usize { self.inner.cache.len() } diff --git a/rust_backend/crates/providers/src/resolver/availability/cache.rs b/rust_backend/crates/providers/src/resolver/availability/cache.rs index 0707b2ca..8789f0a5 100644 --- a/rust_backend/crates/providers/src/resolver/availability/cache.rs +++ b/rust_backend/crates/providers/src/resolver/availability/cache.rs @@ -148,7 +148,8 @@ impl AvailabilityService { self.with_raw(check, |resolver, check| album(resolver, id, check)) } - pub fn check_from_deezer( + #[cfg(test)] + pub(crate) fn check_from_deezer( &self, id: &str, check: &Check<'_>,