pub struct LoudnessDatabase { /* private fields */ }Expand description
SQLite database for track loudness metadata
Implementations§
Source§impl LoudnessDatabase
impl LoudnessDatabase
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self, String>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, String>
Open or create the loudness database
Sourcepub fn upsert(&self, track: &TrackLoudness) -> Result<(), String>
pub fn upsert(&self, track: &TrackLoudness) -> Result<(), String>
Insert or update a track’s loudness data
Sourcepub fn get(&self, file_path: &str) -> Result<Option<TrackLoudness>, String>
pub fn get(&self, file_path: &str) -> Result<Option<TrackLoudness>, String>
Get loudness data for a track by file path
Sourcepub fn get_fresh(
&self,
file_path: &str,
) -> Result<Option<TrackLoudness>, String>
pub fn get_fresh( &self, file_path: &str, ) -> Result<Option<TrackLoudness>, String>
Get loudness data only when the cached record is still fresh.
This centralizes the cache-hit contract used by both HTTP analysis handlers and playback loading: scan version, file mtime, and file size must all still match before a record may skip EBU R128 analysis.
Sourcepub fn needs_scan(&self, file_path: &str) -> Result<bool, String>
pub fn needs_scan(&self, file_path: &str) -> Result<bool, String>
Check if a track needs scanning (not in DB, outdated version, or file changed)
FIX for Defect 40: Also check file mtime and size for change detection. This handles the case where a file is replaced but keeps the same path.
Sourcepub fn get_outdated_tracks(&self) -> Result<Vec<String>, String>
pub fn get_outdated_tracks(&self) -> Result<Vec<String>, String>
Get all tracks that need rescanning
Sourcepub fn batch_upsert(&self, tracks: &[TrackLoudness]) -> Result<usize, String>
pub fn batch_upsert(&self, tracks: &[TrackLoudness]) -> Result<usize, String>
Batch insert multiple tracks (for initial scan)
Sourcepub fn set_album_gain(
&self,
track_ids: &[&str],
album_gain_db: f64,
) -> Result<(), String>
pub fn set_album_gain( &self, track_ids: &[&str], album_gain_db: f64, ) -> Result<(), String>
Update album gain for multiple tracks (same album)
FIX for Defect 41: Wrap in transaction for atomicity. If any update fails or process crashes, all changes are rolled back.
Sourcepub fn stats(&self) -> Result<DatabaseStats, String>
pub fn stats(&self) -> Result<DatabaseStats, String>
Get database statistics
Auto Trait Implementations§
impl !Freeze for LoudnessDatabase
impl RefUnwindSafe for LoudnessDatabase
impl Send for LoudnessDatabase
impl Sync for LoudnessDatabase
impl Unpin for LoudnessDatabase
impl UnsafeUnpin for LoudnessDatabase
impl UnwindSafe for LoudnessDatabase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more