dioxus_devtools_types/
lib.rs

1use dioxus_core::internal::HotReloadTemplateWithLocation;
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5/// A message the hot reloading server sends to the client
6#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
7pub enum DevserverMsg {
8    /// Attempt a hotreload
9    /// This includes all the templates/literals/assets/binary patches that have changed in one shot
10    HotReload(HotReloadMsg),
11
12    /// The devserver is starting a full rebuild.
13    FullReloadStart,
14
15    /// The full reload failed.
16    FullReloadFailed,
17
18    /// The app should reload completely if it can
19    FullReloadCommand,
20
21    /// The program is shutting down completely - maybe toss up a splash screen or something?
22    Shutdown,
23}
24
25/// A message the client sends from the frontend to the devserver
26///
27/// This is used to communicate with the devserver
28#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
29pub enum ClientMsg {
30    Log {
31        level: String,
32        messages: Vec<String>,
33    },
34}
35
36#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
37pub struct HotReloadMsg {
38    pub templates: Vec<HotReloadTemplateWithLocation>,
39    pub assets: Vec<PathBuf>,
40    pub unknown_files: Vec<PathBuf>,
41}
42
43impl HotReloadMsg {
44    pub fn is_empty(&self) -> bool {
45        self.templates.is_empty() && self.assets.is_empty() && self.unknown_files.is_empty()
46    }
47}