Serialize a `SwimMessage` into a zerompk byte buffer.
(msg: &SwimMessage)
| 16 | |
| 17 | /// Serialize a `SwimMessage` into a zerompk byte buffer. |
| 18 | pub fn encode(msg: &SwimMessage) -> Result<Vec<u8>, SwimError> { |
| 19 | zerompk::to_msgpack_vec(msg).map_err(|e| SwimError::Encode { |
| 20 | detail: e.to_string(), |
| 21 | }) |
| 22 | } |
| 23 | |
| 24 | /// Decode a zerompk byte buffer into a `SwimMessage`. Truncated or |
| 25 | /// malformed input returns [`SwimError::Decode`] rather than panicking. |