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, PartialEq, Eq, Hash, Clone, Copy, thiserror::Error)]
7#[non_exhaustive]
8#[deprecated(note = "Unused error in this plugin")]
9pub enum PathError {
10
11 #[error("The path contains consecutive separators.")]
13 ConsecutiveSeparator,
14
15 #[error("The path does not contain a filename.")]
17 DoesNotContainFileName,
18
19 #[error("The path does not contain a subdirectory.")]
21 DoesNotContainSubDir,
22
23 #[error("The path is empty.")]
25 Empty,
26}
27
28#[derive(Debug, thiserror::Error)]
29#[non_exhaustive]
30pub enum Error {
31
32 #[error("This device is not running Android. This plugin is only supported on Android.")]
33 NotAndroid,
34
35 #[error(transparent)]
36 #[deprecated(note = "Unused error in this plugin")]
37 #[allow(deprecated)]
38 Path(#[from] PathError),
39
40 #[error(transparent)]
41 Io(#[from] std::io::Error),
42
43 #[error("{0}")]
44 PluginInvoke(String),
45}
46
47#[cfg(target_os = "android")]
48impl From<tauri::plugin::mobile::PluginInvokeError> for crate::Error {
49
50 fn from(value: tauri::plugin::mobile::PluginInvokeError) -> Self {
51 Self::PluginInvoke(format!("{value}"))
52 }
53}
54
55impl Serialize for crate::Error {
56
57 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
58 where
59 S: Serializer,
60 {
61 serializer.serialize_str(self.to_string().as_ref())
62 }
63}