Skip to main content

Module plugins

Module plugins 

Source
Expand description

Rhai plugin runtime for user-authored segments.

Plugins are .rhai files discovered at startup (per docs/specs/plugin-api.md), compiled once, wrapped in a RhaiSegment adapter, and registered alongside built-ins. This module root re-exports build_engine — the constructor for the shared Arc<Engine> every plugin invokes call_fn on — and PluginError, the load-time + render-time failure surface.

Re-exports§

pub use ctx_mirror::build_ctx;
pub use discovery::scan_plugin_dirs;
pub use engine::build_engine;
pub use errors::CollisionWinner;
pub use errors::PluginError;
pub use errors::ResourceLimit;
pub use header::parse_data_deps_header;
pub use header::HeaderError;
pub use output::validate_return;
pub use registry::CompiledPlugin;
pub use registry::PluginRegistry;
pub use segment::RhaiSegment;

Modules§

ctx_mirror
Converts a DataContext into the immutable rhai Map a plugin’s render(ctx) receives.
discovery
Plugin file discovery. Scans the configured plugin_dirs plus the default $XDG_CONFIG_HOME/linesmith/segments/ (falling back to ~/.config/linesmith/segments/) for .rhai files, returning an ordered deduplicated path list.
engine
Rhai engine construction for the plugin runtime.
errors
PluginError covers every failure mode described in docs/specs/plugin-api.md §Edge cases.
header
Parses the optional @data_deps = [...] declaration from the first contiguous block of // line comments at the top of a plugin script. See docs/specs/plugin-api.md §@data_deps header syntax for the full contract.
output
Validates the value a plugin’s render(ctx) function returns and converts it into a RenderedSegment the layout engine can consume.
registry
Plugin registry: the single source of truth for compiled .rhai scripts after discovery. Owns the parsed ASTs + resolved header data. Wrapping a CompiledPlugin in the Segment trait is the RhaiSegment adapter’s job, not this module’s.
segment
RhaiSegment — the adapter that lets a compiled .rhai plugin participate in the layout engine as a first-class crate::segments::Segment.