tauri_store/store/marshaler/
mod.rs

1mod json;
2
3#[cfg(feature = "marshaler-toml")]
4mod toml;
5
6use crate::store::StoreState;
7
8pub use json::{JsonMarshaler, PrettyJsonMarshaler};
9
10#[cfg(feature = "marshaler-toml")]
11pub use toml::{PrettyTomlMarshaler, TomlMarshaler};
12
13/// Generic marshaling error.
14pub type MarshalingError = Box<dyn std::error::Error + Send + Sync>;
15
16/// Describes how stores should be serialized and deserialized.
17pub trait Marshaler: Send + Sync {
18  fn serialize(&self, state: &StoreState) -> Result<Vec<u8>, MarshalingError>;
19  fn deserialize(&self, bytes: &[u8]) -> Result<StoreState, MarshalingError>;
20
21  /// Extension with which the store will be saved. Defaults to `store`.
22  fn extension(&self) -> &'static str {
23    "store"
24  }
25}