diff --git a/src/model/pacbuild.rs b/src/model/pacbuild.rs index 6145f08..5f03d36 100644 --- a/src/model/pacbuild.rs +++ b/src/model/pacbuild.rs @@ -1,3 +1,5 @@ +//! + use chrono::NaiveDateTime as DateTime; use serde_derive::{Deserialize, Serialize}; @@ -31,7 +33,7 @@ pub struct PacBuild { /// ``` pub type Version = String; -/// Represents a `PacBuild` or Apt package name. +/// Represents a [`PacBuild`] or Apt package name. /// # Examples /// /// ``` diff --git a/src/store/base.rs b/src/store/base.rs index 700ddd4..8868499 100644 --- a/src/store/base.rs +++ b/src/store/base.rs @@ -11,47 +11,47 @@ pub type StoreResult = Result; /// Abstraction over the caching implementation pub trait Base: Debug { - /// Removes `PacBuild` by name that belongs to the given repository. + /// Removes [`PacBuild`] by name that belongs to the given repository. /// /// # Errors - /// * `StoreError::RepositoryNotFound` - /// * `StoreError::PacBuildNotFound` + /// * [`StoreError::RepositoryNotFound`] + /// * [`StoreError::PacBuildNotFound`] fn remove_pacbuild(&mut self, name: &str, repository_url: &str) -> StoreResult<()>; - /// Adds `PacBuild` to the given repository. + /// Adds [`PacBuild`] to the given repository. /// /// # Errors - /// * `StoreError::RepositoryConflict` - /// * `StoreError::PacBuildConflict` + /// * [`StoreError::RepositoryConflict`] + /// * [`StoreError::PacBuildConflict`] fn add_pacbuild(&mut self, pacbuild: PacBuild, repository_url: &str) -> StoreResult<()>; - /// Updates `PacBuild` that belongs to the given repository. + /// Updates [`PacBuild`] that belongs to the given repository. /// /// # Errors - /// * `StoreError::RepositoryNotFound` - /// * `StoreError::PacBuildNotFound` + /// * [`StoreError::RepositoryNotFound`] + /// * [`StoreError::PacBuildNotFound`] fn update_pacbuild(&mut self, pacbuild: PacBuild, repository_url: &str) -> StoreResult<()>; - /// Removes all `PacBuild` by name that belongs to the given repository. + /// Removes all [`PacBuild`] by name that belongs to the given repository. /// /// # Errors - /// * `StoreError::Aggregate` + /// * [`StoreError::Aggregate`] fn remove_all_pacbuilds(&mut self, name: &[&str], repository_url: &str) -> StoreResult<()>; - /// Adds all `PacBuild` to the given repository. + /// Adds all [`PacBuild`] to the given repository. /// /// # Errors - /// * `StoreError::Aggregate` + /// * [`StoreError::Aggregate`] fn add_all_pacbuilds( &mut self, pacbuilds: Vec, repository_url: &str, ) -> StoreResult<()>; - /// Updates all `PacBuild` that belongs to the given repository. + /// Updates all [`PacBuild`] that belongs to the given repository. /// /// # Errors - /// * `StoreError::Aggregate` + /// * [`StoreError::Aggregate`] fn update_all_pacbuilds( &mut self, pacbuilds: Vec, @@ -61,19 +61,19 @@ pub trait Base: Debug { /// Removes [Repository] by url. /// /// # Errors - /// * `StoreError::RepositoryNotFound` + /// * [`StoreError::RepositoryNotFound`] fn remove_repository(&mut self, repository_url: &str) -> StoreResult<()>; /// Adds `Repository`. /// /// # Errors - /// * `StoreError::RepositoryConflict` + /// * [`StoreError::RepositoryConflict`] fn add_repository(&mut self, repository: Repository) -> StoreResult<()>; /// Updates [Repository]. /// /// # Errors - /// * `StoreError::RepositoryConflict` + /// * [`StoreError::RepositoryConflict`] fn update_repository(&mut self, repository: Repository) -> StoreResult<()>; /// Find first by name in the given repository diff --git a/src/store/filters.rs b/src/store/filters.rs index aefe474..d8195ca 100644 --- a/src/store/filters.rs +++ b/src/store/filters.rs @@ -8,6 +8,12 @@ pub enum InstallState { None, } +impl From<&crate::model::InstallState> for InstallState { + fn from(other: &crate::model::InstallState) -> Self { + InstallState::from_model_install_state(other) + } +} + impl InstallState { pub fn from_model_install_state(other: &crate::model::InstallState) -> InstallState { match other { @@ -28,6 +34,10 @@ pub enum Kind { GitRelease, } +impl From<&crate::model::Kind> for Kind { + fn from(other: &crate::model::Kind) -> Self { Kind::from_model_kind(other) } +} + impl Kind { pub fn from_model_kind(other: &crate::model::Kind) -> Kind { match other { diff --git a/src/store/fs.rs b/src/store/fs.rs index 2769ff0..0f5e283 100644 --- a/src/store/fs.rs +++ b/src/store/fs.rs @@ -139,15 +139,14 @@ impl Base for FileSystemStore { .flat_map(|(_, pkgs)| pkgs) .filter(|it| { if let Some(kind_filter) = &kind { - *kind_filter == Kind::from_model_kind(&it.kind) + *kind_filter == (&it.kind).into() } else { true } }) .filter(|it| { if let Some(install_state_filter) = &install_state { - *install_state_filter - == InstallState::from_model_install_state(&it.install_state) + *install_state_filter == (&it.install_state).into() } else { true }