tauri_store/store/marshaler/
mod.rs1mod json;
2
3#[cfg(feature = "marshaler-cbor")]
4mod cbor;
5#[cfg(feature = "marshaler-ron")]
6mod ron;
7#[cfg(feature = "marshaler-toml")]
8mod toml;
9
10use crate::store::StoreState;
11
12pub use json::{JsonMarshaler, PrettyJsonMarshaler};
13
14#[cfg(feature = "marshaler-cbor")]
15pub use cbor::CborMarshaler;
16#[cfg(feature = "marshaler-ron")]
17pub use ron::{PrettyRonMarshaler, RonMarshaler};
18#[cfg(feature = "marshaler-toml")]
19pub use toml::{PrettyTomlMarshaler, TomlMarshaler};
20
21pub type MarshalingError = Box<dyn std::error::Error + Send + Sync>;
23
24pub trait Marshaler: Send + Sync {
26 fn serialize(&self, state: &StoreState) -> Result<Vec<u8>, MarshalingError>;
27 fn deserialize(&self, bytes: &[u8]) -> Result<StoreState, MarshalingError>;
28
29 fn extension(&self) -> &'static str {
31 "store"
32 }
33}