format code

Signed-off-by: Felix Breuer <fbreuer@pm.me>
This commit is contained in:
Felix Breuer 2022-01-27 17:08:47 +01:00
parent ea877ebde6
commit befad26e33
6 changed files with 70 additions and 67 deletions

1
rustfmt.toml Normal file
View file

@ -0,0 +1 @@
hard_tabs = true

View file

@ -3,7 +3,7 @@ use std::io::{Error, ErrorKind, Read, Seek};
use crate::downloader::{AudioFormat, Quality};
use crate::error::SpotifyError;
use crate::error::SpotifyError::{LameConverterError, InvalidFormat};
use crate::error::SpotifyError::{InvalidFormat, LameConverterError};
/// Converts audio to MP3
pub enum AudioConverter {
@ -35,16 +35,16 @@ impl AudioConverter {
match lame.set_channels(2) {
Ok(_) => {}
Err(_) => return Err(LameConverterError("Channels".to_string()))
Err(_) => return Err(LameConverterError("Channels".to_string())),
};
match lame.set_quality(0) {
Ok(_) => {}
Err(_) => return Err(LameConverterError("Quality".to_string()))
Err(_) => return Err(LameConverterError("Quality".to_string())),
};
match lame.set_kilobitrate(bitrate) {
Ok(_) => {}
Err(_) => return Err(LameConverterError("Bitrate".to_string()))
Err(_) => return Err(LameConverterError("Bitrate".to_string())),
};
match format {
@ -57,11 +57,11 @@ impl AudioConverter {
// Init lame
match lame.set_sample_rate(sample_rate) {
Ok(_) => {}
Err(_) => return Err(LameConverterError("Sample rate".to_string()))
Err(_) => return Err(LameConverterError("Sample rate".to_string())),
};
match lame.init_params() {
Ok(_) => {}
Err(_) => return Err(LameConverterError("Init".to_string()))
Err(_) => return Err(LameConverterError("Init".to_string())),
};
Ok(AudioConverter::Ogg {

View file

@ -472,7 +472,7 @@ impl DownloaderInternal {
Ok(())
}
async fn find_alternative(session: &Session, track : Track) -> Result<Track, SpotifyError> {
async fn find_alternative(session: &Session, track: Track) -> Result<Track, SpotifyError> {
for alt in track.alternatives {
let t = Track::get(&session, alt).await?;
if t.available {

View file

@ -27,7 +27,7 @@ impl Settings {
client_id: client_id.to_string(),
client_secret: client_secret.to_string(),
refresh_ui_seconds: 1,
downloader: DownloaderConfig::new()
downloader: DownloaderConfig::new(),
}
}

View file

@ -1,4 +1,7 @@
use aspotify::{Album, Artist, Client, ClientCredentials, ItemType, Playlist, PlaylistItemType, Track, TrackSimplified};
use aspotify::{
Album, Artist, Client, ClientCredentials, ItemType, Playlist, PlaylistItemType, Track,
TrackSimplified,
};
use librespot::core::authentication::Credentials;
use librespot::core::config::SessionConfig;
use librespot::core::session::Session;

View file

@ -17,7 +17,6 @@ pub enum TagWrap {
}
impl TagWrap {
/// Load from file
pub fn new(path: impl AsRef<Path>, format: AudioFormat) -> Result<TagWrap, SpotifyError> {
match format {