qconnect: make PlaybackSource the shared cast predicate (is_castable_to_qconnect)
is_qobuz_streamable was dead code. Add is_castable_to_qconnect as the single source of truth and depend qconnect-core on qbz-models so the admission gate and the cast predicate derive from one enum. cc
This commit is contained in:
4 files changed
+31
No files matched your search
Generated
+1
@@ -5323,6 +5323,7 @@ dependencies = [
|
||||
name = "qconnect-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"qbz-models",
|
||||
"serde",
|
||||
"thiserror 2.0.18",
|
||||
]
|
||||
|
||||
@@ -61,6 +61,13 @@ impl PlaybackSource {
|
||||
pub fn is_qobuz_streamable(self) -> bool {
|
||||
matches!(self, Self::Qobuz)
|
||||
}
|
||||
|
||||
/// The admission-side cast predicate. Offline-cache maps to castable (the
|
||||
/// offline copy carries a valid Qobuz track id). This is the method the
|
||||
/// QConnect gate consults; is_qobuz_streamable stays "streams live from Qobuz".
|
||||
pub fn is_castable_to_qconnect(self) -> bool {
|
||||
matches!(self, Self::Qobuz | Self::OfflineCache)
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to a piece of cover art, resolvable regardless of origin.
|
||||
|
||||
@@ -8,3 +8,4 @@ description = "UI-agnostic domain core for Qobuz Connect queue and concurrency"
|
||||
[dependencies]
|
||||
serde = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
qbz-models = { path = "../qbz-models" }
|
||||
@@ -61,3 +61,25 @@ pub fn resolve_handoff_intent(origin: TrackOrigin) -> HandoffIntent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use qbz_models::PlaybackSource;
|
||||
|
||||
#[test]
|
||||
fn admission_matches_playback_source_predicate() {
|
||||
let pairs = [
|
||||
(TrackOrigin::QobuzOnline, PlaybackSource::Qobuz),
|
||||
(TrackOrigin::LocalLibrary, PlaybackSource::Local),
|
||||
(TrackOrigin::Plex, PlaybackSource::Plex),
|
||||
];
|
||||
for (origin, source) in pairs {
|
||||
assert_eq!(
|
||||
evaluate_remote_queue_admission(origin).accepted,
|
||||
source.is_qobuz_streamable(),
|
||||
"admission/predicate disagree for {origin:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user