pub fn encode<T: Serialize>(msg: &T) -> Result<Vec<u8>>
Encode a message to length-prefixed CBOR wire format.