fn write_body<F>(buf: &mut BytesMut, f: F) -> Result<()>where F: FnOnce(&mut BytesMut) -> Result<()>,
Call f() to write body of the message and prepend it with 4-byte len as prescribed by the protocol. First write out body value and fill length value as i32 in front of it.