Trait nu_plugin_core::Encoder
source · pub trait Encoder<T>: Clone + Send + Sync {
// Required methods
fn encode(
&self,
data: &T,
writer: &mut impl Write
) -> Result<(), ShellError>;
fn decode(&self, reader: &mut impl BufRead) -> Result<Option<T>, ShellError>;
}Expand description
Encoder for a specific message type. Usually implemented on PluginInput
and PluginOutput.
Required Methods§
sourcefn encode(&self, data: &T, writer: &mut impl Write) -> Result<(), ShellError>
fn encode(&self, data: &T, writer: &mut impl Write) -> Result<(), ShellError>
Serialize a value in the PluginEncoders format
Returns ShellError::IOError if there was a problem writing, or
ShellError::PluginFailedToEncode for a serialization error.
sourcefn decode(&self, reader: &mut impl BufRead) -> Result<Option<T>, ShellError>
fn decode(&self, reader: &mut impl BufRead) -> Result<Option<T>, ShellError>
Deserialize a value from the PluginEncoder’s format
Returns None if there is no more output to receive.
Returns ShellError::IOError if there was a problem reading, or
ShellError::PluginFailedToDecode for a deserialization error.
Object Safety§
This trait is not object safe.