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
DataContextinto the immutable rhaiMapa plugin’srender(ctx)receives. - discovery
- Plugin file discovery. Scans the configured
plugin_dirsplus the default$XDG_CONFIG_HOME/linesmith/segments/(falling back to~/.config/linesmith/segments/) for.rhaifiles, returning an ordered deduplicated path list. - engine
- Rhai engine construction for the plugin runtime.
- errors
PluginErrorcovers every failure mode described indocs/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. Seedocs/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 aRenderedSegmentthe layout engine can consume. - registry
- Plugin registry: the single source of truth for compiled
.rhaiscripts after discovery. Owns the parsed ASTs + resolved header data. Wrapping aCompiledPluginin theSegmenttrait is theRhaiSegmentadapter’s job, not this module’s. - segment
RhaiSegment— the adapter that lets a compiled.rhaiplugin participate in the layout engine as a first-classcrate::segments::Segment.