pub struct HotReloadManager {
pub loaded_plugins: HashMap<String, PluginVersion>,
pub policy: ReloadPolicy,
pub watchers: Vec<WatchEntry>,
/* private fields */
}Expand description
Manages the hot-reload lifecycle for a set of plugins.
§Simulation note
This implementation does not perform actual dynamic library loading; it
manages the metadata and change-detection layer. The actual dlopen /
dlclose operations are performed by the loader module (feature-gated on
dynamic-loading).
Fields§
§loaded_plugins: HashMap<String, PluginVersion>Currently loaded plugins by ID.
policy: ReloadPolicyActive reload policy.
watchers: Vec<WatchEntry>File watchers for change detection.
Implementations§
Source§impl HotReloadManager
impl HotReloadManager
Sourcepub fn new(policy: ReloadPolicy) -> Self
pub fn new(policy: ReloadPolicy) -> Self
Create a new manager with the given policy and no loaded plugins.
Sourcepub fn register_loaded(&mut self, version: PluginVersion)
pub fn register_loaded(&mut self, version: PluginVersion)
Register a plugin as loaded with the given metadata.
Sourcepub fn watch(
&mut self,
plugin_id: impl Into<String>,
path: impl Into<String>,
initial_content: &[u8],
)
pub fn watch( &mut self, plugin_id: impl Into<String>, path: impl Into<String>, initial_content: &[u8], )
Add a watcher for a plugin path.
initial_content should be the current bytes of the plugin binary so
that the baseline hash is computed correctly.
Sourcepub fn check_for_changes(
&self,
current_content: &HashMap<String, Vec<u8>>,
) -> Vec<String>
pub fn check_for_changes( &self, current_content: &HashMap<String, Vec<u8>>, ) -> Vec<String>
Check for changes by comparing current_content (indexed by plugin_id)
against stored hashes.
Returns the IDs of plugins whose content has changed. The internal
last_hash values are not updated here; call update_hash after
a successful reload.
Sourcepub fn update_hash(&mut self, plugin_id: &str, new_content: &[u8])
pub fn update_hash(&mut self, plugin_id: &str, new_content: &[u8])
Update the stored hash for a plugin after a successful reload.
Sourcepub fn reload_plugin(
&mut self,
plugin_id: &str,
new_version: PluginVersion,
) -> PluginResult<()>
pub fn reload_plugin( &mut self, plugin_id: &str, new_version: PluginVersion, ) -> PluginResult<()>
Simulate reloading a plugin (metadata update only — no actual dlopen).
Updates the loaded_at timestamp and version hash in the manager’s
internal state.
§Errors
Returns PluginError::NotFound if the plugin ID is not currently loaded.
Sourcepub fn unload_plugin(&mut self, plugin_id: &str) -> PluginResult<PluginVersion>
pub fn unload_plugin(&mut self, plugin_id: &str) -> PluginResult<PluginVersion>
Unload a plugin, removing it from the manager.
§Errors
Returns PluginError::NotFound if the plugin is not loaded.
Sourcepub fn is_scheduled_reload_due(&mut self) -> bool
pub fn is_scheduled_reload_due(&mut self) -> bool
Check whether a scheduled reload is due.
Returns true only when the policy is ReloadPolicy::Scheduled and
the interval has elapsed. Resets the internal timer on a true return.
Sourcepub fn auto_reload_enabled(&self) -> bool
pub fn auto_reload_enabled(&self) -> bool
Return true if the policy allows automatic reloading.
Auto Trait Implementations§
impl Freeze for HotReloadManager
impl RefUnwindSafe for HotReloadManager
impl Send for HotReloadManager
impl Sync for HotReloadManager
impl Unpin for HotReloadManager
impl UnsafeUnpin for HotReloadManager
impl UnwindSafe for HotReloadManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more