unistore-tray 0.1.0

System tray capability for UniStore - cross-platform tray icon, menu, and notifications
Documentation
//! 【Stub 实现】- 不支持平台的占位实现
//!
//! 职责:
//! - 为不支持的平台提供编译通过的实现
//! - 所有操作返回 Unsupported 错误

use crate::backend::PlatformTrayOps;
use crate::config::TrayConfig;
use crate::error::{TrayError, TrayResult};
use crate::event::TrayEvent;
use crate::icon::TrayIcon;
use crate::menu::Menu;

use tokio::sync::broadcast;

/// Stub 平台实现(不支持的平台)
pub struct PlatformTray {
    event_tx: broadcast::Sender<TrayEvent>,
}

impl PlatformTrayOps for PlatformTray {
    fn new(_config: &TrayConfig, event_tx: broadcast::Sender<TrayEvent>) -> TrayResult<Self> {
        // 发送就绪事件(虽然实际不工作)
        let _ = event_tx.send(TrayEvent::Ready);
        
        Ok(Self { event_tx })
    }

    fn set_icon(&self, _icon: &TrayIcon) -> TrayResult<()> {
        Err(TrayError::Unsupported(
            "当前平台不支持系统托盘".into()
        ))
    }

    fn set_tooltip(&self, _tooltip: &str) -> TrayResult<()> {
        Err(TrayError::Unsupported(
            "当前平台不支持系统托盘".into()
        ))
    }

    fn set_menu(&self, _menu: &Menu) -> TrayResult<()> {
        Err(TrayError::Unsupported(
            "当前平台不支持系统托盘".into()
        ))
    }

    fn destroy(&self) -> TrayResult<()> {
        let _ = self.event_tx.send(TrayEvent::Destroyed);
        Ok(())
    }
}