pub struct Loader { /* private fields */ }Expand description
Cheap cloneable loader handle.
Implementations§
Source§impl Loader
impl Loader
Sourcepub fn open(root: &Context, config: LoaderConfig) -> Result<Loader>
pub fn open(root: &Context, config: LoaderConfig) -> Result<Loader>
Open (creating if needed) the entry file, load the tree, and start every enabled entry.
Entries that fail to resolve or start do not abort the open; the
error is recorded and retrievable via Loader::last_error, and the
offending entry simply has no (or a failed) fiber.
Sourcepub fn file(&self) -> &LoaderFile
pub fn file(&self) -> &LoaderFile
The entry config file.
Sourcepub fn registry(&self) -> PluginRegistry
pub fn registry(&self) -> PluginRegistry
The plugin registry (a clone of the current state); populate it via
LoaderConfig::with_registry before open, or
Loader::register_plugin later.
Sourcepub fn register_plugin<P: Plugin>(&self, plugin: P)
pub fn register_plugin<P: Plugin>(&self, plugin: P)
Register one plugin instance by its own name; picked up by the next reload (or immediately for not-yet-started entries).
Sourcepub fn register<F>(&self, name: impl Into<String>, factory: F)
pub fn register<F>(&self, name: impl Into<String>, factory: F)
Register a handle factory under a name.
Sourcepub fn last_error(&self) -> Option<String>
pub fn last_error(&self) -> Option<String>
The last background error recorded by the loader, if any.
Sourcepub fn locate(&self, fiber: &Fiber) -> Option<Entry>
pub fn locate(&self, fiber: &Fiber) -> Option<Entry>
The entry whose fiber is fiber, if the loader started it.
Sourcepub fn reload(&self) -> Result<TreeDiff>
pub fn reload(&self) -> Result<TreeDiff>
Re-read the entry file and apply the difference to the fibers.
Created entries start (parents first), removed subtrees stop, moved entries restart under their new parent, updated entries are patched in place when only config changed and restarted otherwise. While the reload runs, the file is suspended, so the patches it causes are not written back; generated ids are persisted afterwards.