p2p_chat/ui/
event.rs

1//! This module defines the events that can be sent to the UI.
2use crate::types::Message;
3use crossterm::event::KeyEvent;
4
5use super::log_entry::LogEntry;
6
7/// Represents an event that can be sent to the UI.
8#[derive(Debug)]
9pub enum UIEvent {
10    /// A new message has arrived.
11    NewMessage(Message),
12    /// A batch of new log entries has arrived.
13    NewLogBatch(Vec<LogEntry>),
14    /// Request to refresh the displayed logs.
15    RefreshLogs,
16    /// A chat message to be displayed in the UI.
17    ChatMessage(String),
18    /// A block of text representing historical output, typically from command execution.
19    HistoryOutput(String),
20    /// A key press event from the terminal.
21    KeyPress(KeyEvent),
22    /// The terminal has been resized.
23    Resize(u16, u16),
24    /// Update the count of connected peers.
25    UpdatePeersCount(usize),
26    /// Update the list of discovered peers.
27    UpdateDiscoveredPeers(Vec<String>),
28}