pub struct RhaiSegment { /* private fields */ }Expand description
A plugin-authored segment backed by a compiled rhai script.
Implementations§
Source§impl RhaiSegment
impl RhaiSegment
Sourcepub fn from_compiled(
plugin: CompiledPlugin,
engine: Arc<Engine>,
config: Dynamic,
) -> Self
pub fn from_compiled( plugin: CompiledPlugin, engine: Arc<Engine>, config: Dynamic, ) -> Self
Wrap a CompiledPlugin in the Segment trait.
config is the plugin’s [segments.<id>] TOML table, already
converted to a rhai-compatible Dynamic. Pass Dynamic::UNIT
when no table is configured.
Consumes plugin: the AST and declared deps move into the
segment, and declared_deps is promoted to &'static via
Vec::leak — see Segment::data_deps for why.
pub fn id(&self) -> &str
Trait Implementations§
Source§impl Segment for RhaiSegment
impl Segment for RhaiSegment
Source§fn render(&self, ctx: &DataContext, rc: &RenderContext) -> RenderResult
fn render(&self, ctx: &DataContext, rc: &RenderContext) -> RenderResult
Render this segment for the given context. Read more
Source§fn data_deps(&self) -> &'static [DataDep]
fn data_deps(&self) -> &'static [DataDep]
Declare which data sources this segment reads. The runtime
computes the union across all enabled segments and lazy-fetches
only those sources. Defaults to the stdin payload only; segments
that read other sources must override. See
docs/specs/data-fetching.md §Segment dependency declaration. Read moreSource§fn shrink_to_fit(
&self,
ctx: &DataContext,
rc: &RenderContext,
target: u16,
) -> Option<RenderedSegment>
fn shrink_to_fit( &self, ctx: &DataContext, rc: &RenderContext, target: u16, ) -> Option<RenderedSegment>
Layout-pressure-aware compaction hook. The reflow loop calls
this on any segment under width pressure (truncatable or
not), asking whether it can produce a render at most
target
cells wide. It runs before truncatable end-ellipsis
truncation, so segment-side intelligence beats generic
string clipping when both apply. Default returns None (no
compact form available; engine falls through to truncatable
or drop). Segments with structured tail content override to
shed decoration while keeping the signal-bearing prefix. Read moreSource§fn defaults(&self) -> SegmentDefaults
fn defaults(&self) -> SegmentDefaults
Layout defaults (priority, width bounds, truncatable opt-in).
User config may override each field via
OverriddenSegment.
Implementations must be O(1), do no I/O, and avoid allocation:
the layout engine snapshots this at collect time and the
[LineItem::Debug] impl reads it for dbg! / panic-backtrace
formatting.Auto Trait Implementations§
impl Freeze for RhaiSegment
impl !RefUnwindSafe for RhaiSegment
impl Send for RhaiSegment
impl Sync for RhaiSegment
impl Unpin for RhaiSegment
impl UnsafeUnpin for RhaiSegment
impl !UnwindSafe for RhaiSegment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more