make error Send and Sync

pull/108/head
Jonas Kruckenberg 2 years ago
parent f1ad29c882
commit b3bd475d02

@ -10,9 +10,9 @@ use std::path::PathBuf;
#[non_exhaustive] #[non_exhaustive]
pub enum Error { pub enum Error {
#[error("Failed to serialize store. {0}")] #[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}")] #[error("Failed to deserialize store. {0}")]
Deserialize(Box<dyn std::error::Error>), Deserialize(Box<dyn std::error::Error + Send + Sync>),
/// JSON error. /// JSON error.
#[error(transparent)] #[error(transparent)]
Json(#[from] serde_json::Error), Json(#[from] serde_json::Error),

@ -12,18 +12,18 @@ use std::{
}; };
use tauri::{AppHandle, Manager, Runtime}; use tauri::{AppHandle, Manager, Runtime};
type SerializeFn = fn(&HashMap<String, JsonValue>) -> Result<Vec<u8>, Box<dyn std::error::Error>>; type SerializeFn = fn(&HashMap<String, JsonValue>) -> Result<Vec<u8>, Box<dyn std::error::Error + Send + Sync>>;
type DeserializeFn = fn(&[u8]) -> Result<HashMap<String, JsonValue>, Box<dyn std::error::Error>>; type DeserializeFn = fn(&[u8]) -> Result<HashMap<String, JsonValue>, Box<dyn std::error::Error + Send + Sync>>;
fn default_serialize( fn default_serialize(
cache: &HashMap<String, JsonValue>, cache: &HashMap<String, JsonValue>,
) -> Result<Vec<u8>, Box<dyn std::error::Error>> { ) -> Result<Vec<u8>, Box<dyn std::error::Error + Send + Sync>> {
Ok(serde_json::to_vec(&cache)?) Ok(serde_json::to_vec(&cache)?)
} }
fn default_deserialize( fn default_deserialize(
bytes: &[u8], bytes: &[u8],
) -> Result<HashMap<String, JsonValue>, Box<dyn std::error::Error>> { ) -> Result<HashMap<String, JsonValue>, Box<dyn std::error::Error + Send + Sync>> {
serde_json::from_slice(bytes).map_err(Into::into) serde_json::from_slice(bytes).map_err(Into::into)
} }

Loading…
Cancel
Save