Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installing Plugins

A plugin is a crate compiled into the application. Installing one records it and rebuilds.

StateWhereChanging it costs
Which plugins are compiled inplugins/plugins.tomla rebuild
Which of them are enabledthe databasea restart

Add one

$ lat plugin add ../rainmill-discovery
$ lat plugin add https://github.com/rainmill/discovery-plugin
$ cargo build

A checkout outside the project is linked into plugins/, not copied. --as <folder> picks the folder name.

The list

# plugins/plugins.toml
[[plugin]]
path = "rainmill-discovery"

[[plugin]]
path = "acme-blog"
source = "https://github.com/acme/blog-plugin"
CommandDescription
lat plugin addRecords a plugin and syncs.
lat plugin removeDrops the entry. --delete removes the folder; a link only loses its link.
lat plugin syncRegenerates plugins-manifest/ from the list. Run after editing by hand.
lat doctorChecks the list and the manifest agree.

Two entries resolving to one crate are refused.

Enable and disable

Settings → Plugins turns a compiled-in plugin off without a rebuild. The change applies at the next boot: a disabled plugin’s migrations do not run, it contributes nothing, and anything depending on it is skipped. Its tables stay.

Write one

Mark the crate, name its module, and declare the framework by version:

[package.metadata.laterite]
plugin = "acme.blog"

[dependencies]
laterite-core = "0.9"
laterite-admin = "0.9"

Expose the entry point at the crate root:

pub fn module() -> Box<dyn Module> {
    Box::new(MyModule)
}

The dependency requirement is the compatibility statement. lat plugin add refuses a plugin built for another Laterite:

$ lat plugin add ../acme-legacy
Error: acme-legacy needs laterite-core ^0.2, and this application is on 0.5.0.

Never declare the framework by path. An application on a local checkout maps it with [patch.crates-io], which lat new writes in development mode.