Files
tauri-plugins-workspace/plugins/biometric/src/error.rs
T
2026-09-26 15:36:22 -03:00

32 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 a [`Result`](std::result::Result) with the error type [`Error`].
pub type Result<T> = std::result::Result<T, Error>;
/// The error types returned by this plugin.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// An I/O error occurred.
#[error(transparent)]
Io(#[from] std::io::Error),
/// The invocation of the underlying Android or iOS plugin failed, for example because
/// biometric authentication was unavailable, was not enrolled, failed, or was canceled by
/// the user.
#[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())
}
}