pub struct Reloadable<Host> { /* private fields */ }Expand description
A Reloadable represents a handle to library that can be live reloaded.
Implementations§
Source§impl<Host> Reloadable<Host>
impl<Host> Reloadable<Host>
Sourcepub fn new<P: AsRef<Path>>(path: P, host: Host) -> Result<Self, Error>
pub fn new<P: AsRef<Path>>(path: P, host: Host) -> Result<Self, Error>
Create a new Reloadable library.
This takes the path to a dynamic library containing a RELOAD_API
symbol that exports the functions needed for live reloading. In order to
define this symbol in your own reloadable libraries, see the
live_reload! macro. This will load the library and initialize a
filesystem watcher pointing to the file in order to know when the
library has changed.
Sourcepub fn reload(&mut self) -> Result<(), Error>
pub fn reload(&mut self) -> Result<(), Error>
Reload the library if it has changed, otherwise do nothing.
This will consult with the filesystem watcher, and if the library has
been recreated or updated, it will reload the library. See
reload_now for details on what happens when a library is reloaded.
Sourcepub fn reload_now(&mut self) -> Result<(), Error>
pub fn reload_now(&mut self) -> Result<(), Error>
Immediately reload the library without checking whether it has changed.
This first calls unload on the currently loaded library, then unloads
the dynamic library. Next, it loads the new dynamic library, and calls
reload on that. If the new library fails to load, this method will
return an Err and the Reloadable will be left with no library
loaded.
Sourcepub fn update(&mut self) -> ShouldQuit
pub fn update(&mut self) -> ShouldQuit
Call the update method on the library.
If no library is currently loaded, this does nothing and returns
ShouldQuit::No.