Skip to main content

flashkraft_gui/core/
message.rs

1//! Message - Events in The Elm Architecture
2//!
3//! This module defines all possible messages (events) that can occur
4//! in the FlashKraft application. Messages are the only way to trigger
5//! state changes, making the application predictable and debuggable.
6
7use std::path::PathBuf;
8
9use crate::domain::DriveInfo;
10use iced::Theme;
11
12/// All possible messages in the application
13///
14/// Messages represent events that can occur, either from user interactions
15/// or as results of asynchronous operations (Commands).
16#[derive(Debug, Clone)]
17pub enum Message {
18    // ========================================================================
19    // User Interaction Messages
20    // ========================================================================
21    /// User clicked the "Select Image" button
22    SelectImageClicked,
23
24    /// User clicked the "Refresh Drives" button
25    RefreshDrivesClicked,
26
27    /// User clicked on a specific target drive
28    TargetDriveClicked(DriveInfo),
29
30    /// User clicked to open the device selection view
31    OpenDeviceSelection,
32
33    /// User clicked to close the device selection view
34    CloseDeviceSelection,
35
36    /// User clicked the "Flash" button
37    FlashClicked,
38
39    /// User clicked the "Reset" button (start over)
40    ResetClicked,
41
42    /// User clicked the "Cancel" button
43    CancelClicked,
44
45    /// User clicked "Cancel" during flash operation
46    CancelFlash,
47
48    // ========================================================================
49    // Animation Messages
50    // ========================================================================
51    /// Animation tick for progress bar effects
52    AnimationTick,
53
54    // ========================================================================
55    // Async Result Messages
56    // ========================================================================
57    /// Result from async image file selection
58    ///
59    /// Contains `Some(path)` if user selected a file, `None` if cancelled
60    ImageSelected(Option<PathBuf>),
61
62    /// Result from async drive detection
63    ///
64    /// Contains a list of detected drives
65    DrivesRefreshed(Vec<DriveInfo>),
66
67    /// Progress update from flash subscription
68    ///
69    /// Contains (progress 0.0-1.0, bytes_written, speed_mb_per_sec)
70    FlashProgressUpdate(f32, u64, f32),
71
72    /// Status message from flash operation
73    Status(String),
74
75    /// Result from async flash operation
76    ///
77    /// Contains `Ok(())` on success or `Err(message)` on failure
78    FlashCompleted(Result<(), String>),
79
80    /// User changed the application theme
81    ThemeChanged(Theme),
82}