Format and apply Clippy suggestions
This commit is contained in:
parent
8e7a087e41
commit
138446e040
2 changed files with 8 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::{path::Path, collections::HashMap};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use percent_encoding::percent_decode_str;
|
use percent_encoding::percent_decode_str;
|
||||||
|
@ -176,7 +176,8 @@ struct UpdateQueueBody {
|
||||||
async fn post_queue_move(mut req: tide::Request<()>) -> tide::Result {
|
async fn post_queue_move(mut req: tide::Request<()>) -> tide::Result {
|
||||||
let body: UpdateQueueBody = req.body_json().await?;
|
let body: UpdateQueueBody = req.body_json().await?;
|
||||||
let mut mpd = mpd::Mpd::connect().await?;
|
let mut mpd = mpd::Mpd::connect().await?;
|
||||||
mpd.command(&format!("move {} {}", body.from, body.to)).await?;
|
mpd.command(&format!("move {} {}", body.from, body.to))
|
||||||
|
.await?;
|
||||||
Ok("".into())
|
Ok("".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/mpd.rs
10
src/mpd.rs
|
@ -246,7 +246,7 @@ impl Mpd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::manual_map)]
|
||||||
pub async fn ls(&mut self, path: &str) -> anyhow::Result<Vec<Entry>> {
|
pub async fn ls(&mut self, path: &str) -> anyhow::Result<Vec<Entry>> {
|
||||||
fn get_filename(path: &str) -> String {
|
fn get_filename(path: &str) -> String {
|
||||||
std::path::Path::new(path)
|
std::path::Path::new(path)
|
||||||
|
@ -256,7 +256,7 @@ impl Mpd {
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.command(&format!("lsinfo \"{}\"", Self::escape_str(&path)))
|
.command(&format!("lsinfo \"{}\"", Self::escape_str(path)))
|
||||||
.await?
|
.await?
|
||||||
.into_hashmaps(&["file", "directory", "playlist"]);
|
.into_hashmaps(&["file", "directory", "playlist"]);
|
||||||
|
|
||||||
|
@ -265,18 +265,18 @@ impl Mpd {
|
||||||
.flat_map(|prop| {
|
.flat_map(|prop| {
|
||||||
if let Some(file) = prop.get("file") {
|
if let Some(file) = prop.get("file") {
|
||||||
Some(Entry::Song {
|
Some(Entry::Song {
|
||||||
name: prop.get("Title").unwrap_or(&get_filename(&file)).clone(),
|
name: prop.get("Title").unwrap_or(&get_filename(file)).clone(),
|
||||||
artist: prop.get("Artist").unwrap_or(&String::new()).clone(),
|
artist: prop.get("Artist").unwrap_or(&String::new()).clone(),
|
||||||
path: file.to_string(),
|
path: file.to_string(),
|
||||||
})
|
})
|
||||||
} else if let Some(file) = prop.get("directory") {
|
} else if let Some(file) = prop.get("directory") {
|
||||||
Some(Entry::Directory {
|
Some(Entry::Directory {
|
||||||
name: get_filename(&file),
|
name: get_filename(file),
|
||||||
path: file.to_string(),
|
path: file.to_string(),
|
||||||
})
|
})
|
||||||
} else if let Some(file) = prop.get("playlist") {
|
} else if let Some(file) = prop.get("playlist") {
|
||||||
Some(Entry::Playlist {
|
Some(Entry::Playlist {
|
||||||
name: get_filename(&file),
|
name: get_filename(file),
|
||||||
path: file.to_string(),
|
path: file.to_string(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue