chore: cargo clippy --fix
Reformat format strings
This commit is contained in:
@@ -216,7 +216,7 @@ impl Application {
|
||||
if layout.has_screen(&initial_screen) {
|
||||
layout.set_screen(initial_screen);
|
||||
} else {
|
||||
error!("Invalid screen name: {}", initial_screen);
|
||||
error!("Invalid screen name: {initial_screen}");
|
||||
layout.set_screen("library");
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ impl Application {
|
||||
#[cfg(unix)]
|
||||
for signal in signals.pending() {
|
||||
if signal == SIGTERM || signal == SIGHUP {
|
||||
info!("Caught {}, cleaning up and closing", signal);
|
||||
info!("Caught {signal}, cleaning up and closing");
|
||||
if let Some(data) = self.cursive.user_data::<UserData>().cloned() {
|
||||
data.cmd.handle(&mut self.cursive, Command::Quit);
|
||||
}
|
||||
@@ -253,7 +253,7 @@ impl Application {
|
||||
for event in self.event_manager.msg_iter() {
|
||||
match event {
|
||||
Event::Player(state) => {
|
||||
trace!("event received: {:?}", state);
|
||||
trace!("event received: {state:?}");
|
||||
self.spotify.update_status(state.clone());
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
@@ -77,14 +77,11 @@ impl CommandManager {
|
||||
for (key, commands) in custom_bindings.unwrap_or_default() {
|
||||
match parse(&commands) {
|
||||
Ok(cmds) => {
|
||||
info!("Custom keybinding: {} -> {:?}", key, cmds);
|
||||
info!("Custom keybinding: {key} -> {cmds:?}");
|
||||
kb.insert(key, cmds);
|
||||
}
|
||||
Err(err) => {
|
||||
error!(
|
||||
"Invalid command(s) for key {}-\"{}\": {}",
|
||||
key, commands, err
|
||||
);
|
||||
error!("Invalid command(s) for key {key}-\"{commands}\": {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +201,7 @@ impl CommandManager {
|
||||
.spotify
|
||||
.volume()
|
||||
.saturating_sub(VOLUME_PERCENT * amount);
|
||||
debug!("vol {}", volume);
|
||||
debug!("vol {volume}");
|
||||
self.spotify.set_volume(volume, true);
|
||||
Ok(None)
|
||||
}
|
||||
@@ -239,7 +236,7 @@ impl CommandManager {
|
||||
Command::NewPlaylist(name) => {
|
||||
match self.spotify.api.create_playlist(name, None, None) {
|
||||
Ok(_) => self.library.update_library(),
|
||||
Err(_) => error!("could not create playlist {}", name),
|
||||
Err(_) => error!("could not create playlist {name}"),
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
@@ -273,10 +270,10 @@ impl CommandManager {
|
||||
Ok(None)
|
||||
}
|
||||
Command::Execute(cmd) => {
|
||||
log::info!("Executing command: {}", cmd);
|
||||
log::info!("Executing command: {cmd}");
|
||||
let cmd = std::ffi::CString::new(cmd.clone()).unwrap();
|
||||
let result = unsafe { libc::system(cmd.as_ptr()) };
|
||||
log::info!("Exit code: {}", result);
|
||||
log::info!("Exit code: {result}");
|
||||
Ok(None)
|
||||
}
|
||||
Command::Reconnect => {
|
||||
@@ -404,7 +401,7 @@ impl CommandManager {
|
||||
if let Some(binding) = Self::parse_keybinding(k) {
|
||||
self.register_keybinding(cursive, binding, v.clone());
|
||||
} else {
|
||||
error!("Could not parse keybinding: \"{}\"", k);
|
||||
error!("Could not parse keybinding: \"{k}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ impl Config {
|
||||
let path = config_path(USER_STATE_FILE_NAME);
|
||||
debug!("saving user state to {}", path.display());
|
||||
if let Err(e) = CBOR.write(path, &*self.state()) {
|
||||
error!("Could not save user state: {}", e);
|
||||
error!("Could not save user state: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ impl IpcSocket {
|
||||
loop {
|
||||
match listener.accept().await {
|
||||
Ok((stream, sockaddr)) => {
|
||||
debug!("Connection from {:?}", sockaddr);
|
||||
debug!("Connection from {sockaddr:?}");
|
||||
tokio::spawn(Self::stream_handler(
|
||||
stream,
|
||||
ev.clone(),
|
||||
|
||||
@@ -79,8 +79,7 @@ impl Library {
|
||||
let saved_cache_version = self.cfg.state().cache_version;
|
||||
if saved_cache_version < CACHE_VERSION {
|
||||
debug!(
|
||||
"Cache version for {:?} has changed from {} to {}, ignoring cache",
|
||||
cache_path, saved_cache_version, CACHE_VERSION
|
||||
"Cache version for {cache_path:?} has changed from {saved_cache_version} to {CACHE_VERSION}, ignoring cache"
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -103,7 +102,7 @@ impl Library {
|
||||
self.trigger_redraw();
|
||||
}
|
||||
Err(e) => {
|
||||
error!("can't parse cache: {}", e);
|
||||
error!("can't parse cache: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,7 +368,7 @@ impl Library {
|
||||
|
||||
loop {
|
||||
let page = self.spotify.api.current_user_followed_artists(last);
|
||||
debug!("artists page: {}", i);
|
||||
debug!("artists page: {i}");
|
||||
i += 1;
|
||||
if page.is_err() {
|
||||
error!("Failed to fetch artists.");
|
||||
@@ -426,7 +425,7 @@ impl Library {
|
||||
.spotify
|
||||
.api
|
||||
.current_user_saved_albums(albums.len() as u32);
|
||||
debug!("albums page: {}", i);
|
||||
debug!("albums page: {i}");
|
||||
|
||||
i += 1;
|
||||
|
||||
@@ -470,7 +469,7 @@ impl Library {
|
||||
.api
|
||||
.current_user_saved_tracks(tracks.len() as u32);
|
||||
|
||||
debug!("tracks page: {}", i);
|
||||
debug!("tracks page: {i}");
|
||||
i += 1;
|
||||
|
||||
if page.is_err() {
|
||||
|
||||
@@ -57,7 +57,7 @@ impl Playlist {
|
||||
|
||||
pub fn delete_track(&mut self, index: usize, spotify: Spotify, library: &Library) -> bool {
|
||||
let playable = self.tracks.as_ref().unwrap()[index].clone();
|
||||
debug!("deleting track: {} {:?}", index, playable);
|
||||
debug!("deleting track: {index} {playable:?}");
|
||||
|
||||
if playable.track().map(|t| t.is_local) == Some(true) {
|
||||
warn!("track is a local file, can't delete");
|
||||
|
||||
@@ -464,7 +464,7 @@ impl Queue {
|
||||
QueueEvent::PreloadTrackRequest => {
|
||||
if let Some(next_index) = self.next_index() {
|
||||
let track = self.queue.read().unwrap()[next_index].clone();
|
||||
debug!("Preloading track {} as requested by librespot", track);
|
||||
debug!("Preloading track {track} as requested by librespot");
|
||||
self.spotify.preload(&track);
|
||||
}
|
||||
}
|
||||
@@ -494,7 +494,7 @@ pub fn send_notification(summary_txt: &str, body_txt: &str, cover_url: Option<St
|
||||
let path = crate::utils::cache_path_for_url(u.to_string());
|
||||
if !path.exists() {
|
||||
if let Err(e) = crate::utils::download(u, path.clone()) {
|
||||
log::error!("Failed to download cover: {}", e);
|
||||
log::error!("Failed to download cover: {e}");
|
||||
}
|
||||
}
|
||||
n.icon(path.to_str().unwrap());
|
||||
@@ -512,6 +512,6 @@ pub fn send_notification(summary_txt: &str, body_txt: &str, cover_url: Option<St
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
info!("Created notification: {}", handle.id());
|
||||
}
|
||||
Err(e) => log::error!("Failed to send notification cover: {}", e),
|
||||
Err(e) => log::error!("Failed to send notification cover: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ impl Spotify {
|
||||
};
|
||||
match env::var("http_proxy") {
|
||||
Ok(proxy) => {
|
||||
info!("Setting HTTP proxy {}", proxy);
|
||||
info!("Setting HTTP proxy {proxy}");
|
||||
session_config.proxy = Url::parse(&proxy).ok();
|
||||
}
|
||||
Err(_) => debug!("No HTTP proxy set"),
|
||||
@@ -204,7 +204,7 @@ impl Spotify {
|
||||
|
||||
let backend_name = backend.0;
|
||||
|
||||
info!("Initializing audio backend {}", backend_name);
|
||||
info!("Initializing audio backend {backend_name}");
|
||||
if backend_name == "pulseaudio" {
|
||||
// TODO: Audit that the environment access only happens in single-threaded code.
|
||||
unsafe { env::set_var("PULSE_PROP_application.name", "ncspot") };
|
||||
@@ -316,10 +316,10 @@ impl Spotify {
|
||||
/// Load `track` into the [Player]. Start playing immediately if
|
||||
/// `start_playing` is true. Start playing from `position_ms` in the song.
|
||||
pub fn load(&self, track: &Playable, start_playing: bool, position_ms: u32) {
|
||||
info!("loading track: {:?}", track);
|
||||
info!("loading track: {track:?}");
|
||||
|
||||
if !track.is_playable() {
|
||||
warn!("track {:?} can not be played, skipping..", track);
|
||||
warn!("track {track:?} can not be played, skipping..");
|
||||
self.events.send(Event::Player(PlayerEvent::FinishedTrack));
|
||||
return;
|
||||
}
|
||||
@@ -385,7 +385,7 @@ impl Spotify {
|
||||
/// Send an [MprisCommand] to the mpris thread.
|
||||
#[cfg(feature = "mpris")]
|
||||
fn send_mpris(&self, cmd: MprisCommand) {
|
||||
debug!("Sending mpris command: {:?}", cmd);
|
||||
debug!("Sending mpris command: {cmd:?}");
|
||||
match self.mpris.lock().unwrap().as_ref() {
|
||||
Some(mpris_manager) => {
|
||||
mpris_manager.send(cmd);
|
||||
@@ -398,15 +398,12 @@ impl Spotify {
|
||||
|
||||
/// Send a [WorkerCommand] to the worker thread.
|
||||
fn send_worker(&self, cmd: WorkerCommand) {
|
||||
info!("sending command to worker: {:?}", cmd);
|
||||
info!("sending command to worker: {cmd:?}");
|
||||
let channel = self.channel.read().unwrap();
|
||||
match channel.as_ref() {
|
||||
Some(channel) => {
|
||||
if let Err(e) = channel.send(cmd) {
|
||||
error!(
|
||||
"can't send command to spotify worker: {}, dropping command",
|
||||
e
|
||||
);
|
||||
error!("can't send command to spotify worker: {e}, dropping command");
|
||||
}
|
||||
}
|
||||
None => error!("no channel to worker available"),
|
||||
@@ -460,7 +457,7 @@ impl Spotify {
|
||||
/// Set the current volume of the [Player]. If `notify` is true, also notify MPRIS clients about
|
||||
/// the update.
|
||||
pub fn set_volume(&self, volume: u16, notify: bool) {
|
||||
info!("setting volume to {}", volume);
|
||||
info!("setting volume to {volume}");
|
||||
self.cfg.with_state_mut(|s| s.volume = volume);
|
||||
self.send_worker(WorkerCommand::SetVolume(volume));
|
||||
// HACK: This is a bit of a hack to prevent duplicate update signals when updating from the
|
||||
|
||||
@@ -92,7 +92,7 @@ impl WebApi {
|
||||
return None;
|
||||
}
|
||||
|
||||
info!("Token will expire in {}, renewing", delta);
|
||||
info!("Token will expire in {delta}, renewing");
|
||||
}
|
||||
|
||||
let (token_tx, token_rx) = std::sync::mpsc::channel();
|
||||
@@ -136,14 +136,14 @@ impl WebApi {
|
||||
match result {
|
||||
Ok(v) => Some(v),
|
||||
Err(ClientError::Http(error)) => {
|
||||
debug!("http error: {:?}", error);
|
||||
debug!("http error: {error:?}");
|
||||
match error.as_ref() {
|
||||
HttpError::StatusCode(response) => match response.status() {
|
||||
429 => {
|
||||
let waiting_duration = response
|
||||
.header("Retry-After")
|
||||
.and_then(|v| v.parse::<u64>().ok());
|
||||
debug!("rate limit hit. waiting {:?} seconds", waiting_duration);
|
||||
debug!("rate limit hit. waiting {waiting_duration:?} seconds");
|
||||
thread::sleep(Duration::from_secs(waiting_duration.unwrap_or(0)));
|
||||
api_call(&self.api).ok()
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl WebApi {
|
||||
.and_then(move |_| api_call(&self.api).ok())
|
||||
}
|
||||
_ => {
|
||||
error!("unhandled api error: {:?}", response);
|
||||
error!("unhandled api error: {response:?}");
|
||||
None
|
||||
}
|
||||
},
|
||||
@@ -161,7 +161,7 @@ impl WebApi {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("unhandled api error: {}", e);
|
||||
error!("unhandled api error: {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -258,12 +258,12 @@ impl WebApi {
|
||||
if self.append_tracks(id, tracks, None).is_ok() {
|
||||
debug!("{} tracks successfully added", tracks.len());
|
||||
} else {
|
||||
error!("error saving tracks to playlists {}", id);
|
||||
error!("error saving tracks to playlists {id}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error!("error saving tracks to playlist {}", id);
|
||||
error!("error saving tracks to playlist {id}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ impl WebApi {
|
||||
|
||||
/// Fetch the album with the given `album_id`.
|
||||
pub fn album(&self, album_id: &str) -> Result<FullAlbum, ()> {
|
||||
debug!("fetching album {}", album_id);
|
||||
debug!("fetching album {album_id}");
|
||||
let aid = AlbumId::from_id(album_id).map_err(|_| ())?;
|
||||
self.api_with_retry(|api| api.album(aid.clone(), Some(Market::FromToken)))
|
||||
.ok_or(())
|
||||
@@ -395,7 +395,7 @@ impl WebApi {
|
||||
const MAX_LIMIT: u32 = 50;
|
||||
let spotify = self.clone();
|
||||
let fetch_page = move |offset: u32| {
|
||||
debug!("fetching user playlists, offset: {}", offset);
|
||||
debug!("fetching user playlists, offset: {offset}");
|
||||
spotify.api_with_retry(|api| {
|
||||
match api.current_user_playlists_manual(Some(MAX_LIMIT), Some(offset)) {
|
||||
Ok(page) => Ok(ApiPage {
|
||||
@@ -416,10 +416,7 @@ impl WebApi {
|
||||
let spotify = self.clone();
|
||||
let playlist_id = playlist_id.to_string();
|
||||
let fetch_page = move |offset: u32| {
|
||||
debug!(
|
||||
"fetching playlist {} tracks, offset: {}",
|
||||
playlist_id, offset
|
||||
);
|
||||
debug!("fetching playlist {playlist_id} tracks, offset: {offset}");
|
||||
spotify.api_with_retry(|api| {
|
||||
match api.playlist_items_manual(
|
||||
PlaylistId::from_id(&playlist_id).unwrap(),
|
||||
@@ -461,7 +458,7 @@ impl WebApi {
|
||||
limit: u32,
|
||||
offset: u32,
|
||||
) -> Result<Page<SimplifiedTrack>, ()> {
|
||||
debug!("fetching album tracks {}", album_id);
|
||||
debug!("fetching album tracks {album_id}");
|
||||
self.api_with_retry(|api| {
|
||||
api.album_track_manual(
|
||||
AlbumId::from_id(album_id).unwrap(),
|
||||
@@ -484,7 +481,7 @@ impl WebApi {
|
||||
let spotify = self.clone();
|
||||
let artist_id = artist_id.to_string();
|
||||
let fetch_page = move |offset: u32| {
|
||||
debug!("fetching artist {} albums, offset: {}", artist_id, offset);
|
||||
debug!("fetching artist {artist_id} albums, offset: {offset}");
|
||||
spotify.api_with_retry(|api| {
|
||||
match api.artist_albums_manual(
|
||||
ArtistId::from_id(&artist_id).unwrap(),
|
||||
@@ -695,7 +692,7 @@ impl WebApi {
|
||||
const MAX_LIMIT: u32 = 50;
|
||||
let spotify = self.clone();
|
||||
let fetch_page = move |offset: u32| {
|
||||
debug!("fetching categories, offset: {}", offset);
|
||||
debug!("fetching categories, offset: {offset}");
|
||||
spotify.api_with_retry(|api| {
|
||||
match api.categories_manual(
|
||||
None,
|
||||
@@ -721,7 +718,7 @@ impl WebApi {
|
||||
let spotify = self.clone();
|
||||
let category_id = category_id.to_string();
|
||||
let fetch_page = move |offset: u32| {
|
||||
debug!("fetching category playlists, offset: {}", offset);
|
||||
debug!("fetching category playlists, offset: {offset}");
|
||||
spotify.api_with_retry(|api| {
|
||||
match api.category_playlists_manual(
|
||||
&category_id,
|
||||
|
||||
@@ -94,7 +94,7 @@ impl Worker {
|
||||
Some(WorkerCommand::Load(playable, start_playing, position_ms)) => {
|
||||
match SpotifyId::from_uri(&playable.uri()) {
|
||||
Ok(id) => {
|
||||
info!("player loading track: {:?}", id);
|
||||
info!("player loading track: {id:?}");
|
||||
if !id.is_playable() {
|
||||
warn!("track is not playable");
|
||||
self.events.send(Event::Player(PlayerEvent::FinishedTrack));
|
||||
@@ -103,7 +103,7 @@ impl Worker {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("error parsing uri: {:?}", e);
|
||||
error!("error parsing uri: {e:?}");
|
||||
self.events.send(Event::Player(PlayerEvent::FinishedTrack));
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ impl Worker {
|
||||
}
|
||||
Some(WorkerCommand::Preload(playable)) => {
|
||||
if let Ok(id) = SpotifyId::from_uri(&playable.uri()) {
|
||||
debug!("Preloading {:?}", id);
|
||||
debug!("Preloading {id:?}");
|
||||
self.player.preload(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ impl ContextMenu {
|
||||
|
||||
impl ViewExt for AddToPlaylistMenu {
|
||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||
log::info!("playlist command: {:?}", cmd);
|
||||
log::info!("playlist command: {cmd:?}");
|
||||
handle_move_command::<Playlist>(&mut self.dialog, s, cmd, "addplaylist_select")
|
||||
}
|
||||
}
|
||||
@@ -364,7 +364,7 @@ impl ViewExt for ContextMenu {
|
||||
|
||||
impl ViewExt for SelectArtistMenu {
|
||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||
log::info!("artist move command: {:?}", cmd);
|
||||
log::info!("artist move command: {cmd:?}");
|
||||
handle_move_command::<Artist>(&mut self.dialog, s, cmd, "artist_select")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,7 @@ impl CoverView {
|
||||
query
|
||||
};
|
||||
|
||||
debug!(
|
||||
"Determined window dimensions: {}x{}, {}x{}",
|
||||
xpixels, ypixels, cols, rows
|
||||
);
|
||||
debug!("Determined window dimensions: {xpixels}x{ypixels}, {cols}x{rows}");
|
||||
|
||||
// Determine font size, considering max scale to prevent tiny covers on HiDPI screens
|
||||
let scale = config.values().cover_max_scale.unwrap_or(1.0);
|
||||
@@ -127,7 +124,7 @@ impl CoverView {
|
||||
);
|
||||
|
||||
if let Err(e) = self.run_ueberzug_cmd(&cmd) {
|
||||
error!("Failed to run Ueberzug: {}", e);
|
||||
error!("Failed to run Ueberzug: {e}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +141,7 @@ impl CoverView {
|
||||
|
||||
let cmd = "{\"action\": \"remove\", \"identifier\": \"cover\"}\n";
|
||||
if let Err(e) = self.run_ueberzug_cmd(cmd) {
|
||||
error!("Failed to run Ueberzug: {}", e);
|
||||
error!("Failed to run Ueberzug: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +181,7 @@ impl CoverView {
|
||||
let loading_thread = self.loading.clone();
|
||||
std::thread::spawn(move || {
|
||||
if let Err(e) = crate::utils::download(url.clone(), path.clone()) {
|
||||
error!("Failed to download cover: {}", e);
|
||||
error!("Failed to download cover: {e}");
|
||||
}
|
||||
let mut loading = loading_thread.write().unwrap();
|
||||
loading.remove(&url.clone());
|
||||
|
||||
@@ -67,7 +67,7 @@ impl<I: ListItem + Clone> ApiResult<I> {
|
||||
|
||||
pub fn next(&self) -> Option<Vec<I>> {
|
||||
let offset = self.offset() + self.limit;
|
||||
debug!("fetching next page at offset {}", offset);
|
||||
debug!("fetching next page at offset {offset}");
|
||||
if !self.at_end() {
|
||||
if let Some(next_page) = (self.fetch_page)(offset) {
|
||||
*self.offset.write().unwrap() = next_page.offset;
|
||||
|
||||
@@ -34,7 +34,7 @@ type DynError = Box<dyn std::error::Error>;
|
||||
|
||||
fn main() {
|
||||
if let Err(e) = try_main() {
|
||||
eprintln!("{}", e);
|
||||
eprintln!("{e}");
|
||||
std::process::exit(-1);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ fn generate_shell_completion(subcommand_arguments: &ArgMatches) -> Result<(), Dy
|
||||
"elvish" => Shell::Elvish,
|
||||
"powershell" => Shell::PowerShell,
|
||||
_ => {
|
||||
eprintln!("Unrecognized shell: {}", shell);
|
||||
eprintln!("Unrecognized shell: {shell}");
|
||||
std::process::exit(-1);
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user