Skip to main content

InterfaceManager

Trait InterfaceManager 

Source
pub trait InterfaceManager {
    type Interface: Interface + 'static;
    type Input;

    // Required methods
    fn get_interface(&self) -> Self::Interface;
    fn consume(&mut self, input: Self::Input) -> Result<(), ShellError>;
    fn stream_manager(&self) -> &StreamManager;
    fn prepare_pipeline_data(
        &self,
        data: PipelineData,
    ) -> Result<PipelineData, ShellError>;

    // Provided methods
    fn consume_stream_message(
        &mut self,
        message: StreamMessage,
    ) -> Result<(), ShellError> { ... }
    fn read_pipeline_data(
        &self,
        header: PipelineDataHeader,
        signals: &Signals,
    ) -> Result<PipelineData, ShellError> { ... }
}
Expand description

An interface manager handles I/O and state management for communication between a plugin and the engine. See PluginInterfaceManager in nu-plugin-engine for communication from the engine side to a plugin, or EngineInterfaceManager in nu-plugin for communication from the plugin side to the engine.

There is typically one InterfaceManager consuming input from a background thread, and managing shared state.

Required Associated Types§

Source

type Interface: Interface + 'static

The corresponding interface type.

Source

type Input

The input message type.

Required Methods§

Source

fn get_interface(&self) -> Self::Interface

Make a new interface that communicates with this InterfaceManager.

Source

fn consume(&mut self, input: Self::Input) -> Result<(), ShellError>

Consume an input message.

When implementing, call .consume_stream_message() for any encapsulated StreamMessages received.

Source

fn stream_manager(&self) -> &StreamManager

Get the StreamManager for handling operations related to stream messages.

Source

fn prepare_pipeline_data( &self, data: PipelineData, ) -> Result<PipelineData, ShellError>

Prepare PipelineData after reading. This is called by read_pipeline_data() as a hook so that values that need special handling can be taken care of.

Provided Methods§

Source

fn consume_stream_message( &mut self, message: StreamMessage, ) -> Result<(), ShellError>

Consume an input stream message.

This method is provided for implementors to use.

Source

fn read_pipeline_data( &self, header: PipelineDataHeader, signals: &Signals, ) -> Result<PipelineData, ShellError>

Generate PipelineData for reading a stream, given a PipelineDataHeader that was received from the other side.

This method is provided for implementors to use.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§