tauri_plugin_keyring_store/error.rs
1//! Error types returned by the plugin (IPC-safe).
2
3use serde::{ser::Serializer, Serialize};
4
5/// Result alias using this crate’s [`Error`].
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Errors surfaced to the frontend and backend helpers (serializes as a plain string over IPC).
9#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 /// Stronghold-style session path was used before `initialize` completed for that path.
12 #[error("session not initialized: {0}")]
13 SessionNotInitialized(String),
14 /// OS keyring reported “no such credential” (or empty semantics aligned with Stronghold).
15 #[error("credential entry not found")]
16 NoEntry,
17 /// Platform backend could not be registered (e.g. missing OS APIs in doc builds).
18 #[error("plugin initialization failed: {0}")]
19 Init(String),
20 /// Wrapped error from [`keyring_core`] / native store.
21 #[error("keyring error: {0}")]
22 Keyring(String),
23 /// Base64 or other encoding used by the store layer failed.
24 #[error("encoding error: {0}")]
25 Encoding(String),
26 /// Optional `crypto` feature: SLIP10 / BIP39 / signing procedure failed.
27 #[error("crypto procedure error: {0}")]
28 Crypto(String),
29 /// [`crate::join_prefix`] / [`crate::split_prefixed`] validation failed.
30 #[error("naming / validation error: {0}")]
31 Naming(String),
32}
33
34impl Serialize for Error {
35 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
36 where
37 S: Serializer,
38 {
39 serializer.serialize_str(self.to_string().as_ref())
40 }
41}