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

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 and clear the fiber map. The root context itself stays usable.

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.