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§
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,
ctrlc: Option<&Arc<AtomicBool>>
) -> Result<PipelineData, ShellError>
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.