Skip to main content

encode

Function encode 

Source
pub fn encode<T: Serialize>(value: &T) -> Result<Vec<u8>>
Expand description

Encode value in dora’s binary wire format.

This and encode_presized are the only encode entry points; call sites do not name the underlying codec, so it stays swappable from one file.

§Example

A value round-trips through encode and decode:

use dora_message::common::NodeExitStatus;

let bytes = dora_message::encode(&NodeExitStatus::ExitCode(1))?;
let decoded: NodeExitStatus = dora_message::decode(&bytes)?;
assert!(!decoded.is_success());