mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:52:12 +00:00
24 lines
702 B
Rust
24 lines
702 B
Rust
use ide_core::{EventSink, IdeEvent};
|
|
use tauri::{AppHandle, Emitter};
|
|
|
|
/// Name of the single backend → UI event. Payload: [`IdeEvent`].
|
|
pub const IDE_EVENT: &str = "ide://event";
|
|
|
|
/// Forwards events to one window (`Some(label)`) or to all windows.
|
|
pub struct TauriSink {
|
|
pub app: AppHandle,
|
|
pub window: Option<String>,
|
|
}
|
|
|
|
impl EventSink for TauriSink {
|
|
fn emit(&self, event: IdeEvent) {
|
|
let result = match &self.window {
|
|
Some(label) => self.app.emit_to(label.as_str(), IDE_EVENT, &event),
|
|
None => self.app.emit(IDE_EVENT, &event),
|
|
};
|
|
if let Err(e) = result {
|
|
tracing::warn!("failed to emit ide event: {e}");
|
|
}
|
|
}
|
|
}
|