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§
Required Methods§
Sourcefn get_interface(&self) -> Self::Interface
fn get_interface(&self) -> Self::Interface
Make a new interface that communicates with this InterfaceManager
.
Sourcefn consume(&mut self, input: Self::Input) -> Result<(), ShellError>
fn consume(&mut self, input: Self::Input) -> Result<(), ShellError>
Consume an input message.
When implementing, call .consume_stream_message()
for any encapsulated
StreamMessage
s received.
Sourcefn stream_manager(&self) -> &StreamManager
fn stream_manager(&self) -> &StreamManager
Get the StreamManager
for handling operations related to stream messages.
Sourcefn prepare_pipeline_data(
&self,
data: PipelineData,
) -> Result<PipelineData, ShellError>
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§
Sourcefn consume_stream_message(
&mut self,
message: StreamMessage,
) -> Result<(), ShellError>
fn consume_stream_message( &mut self, message: StreamMessage, ) -> Result<(), ShellError>
Consume an input stream message.
This method is provided for implementors to use.
Sourcefn read_pipeline_data(
&self,
header: PipelineDataHeader,
signals: &Signals,
) -> Result<PipelineData, ShellError>
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.