tauri_plugin_android_fs/
error.rs1use serde::{ser::Serializer, Serialize};
2
3pub type Result<T> = std::result::Result<T, crate::Error>;
4
5#[derive(Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum Error {
8
9 #[error("This device is not running Android. This plugin is only supported on Android.")]
10 NotAndroid,
11
12 #[error(transparent)]
13 Io(#[from] std::io::Error),
14
15 #[error(transparent)]
16 SerdeJson(#[from] serde_json::Error),
17
18 #[error("{0}")]
19 PluginInvoke(String),
20}
21
22#[cfg(target_os = "android")]
23impl From<tauri::plugin::mobile::PluginInvokeError> for crate::Error {
24
25 fn from(value: tauri::plugin::mobile::PluginInvokeError) -> Self {
26 Self::PluginInvoke(format!("{value}"))
27 }
28}
29
30impl Serialize for crate::Error {
31
32 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
33 where
34 S: Serializer,
35 {
36 serializer.serialize_str(self.to_string().as_ref())
37 }
38}