Skip to main content

Loader

Struct Loader 

Source
pub struct Loader { /* private fields */ }
Expand description

Cheap cloneable loader handle.

Implementations§

Source§

impl Loader

Source

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.

Source

pub fn context(&self) -> &Context

The root context the loader operates on.

Source

pub fn tree(&self) -> &EntryTree

The entry tree.

Source

pub fn file(&self) -> &LoaderFile

The entry config file.

Source

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.

Source

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).

Source

pub fn register<F>(&self, name: impl Into<String>, factory: F)
where F: Fn() -> PluginHandle + Send + Sync + 'static,

Register a handle factory under a name.

Source

pub fn last_error(&self) -> Option<String>

The last background error recorded by the loader, if any.

Source

pub fn set_write_debounce(&self, delay: Option<Duration>)

Set (or clear, with None) the debounce window for coalesced config writes.

Source

pub fn locate(&self, fiber: &Fiber) -> Option<Entry>

The entry whose fiber is fiber, if the loader started it.

Source

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, redefined entries (plugin name, inject declaration, or enabled flag changed) stop and start with their new options, and updated entries are patched in place — their config-only change never restarts the fiber. A patch the plugin rejects leaves the fiber on its current config and is retried by the next reload. Patches are never written back to the file; only newly generated ids are persisted afterwards. The whole reconcile runs under the loader’s operation lock, serialized against update_config and dispose.

Source

pub fn update(&self, document: Document) -> Result<TreeDiff>

Recompose from a caller-supplied document — the in-memory twin of reload: the same full reconcile (diff → stop → patch → start) under the same operation lock, but composed from document instead of any file, and without write-back. A recomposition is not a file edit (upstream’s internal/update persists nothing either); ids generated for id-less rows stay in memory, so those rows restart on every recomposition — the draft is regenerated anyway.

The document also becomes the loader’s composition source: later reloads recompose from it instead of re-reading the root file (import files are still read). This is the core HMR primitive — a watcher recomposes fresh layers and hands the result to update.

Source

pub fn update_config(&self, id: &str, config: Node) -> Result<()>

Change one entry’s config at runtime: the fiber is updated (and restarted when active) and the new config is persisted to the file.

Source

pub fn dispose(&self) -> Result<()>

Stop every entry, stop watching files, and release the loader’s root-level effects (the status listener and the loader service). The root context stays usable, and a fresh Loader::open on the same root works afterwards.

Trait Implementations§

Source§

impl Clone for Loader

Source§

fn clone(&self) -> Loader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.