Skip to main content

tauri_plugin_sync_state/
error.rs

1use serde::Serialize;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum Error {
6    #[error("sync-state registry lock was poisoned")]
7    LockPoisoned,
8    #[error("state slice '{0}' is not registered — call .register({0}::default())")]
9    NotFound(String),
10    #[error("state slice '{0}' is registered under a different Rust type")]
11    TypeMismatch(String),
12    #[error("state slice '{0}' was registered twice")]
13    DuplicateRegistration(String),
14    #[error("failed to serialize state: {0}")]
15    Serialize(String),
16    #[error("failed to deserialize state: {0}")]
17    Deserialize(String),
18    #[error("failed to emit update event: {0}")]
19    Emit(String),
20    #[error("sync-state plugin is not initialized — add it via Builder::new()...build()")]
21    PluginNotInitialized,
22}
23
24pub type Result<T> = std::result::Result<T, Error>;
25
26impl Serialize for Error {
27    fn serialize<S: serde::Serializer>(&self, s: S) -> std::result::Result<S::Ok, S::Error> {
28        s.serialize_str(&self.to_string())
29    }
30}