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

Commit

Permalink
chore: Wiz I know you don't like to see many commits, so, I give my w…
Browse files Browse the repository at this point in the history
…ord to 100% force push everything back to a single commit.

Everything will nice and tidy, so your commit OCD can calm down :)
  • Loading branch information
saenai255 committed Sep 5, 2022
1 parent dba217a commit 009febc
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Test generated junk
db.json
2 changes: 2 additions & 0 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Provides structs to handle Pacstall's data models.

mod pacbuild;
mod repository;

Expand Down
16 changes: 8 additions & 8 deletions src/model/pacbuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct PacBuild {
/// ```
pub type Version = String;

/// Represents a PACBUILD or Apt package name.
/// Represents a `PacBuild` or Apt package name.
/// # Examples
/// ```
/// use libpacstall::model::PackageId;
Expand All @@ -46,7 +46,7 @@ pub type PackageId = String;
/// let url: URL = "https://example.com".into();
/// ```
pub type URL = String;
/// Represents a file SHA1 checksum
/// Represents a file checksum
/// # Examples
/// ```
/// use libpacstall::model::Hash;
Expand Down Expand Up @@ -83,7 +83,7 @@ impl InstallState {
pub fn is_installed(&self) -> bool { !matches!(self, Self::None) }
}

/// Represents the type of the package. Usually deduced by the `PACBUILD.name`
/// Represents the type of the package. Usually deduced by the [PacBuild#name]
/// suffix.
///
/// # Examples
Expand All @@ -94,18 +94,18 @@ impl InstallState {
/// ```
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum Kind {
/// PACBUILD will install an `AppImage`.
/// [PacBuild] will install an `AppImage`.
AppImage(Hash),

/// PACBUILD will install a prebuilt, usually `tar.gz`, package.
/// [PacBuild] will install a prebuilt, usually `tar.gz`, package.
Binary(Hash),

/// PACBUILD will install an existing `.deb` file.
/// [PacBuild] will install an existing `.deb` file.
DebFile(Hash),

/// PACBUILD will install the source of a given Git branch.
/// [PacBuild] will install the source of a given Git branch.
GitBranch,

/// PACBUILD will install the source of a given Git release.
/// [PacBuild] will install the source of a given Git release.
GitRelease,
}
2 changes: 1 addition & 1 deletion src/model/repository.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde_derive::{Deserialize, Serialize};

/// The extracted `repositories` array of tables.
/// Representation of a Pacstall repository.
///
/// Defaults to the official repository.
#[derive(Deserialize, Debug, Eq, PartialEq, Serialize, Clone)]
Expand Down
28 changes: 14 additions & 14 deletions src/store/base.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Abstraction over the caching implementation

use std::fmt::Debug;

use crate::model::{PacBuild, Repository};
Expand All @@ -6,58 +8,56 @@ use crate::store::filters::{InstallState, Kind};

pub type StoreResult<T> = Result<T, StoreError>;

/// 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`
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`
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`
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::RepositoryNotFound`
/// * `StoreError::PacBuildNotFound`
/// * `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::RepositoryConflict`
/// * `StoreError::PacBuildConflict`
/// * `StoreError::Aggregate`
fn add_all_pacbuilds(
&mut self,
pacbuilds: Vec<PacBuild>,
repository_url: &str,
) -> StoreResult<()>;

/// Updates all `PACBUILD` that belongs to the given repository.
/// Updates all `PacBuild` that belongs to the given repository.
///
/// # Errors
/// * `StoreError::RepositoryNotFound`
/// * `StoreError::PacBuildNotFound`
/// * `StoreError::Aggregate`
fn update_all_pacbuilds(
&mut self,
pacbuilds: Vec<PacBuild>,
repository_url: &str,
) -> StoreResult<()>;

/// Removes `Repository` by url.
/// Removes [Repository] by url.
///
/// # Errors
/// * `StoreError::RepositoryNotFound`
Expand All @@ -69,7 +69,7 @@ pub trait Base: Debug {
/// * `StoreError::RepositoryConflict`
fn add_repository(&mut self, repository: Repository) -> StoreResult<()>;

/// Updates `Repository`.
/// Updates [Repository].
///
/// # Errors
/// * `StoreError::RepositoryConflict`
Expand Down
3 changes: 3 additions & 0 deletions src/store/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Errors used by the caching system

/// Errors used by Base
#[derive(Debug, Clone)]
pub enum StoreError {
RepositoryNotFound(String),
Expand Down
4 changes: 4 additions & 0 deletions src/store/filters.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Provides various structs for querying and filtering packages.

/// Used to query packages by installation state
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum InstallState {
Direct,
Expand All @@ -15,6 +18,7 @@ impl InstallState {
}
}

/// Used to query packages by kind.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Kind {
AppImage,
Expand Down
7 changes: 6 additions & 1 deletion src/store/fs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Provides a JSON file-based implementation for the caching system.

use std::collections::HashMap;

use serde::{Deserialize, Serialize};
Expand All @@ -7,9 +9,12 @@ use crate::model::{PacBuild, Repository};
use crate::store::base::{Base, StoreResult};
use crate::store::filters::{InstallState, Kind};

#[cfg(not(test))]
const FSS_PATH: &str = "/etc/pacstall/fss.json";
#[cfg(test)]
const FSS_PATH: &str = "./fss.json";

/// `FileSystem` implementation for caching
/// `FileSystem` implementation for the caching system
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FileSystemStore {
repositories: Vec<Repository>,
Expand Down
2 changes: 2 additions & 0 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Provides traits and structs to handle Pacstall's cache.

pub mod base;
pub mod errors;
pub mod filters;
Expand Down

0 comments on commit 009febc

Please sign in to comment.