tauri_plugin_bluetooth_manager/
error.rs1use serde::Serializer;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum Error {
6 #[error("D-Bus error: {0}")]
7 Zbus(#[from] zbus::Error),
8 #[error("D-Bus variant error: {0}")]
9 Zvariant(#[from] zbus::zvariant::Error),
10 #[error("Command error: {0}")]
11 CommandError(String),
12 #[error("Not found: {0}")]
13 NotFound(String),
14}
15
16impl serde::Serialize for Error {
17 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18 where
19 S: Serializer,
20 {
21 serializer.serialize_str(&self.to_string())
22 }
23}
24
25impl From<std::convert::Infallible> for Error {
26 fn from(_err: std::convert::Infallible) -> Self {
27 Error::CommandError("Infallible error encountered".to_string())
28 }
29}
30
31pub type Result<T> = std::result::Result<T, Error>;