pub fn write_msgpack<T: ToMessagePack, W: Write>(
writer: &mut W,
value: &T,
) -> Result<()>Expand description
Serializes a value of type T into the I/O stream.
§Errors
Serialization can fail if T’s implementation of ToMessagePack returns an error, or if the underlying I/O operation fails.
§Examples
#[derive(zerompk::ToMessagePack)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
let mut file = std::fs::File::open("point.msgpack").unwrap();
zerompk::write_msgpack(&mut file, &point).unwrap();
}