Skip to main content

Crate linesmith_plugin

Crate linesmith_plugin 

Source
Expand description

linesmith-plugin: rhai plugin host for the linesmith status line.

Construction (build_engine) and load-time machinery (discovery, script compilation, @data_deps header parsing, id-collision detection) live here. The bridge that adapts a CompiledPlugin to linesmith-core’s Segment trait — and the DataContextrhai::Map mirror — lives in linesmith-core::plugins so this crate’s public surface stays free of linesmith-domain types.

Surface contract per ADR-0018: declared deps cross this boundary as Vec<String> (raw header tokens, validated against the plugin-accessible name set defined by header::KNOWN_DEPS per docs/specs/plugin-api.md); the consumer maps strings back to its own dep enum. pub use rhai; lets consumers reach rhai::Map / Engine / Dynamic via linesmith_plugin::rhai::* without adding rhai as a direct dep — workspace alignment is still the source of truth for which rhai version compiles together.

Workspace-internal in v0.1; public surface is free to refactor without SemVer cost until a publish decision lands.

Re-exports§

pub use discovery::scan_plugin_dirs;
pub use engine::build_engine;
pub use error::CollisionWinner;
pub use error::PluginError;
pub use error::ResourceLimit;
pub use header::parse_data_deps_header;
pub use header::HeaderError;
pub use registry::CompiledPlugin;
pub use registry::CompiledPluginParts;
pub use registry::PluginRegistry;
pub use rhai;

Modules§

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.
error
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.
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 a Segment adapter is the consumer’s job (see linesmith-core’s RhaiSegment), not this module’s.