pub fn encode<T: Serialize>(msg: &T) -> Result<String, Error>
Encode a message as a newline-delimited JSON string.