Fixed some warnings #11

Merged
phoenix merged 13 commits from warning_fixes into devel 2025-03-22 18:24:09 +00:00
4 changed files with 19 additions and 25 deletions
Showing only changes of commit 5a4e27af39 - Show all commits

View File

@@ -20,23 +20,23 @@ impl Default for AccessLevel {
}
pub fn default_level() -> AccessLevel {
return AccessLevel {
AccessLevel {
id: -1,
level: String::from("Public"),
song_id: -1,
};
}
}
pub fn private_level() -> AccessLevel {
return AccessLevel {
AccessLevel {
id: -1,
level: String::from("Private"),
song_id: -1,
};
}
}
impl AccessLevel {
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 buffer = Vec::new();
match file.read_to_end(&mut buffer) {
Ok(_) => {
return Ok(buffer);
}
Err(err) => {
return Err(err);
}
Ok(_) => Ok(buffer),
Err(err) => Err(err),
}
}
}

View File

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