feat(store): expose Store to Rust code (#108)

* feat(store): expose Store to Rust code in a meaningful way

* manually implement Default to improve generic inference

* update readme

* rename method

* make error Send and Sync

* make `use_store` more ergonomic

* export JsonValue

* fix readme example

* fmt

---------

Co-authored-by: FabianLars <fabianlars@fabianlars.de>
This commit is contained in:
Jonas Kruckenberg
2023-03-06 15:44:02 +01:00
committed by GitHub
co-authored by FabianLars
parent 6d7b985b46
commit d4223f6fd2
4 changed files with 236 additions and 144 deletions
+5 -2
View File
@@ -10,9 +10,9 @@ use std::path::PathBuf;
#[non_exhaustive]
pub enum Error {
#[error("Failed to serialize store. {0}")]
Serialize(Box<dyn std::error::Error>),
Serialize(Box<dyn std::error::Error + Send + Sync>),
#[error("Failed to deserialize store. {0}")]
Deserialize(Box<dyn std::error::Error>),
Deserialize(Box<dyn std::error::Error + Send + Sync>),
/// JSON error.
#[error(transparent)]
Json(#[from] serde_json::Error),
@@ -22,6 +22,9 @@ pub enum Error {
/// Store not found
#[error("Store \"{0}\" not found")]
NotFound(PathBuf),
/// Some Tauri API failed
#[error(transparent)]
Tauri(#[from] tauri::Error),
}
impl Serialize for Error {