stak_module/
hot_reload.rs1use crate::{Guard, Module};
4use core::ops::Deref;
5
6pub struct HotReloadModule {
8 module: hmr::Module,
9}
10
11impl HotReloadModule {
12 pub const fn new(path: &'static str) -> Self {
14 Self {
15 module: hmr::Module::new(path),
16 }
17 }
18}
19
20impl Module<'static> for HotReloadModule {
21 type Guard = HotReloadGuard;
22
23 fn bytecode(&'static self) -> Self::Guard {
24 HotReloadGuard(self.module.load())
25 }
26}
27
28pub struct HotReloadGuard(hmr::Guard);
30
31impl Deref for HotReloadGuard {
32 type Target = [u8];
33
34 fn deref(&self) -> &Self::Target {
35 &self.0
36 }
37}
38
39impl Guard for HotReloadGuard {}