Skip to main content

crisol_core/protocol/
events.rs

1//! Events emitted by a host.
2//!
3//! ```
4//! use crisol_core::protocol::events;
5//! ```
6
7use serde::{Deserialize, Serialize};
8use serde_json::Value;
9
10/// Something the host reports to the embedding application.
11#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
12#[serde(tag = "event", rename_all = "snake_case")]
13#[non_exhaustive]
14/// # Example
15///
16/// ```
17/// use crisol_core::protocol::HostEvent;
18/// ```
19pub enum HostEvent {
20    /// A button or command ran.
21    Command {
22        /// Command id.
23        id: String,
24    },
25    /// A value changed.
26    ValueChanged {
27        /// Widget id.
28        id: String,
29        /// New value.
30        value: Value,
31    },
32    /// A tab strip changed.
33    TabChanged {
34        /// Strip id.
35        id: String,
36        /// Active index.
37        index: usize,
38    },
39    /// A tree selection changed.
40    TreeSelected {
41        /// Tree id.
42        id: String,
43        /// Node key.
44        key: String,
45    },
46    /// A custom widget emitted an event.
47    Custom {
48        /// Widget kind.
49        kind: String,
50        /// Opaque payload.
51        payload: Value,
52    },
53    /// The host window was closed.
54    Closed,
55}