Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.

Commit 7668b2a

Browse files
committed
chore: impl From for filters
1 parent 817e873 commit 7668b2a

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

src/model/pacbuild.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//!
2+
13
use chrono::NaiveDateTime as DateTime;
24
use serde_derive::{Deserialize, Serialize};
35

@@ -31,7 +33,7 @@ pub struct PacBuild {
3133
/// ```
3234
pub type Version = String;
3335

34-
/// Represents a `PacBuild` or Apt package name.
36+
/// Represents a [`PacBuild`] or Apt package name.
3537
/// # Examples
3638
///
3739
/// ```

src/store/base.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,47 @@ pub type StoreResult<T> = Result<T, StoreError>;
1111

1212
/// Abstraction over the caching implementation
1313
pub trait Base: Debug {
14-
/// Removes `PacBuild` by name that belongs to the given repository.
14+
/// Removes [`PacBuild`] by name that belongs to the given repository.
1515
///
1616
/// # Errors
17-
/// * `StoreError::RepositoryNotFound`
18-
/// * `StoreError::PacBuildNotFound`
17+
/// * [`StoreError::RepositoryNotFound`]
18+
/// * [`StoreError::PacBuildNotFound`]
1919
fn remove_pacbuild(&mut self, name: &str, repository_url: &str) -> StoreResult<()>;
2020

21-
/// Adds `PacBuild` to the given repository.
21+
/// Adds [`PacBuild`] to the given repository.
2222
///
2323
/// # Errors
24-
/// * `StoreError::RepositoryConflict`
25-
/// * `StoreError::PacBuildConflict`
24+
/// * [`StoreError::RepositoryConflict`]
25+
/// * [`StoreError::PacBuildConflict`]
2626
fn add_pacbuild(&mut self, pacbuild: PacBuild, repository_url: &str) -> StoreResult<()>;
2727

28-
/// Updates `PacBuild` that belongs to the given repository.
28+
/// Updates [`PacBuild`] that belongs to the given repository.
2929
///
3030
/// # Errors
31-
/// * `StoreError::RepositoryNotFound`
32-
/// * `StoreError::PacBuildNotFound`
31+
/// * [`StoreError::RepositoryNotFound`]
32+
/// * [`StoreError::PacBuildNotFound`]
3333
fn update_pacbuild(&mut self, pacbuild: PacBuild, repository_url: &str) -> StoreResult<()>;
3434

35-
/// Removes all `PacBuild` by name that belongs to the given repository.
35+
/// Removes all [`PacBuild`] by name that belongs to the given repository.
3636
///
3737
/// # Errors
38-
/// * `StoreError::Aggregate`
38+
/// * [`StoreError::Aggregate`]
3939
fn remove_all_pacbuilds(&mut self, name: &[&str], repository_url: &str) -> StoreResult<()>;
4040

41-
/// Adds all `PacBuild` to the given repository.
41+
/// Adds all [`PacBuild`] to the given repository.
4242
///
4343
/// # Errors
44-
/// * `StoreError::Aggregate`
44+
/// * [`StoreError::Aggregate`]
4545
fn add_all_pacbuilds(
4646
&mut self,
4747
pacbuilds: Vec<PacBuild>,
4848
repository_url: &str,
4949
) -> StoreResult<()>;
5050

51-
/// Updates all `PacBuild` that belongs to the given repository.
51+
/// Updates all [`PacBuild`] that belongs to the given repository.
5252
///
5353
/// # Errors
54-
/// * `StoreError::Aggregate`
54+
/// * [`StoreError::Aggregate`]
5555
fn update_all_pacbuilds(
5656
&mut self,
5757
pacbuilds: Vec<PacBuild>,
@@ -61,19 +61,19 @@ pub trait Base: Debug {
6161
/// Removes [Repository] by url.
6262
///
6363
/// # Errors
64-
/// * `StoreError::RepositoryNotFound`
64+
/// * [`StoreError::RepositoryNotFound`]
6565
fn remove_repository(&mut self, repository_url: &str) -> StoreResult<()>;
6666

6767
/// Adds `Repository`.
6868
///
6969
/// # Errors
70-
/// * `StoreError::RepositoryConflict`
70+
/// * [`StoreError::RepositoryConflict`]
7171
fn add_repository(&mut self, repository: Repository) -> StoreResult<()>;
7272

7373
/// Updates [Repository].
7474
///
7575
/// # Errors
76-
/// * `StoreError::RepositoryConflict`
76+
/// * [`StoreError::RepositoryConflict`]
7777
fn update_repository(&mut self, repository: Repository) -> StoreResult<()>;
7878

7979
/// Find first by name in the given repository

src/store/filters.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ pub enum InstallState {
88
None,
99
}
1010

11+
impl From<&crate::model::InstallState> for InstallState {
12+
fn from(other: &crate::model::InstallState) -> Self {
13+
InstallState::from_model_install_state(other)
14+
}
15+
}
16+
1117
impl InstallState {
1218
pub fn from_model_install_state(other: &crate::model::InstallState) -> InstallState {
1319
match other {
@@ -28,6 +34,10 @@ pub enum Kind {
2834
GitRelease,
2935
}
3036

37+
impl From<&crate::model::Kind> for Kind {
38+
fn from(other: &crate::model::Kind) -> Self { Kind::from_model_kind(other) }
39+
}
40+
3141
impl Kind {
3242
pub fn from_model_kind(other: &crate::model::Kind) -> Kind {
3343
match other {

src/store/fs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,14 @@ impl Base for FileSystemStore {
139139
.flat_map(|(_, pkgs)| pkgs)
140140
.filter(|it| {
141141
if let Some(kind_filter) = &kind {
142-
*kind_filter == Kind::from_model_kind(&it.kind)
142+
*kind_filter == (&it.kind).into()
143143
} else {
144144
true
145145
}
146146
})
147147
.filter(|it| {
148148
if let Some(install_state_filter) = &install_state {
149-
*install_state_filter
150-
== InstallState::from_model_install_state(&it.install_state)
149+
*install_state_filter == (&it.install_state).into()
151150
} else {
152151
true
153152
}

0 commit comments

Comments
 (0)