tauri-plugin-profiling 0.1.0

Tauri plugin for CPU profiling with flamegraph generation
Documentation
//! Error types for the profiling plugin.

use serde::{Serialize, Serializer};
use thiserror::Error;

/// Errors that can occur during profiling operations.
#[derive(Debug, Error)]
pub enum Error {
    #[error("Profiling is not supported on this platform")]
    UnsupportedPlatform,

    #[error("Profiler is already running")]
    AlreadyRunning,

    #[error("No profiler is currently running")]
    NotRunning,

    #[error("Failed to start profiler: {0}")]
    StartFailed(String),

    #[error("Failed to build profiler report: {0}")]
    ReportFailed(String),

    #[error("Failed to generate flamegraph: {0}")]
    FlamegraphFailed(String),

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Failed to resolve output path: {0}")]
    PathResolution(String),

    #[error("Tauri error: {0}")]
    Tauri(#[from] tauri::Error),

    #[error("Lock poisoned")]
    LockPoisoned,
}

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())
    }
}

/// A specialized Result type for profiling operations.
pub type Result<T> = std::result::Result<T, Error>;