#[cfg(feature = "unsafe-hot-reload")]
mod imp {
pub use chaud_hot::cycle::*;
pub type Epoch = u32;
}
#[cfg(not(feature = "unsafe-hot-reload"))]
mod imp {
pub type Epoch = ();
#[inline]
pub fn current() {}
#[inline]
pub fn check(_: &mut ()) -> bool {
false
}
#[inline]
#[track_caller]
pub fn wait(_: &mut ()) {
panic!("Cannot wait for hot-reload if hot-reloading is disabled.")
}
}
#[derive(Copy, Clone)]
pub struct Check {
epoch: imp::Epoch,
}
#[derive(Clone)]
pub struct Track {
epoch: imp::Epoch,
}
impl Check {
#[inline]
#[must_use]
#[expect(clippy::new_without_default, reason = "stateful")]
pub fn new() -> Self {
Self { epoch: imp::current() }
}
#[inline]
#[must_use]
pub fn did_reload(mut self) -> bool {
imp::check(&mut self.epoch)
}
#[inline]
#[track_caller]
pub fn wait(mut self) {
imp::wait(&mut self.epoch);
}
}
impl Track {
#[inline]
#[must_use]
#[expect(clippy::new_without_default, reason = "stateful")]
pub fn new() -> Self {
Self { epoch: imp::current() }
}
#[inline]
#[must_use]
pub fn did_reload(&mut self) -> bool {
imp::check(&mut self.epoch)
}
#[inline]
#[track_caller]
pub fn wait(&mut self) {
imp::wait(&mut self.epoch);
}
}