Skip to main content

PluginHost

Struct PluginHost 

Source
pub struct PluginHost {
    pub errors: Vec<String>,
    /* private fields */
}
Expand description

Loads Rhai plugins and runs their commands against the editor.

Fields§

§errors: Vec<String>

Errors encountered while loading or running plugins.

Implementations§

Source§

impl PluginHost

Source

pub fn new() -> Self

Creates a host with the editor API installed but no plugins loaded.

Source

pub fn add_plugin(&mut self, name: &str, source: &str)

Adds (or replaces) a named plugin from source and rebuilds.

Source

pub fn load_dir(&mut self, dir: &Path)

Loads every .rhai file in a directory.

Source

pub fn commands(&self) -> Vec<CommandInfo>

All registered commands, sorted by title.

Source

pub fn command_titles(&self) -> Vec<String>

Source

pub fn keybindings(&self) -> Vec<(KeySpec, String)>

All registered keybindings.

Source

pub fn lookup_key(&self, key: &KeySpec) -> Option<String>

Finds the command title bound to a key, if any.

Source

pub fn run_command( &mut self, title: &str, ctx: &EditorContext, ) -> Vec<EditorAction>

Runs a command by title, returning the actions it requested.

Source

pub fn is_empty(&self) -> bool

Source

pub fn has_hook(&self, name: &str) -> bool

True when a loaded plugin defines name as a function.

Source

pub fn run_hook(&mut self, name: &str, ctx: &EditorContext) -> Vec<EditorAction>

Runs a lifecycle hook such as on_buffer_open or on_buffer_save.

A missing hook is not an error; it simply produces no actions. Errors inside a hook are collected in PluginHost::errors and returned as a message action so the frontend can surface them without crashing.

Trait Implementations§

Source§

impl Default for PluginHost

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.