Function nu_plugin::serve_plugin
source · pub fn serve_plugin(plugin: &mut impl Plugin, encoder: impl PluginEncoder)
Expand description
Function used to implement the communication protocol between nushell and an external plugin.
When creating a new plugin this function is typically used as the main entry point for the plugin, e.g.
fn main() {
serve_plugin(&mut MyPlugin::new(), MsgPackSerializer)
}
The object that is expected to be received by nushell is the PluginResponse
struct.
The serve_plugin
function should ensure that it is encoded correctly and sent
to StdOut for nushell to decode and and present its result.