-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: simonsan <[email protected]>
- Loading branch information
Showing
7 changed files
with
3,386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[package] | ||
name = "pace_storage" | ||
version = "0.1.0" | ||
authors = { workspace = true } | ||
categories = { workspace = true } | ||
edition = { workspace = true } | ||
homepage = { workspace = true } | ||
keywords = { workspace = true } | ||
license = { workspace = true } | ||
repository = { workspace = true } | ||
rust-version = { workspace = true } | ||
description = "pace-storage - a library handling storage engines for pace" | ||
|
||
include = [ | ||
"LICENSE", | ||
"README.md", | ||
"CHANGELOG.md", | ||
"src/**/*", | ||
"Cargo.toml", | ||
] | ||
|
||
[features] | ||
default = ["db"] | ||
db = ["rusqlite"] | ||
rusqlite = ["dep:rusqlite", "dep:libsqlite3-sys"] | ||
|
||
[dependencies] | ||
displaydoc = { workspace = true } | ||
itertools = { workspace = true } | ||
libsqlite3-sys = { workspace = true, features = ["bundled"], optional = true } | ||
merge = { workspace = true } | ||
pace_core = { workspace = true } | ||
pace_time = { workspace = true, features = ["db"] } | ||
parking_lot = { workspace = true, features = ["deadlock_detection"] } | ||
rayon = { workspace = true } | ||
rusqlite = { workspace = true, optional = true, features = ["bundled", "chrono"] } | ||
thiserror = { workspace = true } | ||
toml = { workspace = true, features = ["indexmap", "preserve_order"] } | ||
tracing = { workspace = true } | ||
ulid = { workspace = true, features = ["serde"] } | ||
|
||
[dev-dependencies] | ||
chrono = { workspace = true, features = ["serde"] } | ||
|
||
[lints] | ||
workspace = true |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use std::path::PathBuf; | ||
|
||
use displaydoc::Display; | ||
use pace_core::prelude::{Activity, ActivityGuid, DatabaseEngineKind}; | ||
use thiserror::Error; | ||
|
||
pub type PaceStorageResult<T> = Result<T, PaceStorageErrorKind>; | ||
|
||
/// [`PaceTimeErrorKind`] describes the errors that can happen while dealing with time. | ||
#[non_exhaustive] | ||
#[derive(Error, Debug, Display)] | ||
pub enum PaceStorageErrorKind { | ||
/// SQLite error: {0} | ||
#[error(transparent)] | ||
#[cfg(feature = "rusqlite")] | ||
SQLite(#[from] rusqlite::Error), | ||
|
||
/// Database error: {0} | ||
#[error(transparent)] | ||
Database(#[from] DatabaseStorageErrorKind), | ||
|
||
/// Toml file error: {0} | ||
#[error(transparent)] | ||
TomlFile(#[from] TomlFileStorageErrorKind), | ||
|
||
/// Database storage not configured | ||
DatabaseStorageNotConfigured, | ||
} | ||
|
||
/// [`DatabaseErrorKind`] describes the errors that can happen while dealing with the SQLite database. | ||
#[non_exhaustive] | ||
#[derive(Error, Debug, Display)] | ||
pub enum DatabaseStorageErrorKind { | ||
/// Error connecting to database: {0} - {1} | ||
ConnectionFailed(String, String), | ||
|
||
/// No connection string provided | ||
NoConnectionString, | ||
|
||
/// No configuration settings provided in configuration file, please set them up with `pace setup config` | ||
NoConfigSettings, | ||
|
||
/// This database engine is currently not supported: {0} | ||
UnsupportedDatabaseEngine(DatabaseEngineKind), | ||
|
||
/// Activity with id {0} not found | ||
ActivityNotFound(ActivityGuid), | ||
|
||
/// Failed to create activity: {0} | ||
ActivityCreationFailed(Activity), | ||
|
||
/// Failed to delete activity: {0} | ||
ActivityDeletionFailed(ActivityGuid), | ||
} | ||
|
||
/// [`TomlFileStorageErrorKind`] describes the errors that can happen while dealing with the Toml file storage. | ||
#[non_exhaustive] | ||
#[derive(Error, Debug, Display)] | ||
pub enum TomlFileStorageErrorKind { | ||
/// Parent directory not found: {0} | ||
ParentDirNotFound(PathBuf), | ||
} |
Oops, something went wrong.