This commit is contained in:
Wojciech Kozlowski 2023-04-10 00:04:03 +02:00
parent 5250b1b93a
commit 5b4185df22
4 changed files with 15 additions and 10 deletions

View File

@ -1,7 +1,7 @@
//! Module for storing MusicHoard data in a JSON file database. //! Module for storing MusicHoard data in a JSON file database.
use std::fs; use std::fs;
use std::path::{PathBuf, Path}; use std::path::{Path, PathBuf};
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use serde::Serialize; use serde::Serialize;
@ -57,7 +57,9 @@ pub struct DatabaseJsonFile {
impl DatabaseJsonFile { impl DatabaseJsonFile {
/// Create a database instance that will read/write to the provided path. /// Create a database instance that will read/write to the provided path.
pub fn new(path: &Path) -> Self { pub fn new(path: &Path) -> Self {
DatabaseJsonFile { path: path.to_path_buf() } DatabaseJsonFile {
path: path.to_path_buf(),
}
} }
} }

View File

@ -32,7 +32,7 @@ impl<T: SimpleOption + Display> QueryOptionArgBeets for QueryOption<T> {
Self::Exclude(value) => ("^", value), Self::Exclude(value) => ("^", value),
Self::None => return None, Self::None => return None,
}; };
Some(format!("{}{}{}", negate, option_name, value)) Some(format!("{negate}{option_name}{value}"))
} }
} }
@ -43,7 +43,7 @@ impl QueryOptionArgBeets for QueryOption<Vec<String>> {
Self::Exclude(value) => ("^", value), Self::Exclude(value) => ("^", value),
Self::None => return None, Self::None => return None,
}; };
Some(format!("{}{}{}", negate, option_name, vec.join("; "))) Some(format!("{negate}{option_name}{}", vec.join("; ")))
} }
} }

View File

@ -1,6 +1,6 @@
//! Module for interacting with the music library. //! Module for interacting with the music library.
use std::{num::ParseIntError, str::Utf8Error, fmt}; use std::{fmt, num::ParseIntError, str::Utf8Error};
use crate::Artist; use crate::Artist;
@ -130,7 +130,7 @@ impl From<Utf8Error> for Error {
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:#?}", self) write!(f, "{self:#?}")
} }
} }

View File

@ -1,9 +1,12 @@
use std::fs; use std::fs;
use musichoard::{database::{ use musichoard::{
json::{DatabaseJson, DatabaseJsonFile}, database::{
DatabaseRead, DatabaseWrite, json::{DatabaseJson, DatabaseJsonFile},
}, Artist}; DatabaseRead, DatabaseWrite,
},
Artist,
};
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
use crate::COLLECTION; use crate::COLLECTION;