mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
31 lines
1023 B
Rust
31 lines
1023 B
Rust
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use serde::{ser::Serializer, Serialize};
|
|
|
|
/// Alias for the result type returned by this crate's functions.
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
/// The error type returned by this crate's APIs. Serialized as its [`Display`](std::fmt::Display)
|
|
/// string when it crosses the IPC boundary.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum Error {
|
|
/// An I/O error occurred.
|
|
#[error(transparent)]
|
|
Io(#[from] std::io::Error),
|
|
/// Failed to run a command on the mobile plugin implementation (Kotlin on Android, Swift on iOS).
|
|
#[cfg(mobile)]
|
|
#[error(transparent)]
|
|
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
|
|
}
|
|
|
|
impl Serialize for Error {
|
|
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
|
where
|
|
S: Serializer,
|
|
{
|
|
serializer.serialize_str(self.to_string().as_ref())
|
|
}
|
|
}
|