Missing docstrings (#102)
All checks were successful
Cargo CI / Build and Test (push) Successful in 1m1s
Cargo CI / Lint (push) Successful in 44s
Cargo CI / Build and Test (pull_request) Successful in 2m26s
Cargo CI / Lint (pull_request) Successful in 45s

Closes #98

Reviewed-on: #102
This commit is contained in:
Wojciech Kozlowski 2024-01-12 21:52:06 +01:00
parent 95ee681229
commit 83675c25e6
3 changed files with 17 additions and 2 deletions

View File

@ -29,6 +29,7 @@ pub trait IMbid {
fn mbid(&self) -> &str;
}
/// The different URL types supported by MusicHoard.
#[derive(Debug)]
enum UrlType {
MusicBrainz,
@ -37,6 +38,7 @@ enum UrlType {
Qobuz,
}
/// Invalid URL error.
struct InvalidUrlError {
url_type: UrlType,
url: String,
@ -53,6 +55,7 @@ impl Display for InvalidUrlError {
pub struct MusicBrainz(Url);
impl MusicBrainz {
/// Validate and wrap a MusicBrainz URL.
pub fn new<S: AsRef<str>>(url: S) -> Result<Self, Error> {
let url = Url::parse(url.as_ref())?;
@ -112,6 +115,7 @@ impl IMbid for MusicBrainz {
pub struct MusicButler(Url);
impl MusicButler {
/// Validate and wrap a MusicButler URL.
pub fn new<S: AsRef<str>>(url: S) -> Result<Self, Error> {
let url = Url::parse(url.as_ref())?;
@ -157,6 +161,7 @@ impl IUrl for MusicButler {
pub struct Bandcamp(Url);
impl Bandcamp {
/// Validate and wrap a Bandcamp URL.
pub fn new<S: AsRef<str>>(url: S) -> Result<Self, Error> {
let url = Url::parse(url.as_ref())?;
@ -202,6 +207,7 @@ impl IUrl for Bandcamp {
pub struct Qobuz(Url);
impl Qobuz {
/// Validate and wrap a Qobuz URL.
pub fn new<S: AsRef<str>>(url: S) -> Result<Self, Error> {
let url = Url::parse(url.as_ref())?;
@ -423,6 +429,7 @@ macro_rules! artist_multi_url_dispatch {
}
impl Artist {
/// Create new [`Artist`] with the given [`ArtistId`].
pub fn new<ID: Into<ArtistId>>(id: ID) -> Self {
Artist {
id: id.into(),
@ -698,8 +705,10 @@ pub struct MusicHoard<LIB, DB> {
database: DB,
}
// Unit structs to ensure library/database are not compiled in.
/// Phantom type for when a library implementation is not needed.
pub struct NoLibrary;
/// Phantom type for when a database implementation is not needed.
pub struct NoDatabase;
macro_rules! music_hoard_unique_url_dispatch {
@ -787,6 +796,7 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
}
}
/// Retrieve the [`Collection`].
pub fn get_collection(&self) -> &Collection {
&self.collection
}
@ -914,6 +924,7 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
}
impl<LIB: ILibrary, DB> MusicHoard<LIB, DB> {
/// Rescan the library and merge with the in-memory collection.
pub fn rescan_library(&mut self) -> Result<(), Error> {
let items = self.library.list(&Query::new())?;
let mut library_collection = Self::items_to_artists(items);
@ -927,6 +938,7 @@ impl<LIB: ILibrary, DB> MusicHoard<LIB, DB> {
}
impl<LIB, DB: IDatabase> MusicHoard<LIB, DB> {
/// Load the database and merge with the in-memory collection.
pub fn load_from_database(&mut self) -> Result<(), Error> {
let mut database_collection = self.database.load()?;
Self::sort(&mut database_collection);
@ -937,6 +949,7 @@ impl<LIB, DB: IDatabase> MusicHoard<LIB, DB> {
Ok(())
}
/// Save the in-memory collection to the database.
pub fn save_to_database(&mut self) -> Result<(), Error> {
self.database.save(&self.collection)?;
Ok(())

View File

@ -76,6 +76,8 @@ impl IBeetsLibraryExecutorPrivate for BeetsLibraryProcessExecutor {}
// GRCOV_EXCL_START
#[cfg(feature = "ssh-library")]
pub mod ssh {
//! Module for interacting with the music library via
//! [beets](https://beets.readthedocs.io/en/stable/) over SSH.
use openssh::{KnownHosts, Session};
use tokio::runtime::{self, Runtime};

View File

@ -13,7 +13,7 @@ pub mod beets;
/// Trait for interacting with the music library.
#[cfg_attr(test, automock)]
pub trait ILibrary {
/// List lirbary items that match the a specific query.
/// List library items that match the a specific query.
fn list(&mut self, query: &Query) -> Result<Vec<Item>, Error>;
}