Clippy changes
Some checks failed
Rust Build / Check (pull_request) Failing after 25s
Rust Build / Test Suite (pull_request) Failing after 26s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Failing after 28s
Rust Build / build (pull_request) Failing after 25s

This commit is contained in:
2025-03-21 21:48:07 -04:00
parent ce13ca6a77
commit 5a4e27af39
4 changed files with 19 additions and 25 deletions

View File

@@ -20,23 +20,23 @@ impl Default for AccessLevel {
} }
pub fn default_level() -> AccessLevel { pub fn default_level() -> AccessLevel {
return AccessLevel { AccessLevel {
id: -1, id: -1,
level: String::from("Public"), level: String::from("Public"),
song_id: -1, song_id: -1,
}; }
} }
pub fn private_level() -> AccessLevel { pub fn private_level() -> AccessLevel {
return AccessLevel { AccessLevel {
id: -1, id: -1,
level: String::from("Private"), level: String::from("Private"),
song_id: -1, song_id: -1,
}; }
} }
impl AccessLevel { impl AccessLevel {
pub fn _to_json(&self) -> Result<String, serde_json::Error> { pub fn _to_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self); serde_json::to_string_pretty(&self)
} }
} }

View File

@@ -16,12 +16,8 @@ impl CoverArt {
let mut file = std::fs::File::open(path)?; let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new(); let mut buffer = Vec::new();
match file.read_to_end(&mut buffer) { match file.read_to_end(&mut buffer) {
Ok(_) => { Ok(_) => Ok(buffer),
return Ok(buffer); Err(err) => Err(err),
}
Err(err) => {
return Err(err);
}
} }
} }
} }

View File

@@ -26,6 +26,6 @@ impl Default for LoginResult {
impl LoginResult { impl LoginResult {
pub fn _to_json(&self) -> Result<String, serde_json::Error> { pub fn _to_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self); serde_json::to_string_pretty(&self)
} }
} }

View File

@@ -96,18 +96,18 @@ impl Default for Song {
impl Song { impl Song {
pub fn to_metadata_json(&self, pretty: bool) -> Result<String, serde_json::Error> { pub fn to_metadata_json(&self, pretty: bool) -> Result<String, serde_json::Error> {
if pretty { if pretty {
return serde_json::to_string_pretty(&self); serde_json::to_string_pretty(&self)
} else { } else {
return serde_json::to_string(&self); serde_json::to_string(&self)
} }
} }
pub fn song_path(&self) -> Result<String, std::io::Error> { pub fn song_path(&self) -> Result<String, std::io::Error> {
if self.directory.is_empty() { if self.directory.is_empty() {
return Err(std::io::Error::new( Err(std::io::Error::new(
std::io::ErrorKind::Other, std::io::ErrorKind::Other,
"Directory does not exist", "Directory does not exist",
)); ))
} }
let directory = &self.directory; let directory = &self.directory;
@@ -121,12 +121,12 @@ impl Song {
buffer += &self.filename.clone(); buffer += &self.filename.clone();
return Ok(buffer); Ok(buffer)
} else { } else {
return Err(std::io::Error::new( Err(std::io::Error::new(
std::io::ErrorKind::Other, std::io::ErrorKind::Other,
"Could not access last character of directory", "Could not access last character of directory",
)); ))
} }
} }
@@ -140,17 +140,15 @@ impl Song {
file.read_to_end(&mut buffer)?; file.read_to_end(&mut buffer)?;
if buffer.len() == 0 { if buffer.len() == 0 {
return Err(std::io::Error::new( Err(std::io::Error::new(
std::io::ErrorKind::Other, std::io::ErrorKind::Other,
"File is empty", "File is empty",
)); ))
} else { } else {
return Ok(buffer); Ok(buffer)
} }
} }
Err(er) => { Err(er) => Err(er),
return Err(er);
}
} }
} }