| 1 | use serde::{ser::Serializer, Serialize}; |
| 2 | |
| 3 | pub type Result<T> = std::result::Result<T, Error>; |
| 4 | |
| 5 | #[derive(Debug, thiserror::Error)] |
| 6 | pub enum Error { |
| 7 | #[error(transparent)] |
| 8 | Io(#[from] std::io::Error), |
| 9 | #[cfg(mobile)] |
| 10 | #[error(transparent)] |
| 11 | PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), |
| 12 | } |
| 13 | |
| 14 | impl Serialize for Error { |
| 15 | fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> |
| 16 | where |
| 17 | S: Serializer, |
| 18 | { |
| 19 | serializer.serialize_str(self.to_string().as_ref()) |
| 20 | } |
| 21 | } |