Trait nu_plugin_core::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,
        ctrlc: Option<&Arc<AtomicBool>>
    ) -> 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, ctrlc: Option<&Arc<AtomicBool>> ) -> 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.

Implementors§