dioxus_devtools_types/
lib.rs

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