Files
tauri-plugins-workspace/plugins/torch/src/error.rs
T
0xbizkandLucas Nogueira d80b1be257 feat: add torch plugin for iOS and Android (#3551)
* feat(barcode-scanner): add torch toggle

* feat: torch plugin

* fix

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
2026-10-13 05:37:04 -03:00

29 lines
1.0 KiB
Rust

// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use serde::{Serialize, ser::Serializer};
/// 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 {
/// Failed to run a command on the mobile plugin implementation (Kotlin on Android, Swift on
/// iOS). This includes the native side rejecting the call, e.g. because the device has no
/// torch or the camera is held by another app.
#[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())
}
}