Skip to main content

ExtensionContext

Trait ExtensionContext 

Source
pub trait ExtensionContext {
    // Required methods
    fn current_document(&self) -> Option<&EditorDocument>;
    fn current_document_mut(&mut self) -> Option<&mut EditorDocument>;
    fn send_event(&mut self, event: DocumentEvent) -> Result<()>;
    fn get_config(&self, key: &str) -> Option<String>;
    fn set_config(&mut self, key: String, value: String) -> Result<()>;
    fn register_command(&mut self, command: ExtensionCommand) -> Result<()>;
    fn show_message(&mut self, message: &str, level: MessageLevel) -> Result<()>;
    fn get_extension_data(
        &self,
        extension_name: &str,
        key: &str,
    ) -> Option<String>;
    fn set_extension_data(&mut self, key: String, value: String) -> Result<()>;
}
Expand description

Extension context providing access to editor functionality

Required Methods§

Source

fn current_document(&self) -> Option<&EditorDocument>

Get the current document (if any)

Source

fn current_document_mut(&mut self) -> Option<&mut EditorDocument>

Get a mutable reference to the current document

Source

fn send_event(&mut self, event: DocumentEvent) -> Result<()>

Send an event to the event system

Source

fn get_config(&self, key: &str) -> Option<String>

Get configuration value

Source

fn set_config(&mut self, key: String, value: String) -> Result<()>

Set configuration value

Source

fn register_command(&mut self, command: ExtensionCommand) -> Result<()>

Register a command with the editor

Source

fn show_message(&mut self, message: &str, level: MessageLevel) -> Result<()>

Show a message to the user

Source

fn get_extension_data(&self, extension_name: &str, key: &str) -> Option<String>

Get data from another extension

Source

fn set_extension_data(&mut self, key: String, value: String) -> Result<()>

Set data for inter-extension communication

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§