Trait bliss_rs::Library[][src]

pub trait Library {
    fn get_songs_paths(&self) -> Result<Vec<String>, BlissError>;
fn store_song(&mut self, song: &Song) -> Result<(), BlissError>;
fn store_error_song(
        &mut self,
        song_path: String,
        error: BlissError
    ) -> Result<(), BlissError>;
fn get_stored_songs(&self) -> Result<Vec<Song>, BlissError>; fn playlist_from_song(
        &self,
        first_song: Song,
        playlist_length: usize
    ) -> Result<Vec<Song>, BlissError> { ... }
fn analyze_paths(&mut self, paths: Vec<String>) -> Result<(), BlissError> { ... }
fn analyze_library(&mut self) -> Result<(), BlissError> { ... } }
Expand description

Library trait to make creating plug-ins for existing audio players easier.

Required methods

fn get_songs_paths(&self) -> Result<Vec<String>, BlissError>[src]

Expand description

Return the absolute path of all the songs in an audio player’s music library.

fn store_song(&mut self, song: &Song) -> Result<(), BlissError>[src]

Expand description

Store an analyzed Song object in some (cold) storage, e.g. a database, a file…

fn store_error_song(
    &mut self,
    song_path: String,
    error: BlissError
) -> Result<(), BlissError>
[src]

Expand description

Log and / or store that an error happened while trying to decode and analyze a song.

fn get_stored_songs(&self) -> Result<Vec<Song>, BlissError>[src]

Expand description

Retrieve a list of all the stored Songs.

This should work only after having run analyze_library at least once.

Provided methods

fn playlist_from_song(
    &self,
    first_song: Song,
    playlist_length: usize
) -> Result<Vec<Song>, BlissError>
[src]

Expand description

Return a list of songs that are similar to first_song.

Arguments

  • first_song - The song the playlist will be built from.
  • playlist_length - The playlist length. If there are not enough songs in the library, it will be truncated to the size of the library.

Returns

A vector of playlist_length Songs, including first_song, that you most likely want to plug in your audio player by using something like ret.map(|song| song.path.to_owned()).collect::<Vec<String>>().

fn analyze_paths(&mut self, paths: Vec<String>) -> Result<(), BlissError>[src]

Expand description

Analyze and store songs in paths, using store_song and store_error_song implementations.

Note: this is mostly useful for updating a song library. For the first run, you probably want to use analyze_library.

fn analyze_library(&mut self) -> Result<(), BlissError>[src]

Expand description

Analyzes a song library, using get_songs_paths, store_song and store_error_song implementations.

Implementors