Struct minijinja_autoreload::AutoReloader
source · pub struct AutoReloader { /* private fields */ }
Expand description
An auto reloader for MiniJinja Environment
s.
Implementations§
source§impl AutoReloader
impl AutoReloader
sourcepub fn new<F>(f: F) -> AutoReloader
pub fn new<F>(f: F) -> AutoReloader
Creates a new auto reloader.
The given closure is invoked to create a new environment whenever the auto-reloader
detects that it should reload. It is passed a Notifier
which can be used to
signal back to the auto-reloader when the environment should be re-created.
sourcepub fn notifier(&self) -> Notifier
pub fn notifier(&self) -> Notifier
Returns a handle to the notifier.
This handle can be cloned and used for instance to trigger reloads from a background thread.
sourcepub fn acquire_env(&self) -> Result<EnvironmentGuard<'_>, Error>
pub fn acquire_env(&self) -> Result<EnvironmentGuard<'_>, Error>
Acquires a new environment, potentially reloading it if needed.
The acquired environment is protected by a guard. Until the guard is dropped the environment won’t be reloaded. Crucially the environment returned is also behind a shared reference which means that it won’t be possible to mutate it.
If the creator function passed to the constructor fails, the error is returned from this method.